1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
|
/* -*- C++ -*- */
// $Id$
/*-*- C++ -*- */
// ============================================================================
//
// = LIBRARY
// ACE
//
// = FILENAME
// ACE_Naming_Context.h
//
// = AUTHOR
// Gerhard Lenzer, Douglas C. Schmidt, and Prashant Jain
//
// ============================================================================
#if !defined (ACE_NAMING_CONTEXT_H)
#define ACE_NAMING_CONTEXT_H
#include "ace/ACE.h"
#include "ace/SString.h"
#include "ace/Set.h"
#include "ace/Service_Object.h"
#include "ace/Name_Proxy.h"
#include "ace/Name_Space.h"
// Forward decl
class ACE_Name_Options;
class ACE_Export ACE_Naming_Context : public ACE_Service_Object
// = TITLE
// Maintaining accesses Name Server Databases. Allows to add
// NameBindings, change them, remove them and resolve
// NameBindings
//
// = DESCRIPTION
// Manages a Naming Service . That represents a persistent
// string to string mapping for different scopes. The scope of a
// ACE_Naming_Context may be either local for the calling
// process (Note : A process is hereby not identified by it's
// pid, but by it's argv[0]. So different processes (in UNIX
// syntax) may access the same NameBindings), global for all
// processes running on one host or global for all processes on
// the net (that know the address of the net name server
// socket). Strings may be plain character strings or Wide
// character strings. A Name Binding consists of a name string
// (that's the key), a value string and an optional type string
// (no wide chars).
{
public:
enum Context_Scope_Type
{
PROC_LOCAL, // Name lookup is local to the process.
NODE_LOCAL, // Name lookup is local to the node (host).
NET_LOCAL // Name lookup is local to the (sub)network.
};
// = Initialization and termination methods.
ACE_Naming_Context (void);
// "Do-nothing" constructor.
ACE_Naming_Context (Context_Scope_Type scope_in, int light = 0);
// Specifies the scope of this namespace, opens and memory-maps the
// associated file (if accessible) or contacts the dedicated name
// server process for NET_LOCAL namespace. Note that <light>
// specifies whether or not we want to use
// ACE_Lite_MMap_Memory_Pool. By default we use ACE_MMap_Memory_Pool.
int open (Context_Scope_Type scope_in = ACE_Naming_Context::PROC_LOCAL,
int light = 0);
// Specifies the scope of this namespace, opens and memory-maps the
// associated file (if accessible) or contacts the dedicated name
// server process for NET_LOCAL namespace. Note that <light>
// specifies whether or not we want to use
// ACE_Lite_MMap_Memory_Pool. By default we use ACE_MMap_Memory_Pool.
int close (void);
// Deletes the instance of Name Space. Must be called before
// switching name spaces.
~ACE_Naming_Context (void);
// destructor, do some cleanup :TBD: last dtor should "compress"
// file
// = Dynamic initialization hooks.
virtual int init (int argc, char *argv[]);
// Initialize name options and naming context when dynamically
// linked.
virtual int fini (void);
// Close down the test when dynamically unlinked.
virtual int info (char **strp, size_t length) const;
// Returns information about this context.
ACE_Name_Options *name_options (void);
// Returns the ACE_Name_Options associated with the Naming_Context
int bind (const ACE_WString &name_in,
const ACE_WString &value_in,
const char *type_in = "");
// Bind a new name to a naming context (Wide character strings).
int bind (const char *name_in,
const char *value_in,
const char *type_in = "");
// Bind a new name to a naming context ( character strings).
int rebind (const ACE_WString &name_in,
const ACE_WString &value_in,
const char *type_in = "");
// Overwrite the value or type of an existing name in a
// ACE_Naming_Context or bind a new name to the context, if it
// didn't exist yet. (Wide charcter strings interface).
int rebind (const char *name_in,
const char *value_in,
const char *type_in = "");
// Overwrite the value or type of an existing name in a
// ACE_Naming_Context or bind a new name to the context, if it
// didn't exist yet. ( charcter strings interface)
int unbind (const ACE_WString &name_in);
// Delete a name from a ACE_Naming_Context (Wide charcter strings
// Interface).
int unbind (const char *name_in);
// Delete a name from a ACE_Naming_Context (character strings
// interface).
int resolve (const ACE_WString &name_in,
ACE_WString &value_out,
char *&type_out);
// Get value and type of a given name binding (Wide chars). The
// caller is responsible for deleting both <value_out> and <type_out>!
int resolve (const char *name_in,
ACE_WString &value_out,
char *&type_out);
// Get value and type of a given name binding (Wide chars output).
// The caller is responsible for deleting both <value_out> and
// <type_out>!
int resolve (const char *name_in,
char *&value_out,
char *&type_out);
// Get value and type of a given name binding ( chars ). The caller
// is responsible for deleting both <value_out> and <type_out>!
int list_names (ACE_PWSTRING_SET &set_out,
const ACE_WString &pattern_in);
// Get a set of names matching a specified pattern (wchars). Matching
// means the names must begin with the pattern string.
int list_names (ACE_PWSTRING_SET &set_out,
const char *pattern_in);
// Get a set of names matching a specified pattern (chars). Matching
// means the names must begin with the pattern string.
int list_values (ACE_PWSTRING_SET &set_out,
const ACE_WString &pattern_in);
// Get a set of values matching a specified pattern (wchars). Matching
// means the values must begin with the pattern string.
int list_values (ACE_PWSTRING_SET &set_out,
const char *pattern_in);
// Get a set of values matching a specified pattern (chars). Matching
// means the values must begin with the pattern string.
int list_types (ACE_PWSTRING_SET &set_out,
const ACE_WString &pattern_in);
// Get a set of types matching a specified pattern (wchars). Matching
// means the types must begin with the pattern string.
int list_types (ACE_PWSTRING_SET &set_out,
const char *pattern_in);
// Get a set of types matching a specified pattern (chars). Matching
// means the types must begin with the pattern string.
virtual int list_name_entries (ACE_BINDING_SET &set_out,
const ACE_WString &pattern_in);
// Get a set of names matching a specified pattern (wchars). Matching
// means the names must begin with the pattern string. Returns the
// complete binding associated each pattern match.
virtual int list_name_entries (ACE_BINDING_SET &set_out,
const char *pattern_in);
// Get a set of names matching a specified pattern (wchars). Matching
// means the names must begin with the pattern string. Returns the
// complete binding associated each pattern match.
virtual int list_value_entries (ACE_BINDING_SET &set_out,
const ACE_WString &pattern_in);
// Get a set of values matching a specified pattern (wchars). Matching
// means the values must begin with the pattern string. Returns the
// complete binding associated each pattern match.
virtual int list_value_entries (ACE_BINDING_SET &set_out,
const char *pattern_in);
// Get a set of values matching a specified pattern (wchars). Matching
// means the values must begin with the pattern string. Returns the
// complete binding associated each pattern match.
virtual int list_type_entries (ACE_BINDING_SET &set_out,
const ACE_WString &pattern_in);
// Get a set of types matching a specified pattern (wchars). Matching
// means the types must begin with the pattern string. Returns the
// complete binding associated each pattern match.
virtual int list_type_entries (ACE_BINDING_SET &set_out,
const char *pattern_in);
// Get a set of types matching a specified pattern (wchars). Matching
// means the types must begin with the pattern string. Returns the
// complete binding associated each pattern match.
void dump ();
// Dump the state of the object.
private:
ACE_Name_Options *name_options_;
// Keep track of the options such as database name etc per Naming Context
ACE_Name_Space *name_space_;
// Name space (can be either local or remote) dynamically bound.
char hostname_[MAXHOSTNAMELEN + 1];
// Holds the local hostname.
const char *netnameserver_host_;
// Holds name of net name server.
int netnameserver_port_;
// Holds port number of the net name server.
int local (void);
// 1 if we're on the same local machine as the name server, else 0.
};
class ACE_Export ACE_Name_Options
// = TITLE
// Manages the options for the ACE Name_Server.
{
public:
// = Initialization and termination methods.
ACE_Name_Options (void);
~ACE_Name_Options (void);
void parse_args (int argc, char *argv[]);
// Parse arguments
// = Set/Get port number
void nameserver_port (int port);
int nameserver_port (void);
// = Set/Get the context
ACE_Naming_Context::Context_Scope_Type context (void);
void context (ACE_Naming_Context::Context_Scope_Type);
// = Set/Get host name
void nameserver_host (const char *host);
const char *nameserver_host (void);
// = Set/Get name space directory
void namespace_dir (LPCTSTR dir);
LPCTSTR namespace_dir (void);
// = Set/Get process name
void process_name (LPCTSTR dir);
LPCTSTR process_name (void);
// = Set/Get database name
void database (LPCTSTR);
LPCTSTR database (void);
// = Set/Get base address of the underlying allocator
void base_address (char *address);
char *base_address (void);
// Set/Get use of registry in naming
int use_registry (void);
void use_registry (int);
int debug (void);
// Return debug status
int verbose (void);
// Return verbose status
private:
int debugging_;
// Extra debugging info
int verbosity_;
// Extra verbose messages
int use_registry_;
// Use Win32 Registry
int nameserver_port_;
// Port to connect to nameserver process.
const char *nameserver_host_;
// Hostname of nameserver.
LPCTSTR namespace_dir_;
// Directory to hold name_bindings.
LPCTSTR process_name_;
// Name of this process.
LPCTSTR database_;
// Name of the database that stores the name/value/type bindings.
char *base_address_;
// Base address of the underlying allocator
ACE_Naming_Context::Context_Scope_Type context_;
// The context in which the naming database will be created.
};
// We can't use the ACE_SVC_FACTORY_DECLARE macro here because this
// needs to be in the ACE_Export context rather than the
// ACE_Svc_Export context.
extern "C" ACE_Export ACE_Service_Object *_make_ACE_Naming_Context (void);
#endif /* ACE_NAMING_CONTEXT_H */
|