Edinburgh Speech Tools 2.4-release
EST_ServiceTable.h
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/** A global table of known services. Used for fringe and festival
43 * 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 */
48
50
51
52public:
53 /** 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
59 class Entry
60 {
61 public:
62 /// Name of the server.
64 /// Type of server (eg `fringe')
66 /// Human readable hostname.
68 /// Numeric IP address (###.###.###.###)
70 /// A random string to send as authorisation.
72 /// TCP port number.
73 int port;
74
75 /// Create an empty entry.
77
78 /// A suitable human readable name for the entry.
79 operator EST_String() const;
80
81 /// All entries are taken to be different.
82 friend bool operator == (const Entry &a, const Entry &b);
83
84 /// Print in human readable form.
85 friend ostream & operator << (ostream &s, const Entry &a);
86 };
87
88private:
89
90 class EntryTable
91 {
92 public:
96 };
97
98 /// Table of available Fringe servers.
99 static EntryTable entries;
100
101 static bool random_init;
102 static void init_random(void);
103
104public:
105
106 /**@name Finding What Services Are Available.
107 *
108 * Servers maintain a per-user file which lists the processes
109 * which are running in server mode by name. These functions read
110 * that table. */
111 //@{
112
113 /// Read the users default table. <filename>~/.estServices</filename>
114 static void read_table(void);
115 /// Read a specific table.
116 static void read_table(EST_String socketsFileName);
117 /// Write the users default table. <filename>~/.estServices</filename>
118 static void write_table(void);
119 /// Write a specific table.
120 static void write_table(EST_String socketsFileName);
121 /// List the table to given stream
122 static void list(ostream &s, const EST_String type);
123 /// Return a list of server names.
124 static void names(EST_TList<EST_String> &names, const EST_String type="");
125
126 //@}
127
128 /** Return the entry for the server with the given name and type.
129 * If no such entry is found a dummy entry with a port of 0 is returned.
130 */
131 static const Entry &lookup(const EST_String name,
132 const EST_String type);
133
134 /** Create an entry for a server of the given name and type which is
135 * listening on the given socket.
136 */
137 static const Entry &create(const EST_String name,
138 const EST_String type,
139 int socket);
140
141};
142
143#endif
144
EST_String cookie
A random string to send as authorisation.
friend bool operator==(const Entry &a, const Entry &b)
All entries are taken to be different.
friend ostream & operator<<(ostream &s, const Entry &a)
Print in human readable form.
Entry()
Create an empty entry.
int port
TCP port number.
EST_String type
Type of server (eg ‘fringe’)
EST_String name
Name of the server.
EST_String address
Numeric IP address (###.###.###.###)
EST_String hostname
Human readable hostname.
static const Entry & lookup(const EST_String name, const EST_String type)
static void write_table(void)
Write the users default table. <filename>~/.estServices</filename>
static void read_table(void)
Read the users default table. <filename>~/.estServices</filename>
static void write_table(EST_String socketsFileName)
Write a specific table.
static const Entry & create(const EST_String name, const EST_String type, int socket)
static void names(EST_TList< EST_String > &names, const EST_String type="")
Return a list of server names.
static void read_table(EST_String socketsFileName)
Read a specific table.
static void list(ostream &s, const EST_String type)
List the table to given stream.