Edinburgh Speech Tools  2.1-release
EST_ServiceTable.h
Go to the documentation of this file.
1  /************************************************************************/
2  /* */
3  /* Centre for Speech Technology Research */
4  /* University of Edinburgh, UK */
5  /* Copyright (c) 1996,1997 */
6  /* All Rights Reserved. */
7  /* */
8  /* Permission is hereby granted, free of charge, to use and distribute */
9  /* this software and its documentation without restriction, including */
10  /* without limitation the rights to use, copy, modify, merge, publish, */
11  /* distribute, sublicense, and/or sell copies of this work, and to */
12  /* permit persons to whom this work is furnished to do so, subject to */
13  /* the following conditions: */
14  /* 1. The code must retain the above copyright notice, this list of */
15  /* conditions and the following disclaimer. */
16  /* 2. Any modifications must be clearly marked as such. */
17  /* 3. Original authors' names are not deleted. */
18  /* 4. The authors' names are not used to endorse or promote products */
19  /* derived from this software without specific prior written */
20  /* permission. */
21  /* */
22  /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
23  /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24  /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25  /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
26  /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27  /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28  /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29  /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30  /* THIS SOFTWARE. */
31  /* */
32  /*************************************************************************/
33 
34 
35 #ifndef __EST_SERVICETABLE_H__
36 #define __EST_SERVICETABLE_H__
37 
38 #include "EST_String.h"
39 #include "EST_rw_status.h"
40 #include "EST_TKVL.h"
41 
42 /** \class EST_ServiceTable
43  * \brief A global table of known services. Used for fringe and festival servers.
44  *
45  * @author Richard Caley <rjc@cstr.ed.ac.uk>
46  * @version $Id: EST_ServiceTable.h,v 1.2 2001/04/04 13:11:27 awb Exp $
47  */
49 
50 
51 public:
52  /** \class Entry
53  * \brief A service record.
54  *
55  * This is returned by service lookup operations, it contains
56  * enough information to contact the server and authenticate yourself.
57  */
58  class Entry
59  {
60  public:
61  /// Name of the server.
63  /// Type of server (eg `fringe')
65  /// Human readable hostname.
67  /// Numeric IP address (###.###.###.###)
69  /// A random string to send as authorisation.
71  /// TCP port number.
72  int port;
73 
74  /// Create an empty entry.
75  Entry();
76 
77  /// A suitable human readable name for the entry.
78  operator EST_String() const;
79 
80  /// All entries are taken to be different.
81  friend bool operator == (const Entry &a, const Entry &b);
82 
83  /// Print in human readable form.
84  friend ostream & operator << (ostream &s, const Entry &a);
85  };
86 
87 private:
88 
89  class EntryTable
90  {
91  public:
94  typedef EST_TKVL<EST_String, Entry>::KeyEntries KeyEntries;
95  };
96 
97  /// Table of available Fringe servers.
98  static EntryTable entries;
99 
100  static bool random_init;
101  static void init_random(void);
102 
103 public:
104 
105  /**@name Finding What Services Are Available.
106  *
107  * Servers maintain a per-user file which lists the processes
108  * which are running in server mode by name. These functions read
109  * that table. */
110  ///@{
111 
112  /// Read the users default table. `~/.estServices`
113  static void read_table(void);
114  /// Read a specific table.
115  static void read_table(EST_String socketsFileName);
116  /// Write the users default table. `~/.estServices`
117  static void write_table(void);
118  /// Write a specific table.
119  static void write_table(EST_String socketsFileName);
120  /// List the table to given stream
121  static void list(ostream &s, const EST_String type);
122  /// Return a list of server names.
123  static void names(EST_TList<EST_String> &names, const EST_String type="");
124 
125  ///@}
126 
127  /** Return the entry for the server with the given name and type.
128  * If no such entry is found a dummy entry with a port of 0 is returned.
129  */
130  static const Entry &lookup(const EST_String name,
131  const EST_String type);
132 
133  /** Create an entry for a server of the given name and type which is
134  * listening on the given socket.
135  */
136  static const Entry &create(const EST_String name,
137  const EST_String type,
138  int socket);
139 
140 };
141 
142 #endif
143 
EST_String type
Type of server (eg `fringe&#39;)
int port
TCP port number.
friend ostream & operator<<(ostream &s, const Entry &a)
Print in human readable form.
A service record.
EST_String hostname
Human readable hostname.
static void read_table(void)
Read the users default table. ~/.estServices
static void names(EST_TList< EST_String > &names, const EST_String type="")
Return a list of server names.
EST_String name
Name of the server.
static const Entry & lookup(const EST_String name, const EST_String type)
Entry()
Create an empty entry.
EST_String address
Numeric IP address (###.###.###.###)
Templated Key-Value list. Objects of type EST_TKVL contain lists which are accessed by a key of type ...
Definition: EST_TKVL.h:73
static const Entry & create(const EST_String name, const EST_String type, int socket)
static void write_table(void)
Write the users default table. ~/.estServices
A global table of known services. Used for fringe and festival servers.
friend bool operator==(const Entry &a, const Entry &b)
All entries are taken to be different.
static void list(ostream &s, const EST_String type)
List the table to given stream.
EST_String cookie
A random string to send as authorisation.
EST_String