Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Naming_Context.h
blobe109bfa58ff7acb2ddb502229d384be69350eb79
1 // -*- C++ -*-
3 //==========================================================================
4 /**
5 * @file Naming_Context.h
7 * @author Gerhard Lenzer
8 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
9 * @author Prashant Jain <pjain@uci.edu>
11 //==========================================================================
13 #ifndef ACE_NAMING_CONTEXT_H
14 #define ACE_NAMING_CONTEXT_H
15 #include /**/ "ace/pre.h"
17 #include /**/ "ace/ACE_export.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 # pragma once
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #include "ace/Service_Object.h"
24 #include "ace/Name_Space.h"
25 #include "ace/os_include/os_netdb.h"
27 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
29 // Forward decl
30 class ACE_Name_Options;
31 class ACE_Static_Svc_Descriptor;
33 /**
34 * @class ACE_Naming_Context
36 * @brief Maintaining accesses Name Server Databases. Allows to add
37 * NameBindings, change them, remove them and resolve
38 * NameBindings
40 * Manages a Naming Service . That represents a persistent
41 * string to string mapping for different scopes. The scope of a
42 * ACE_Naming_Context may be either local for the calling
43 * process (Note : A process is hereby not identified by it's
44 * pid, but by it's argv[0]. So different processes (in UNIX
45 * syntax) may access the same NameBindings), global for all
46 * processes running on one host or global for all processes on
47 * the net (that know the address of the net name server
48 * socket). Strings may be plain character strings or Wide
49 * character strings. A Name Binding consists of a name string
50 * (that's the key), a value string and an optional type string
51 * (no wide chars).
53 class ACE_Export ACE_Naming_Context : public ACE_Service_Object
55 public:
56 enum Context_Scope_Type
58 /// Name lookup is local to the process.
59 PROC_LOCAL,
60 /// Name lookup is local to the node (host).
61 NODE_LOCAL,
62 /// Name lookup is local to the (sub)network.
63 NET_LOCAL
66 /// "Do-nothing" constructor.
67 ACE_Naming_Context ();
69 /**
70 * Specifies the scope of this namespace, opens and memory-maps the
71 * associated file (if accessible) or contacts the dedicated name
72 * server process for NET_LOCAL namespace. Note that @a light
73 * specifies whether or not we want to use
74 * ACE_Lite_MMap_Memory_Pool. By default we use ACE_MMap_Memory_Pool.
76 ACE_Naming_Context (Context_Scope_Type scope_in, int light = 0);
78 /**
79 * Specifies the scope of this namespace, opens and memory-maps the
80 * associated file (if accessible) or contacts the dedicated name
81 * server process for NET_LOCAL namespace. Note that @a light
82 * specifies whether or not we want to use
83 * ACE_Lite_MMap_Memory_Pool. By default we use ACE_MMap_Memory_Pool.
85 int open (Context_Scope_Type scope_in = ACE_Naming_Context::PROC_LOCAL,
86 int light = 0);
88 /// Deletes the instance of Name Space. Must be called before
89 /// switching name spaces.
90 int close ();
92 /// Release all resources. Gets called by destructor and fini.
93 int close_down ();
95 /// destructor, do some cleanup :TBD: last dtor should "compress"
96 /// file
97 ~ACE_Naming_Context ();
99 // = Dynamic initialization hooks.
100 /// Initialize name options and naming context when dynamically
101 /// linked.
102 virtual int init (int argc, ACE_TCHAR *argv[]);
104 /// Close down the test when dynamically unlinked.
105 virtual int fini ();
107 /// Returns information about this context.
108 virtual int info (ACE_TCHAR **strp, size_t length) const;
110 /// Returns the ACE_Name_Options associated with the Naming_Context
111 ACE_Name_Options *name_options ();
113 /// Bind a new name to a naming context (Wide character strings).
114 int bind (const ACE_NS_WString &name_in,
115 const ACE_NS_WString &value_in,
116 const char *type_in = "");
118 /// Bind a new name to a naming context ( character strings).
119 int bind (const char *name_in,
120 const char *value_in,
121 const char *type_in = "");
124 * Overwrite the value or type of an existing name in a
125 * ACE_Naming_Context or bind a new name to the context, if it
126 * didn't exist yet. (Wide character strings interface).
128 int rebind (const ACE_NS_WString &name_in,
129 const ACE_NS_WString &value_in,
130 const char *type_in = "");
133 * Overwrite the value or type of an existing name in a
134 * ACE_Naming_Context or bind a new name to the context, if it
135 * didn't exist yet. ( character strings interface)
137 int rebind (const char *name_in,
138 const char *value_in,
139 const char *type_in = "");
141 /// Delete a name from a ACE_Naming_Context (Wide character strings
142 /// Interface).
143 int unbind (const ACE_NS_WString &name_in);
145 /// Delete a name from a ACE_Naming_Context (character strings
146 /// interface).
147 int unbind (const char *name_in);
149 /// Get value and type of a given name binding (Wide chars). The
150 /// caller is responsible for deleting both @a value_out> and @a type_out!
151 int resolve (const ACE_NS_WString &name_in,
152 ACE_NS_WString &value_out,
153 char *&type_out);
156 * Get value and type of a given name binding (Wide chars output).
157 * The caller is responsible for deleting both @a value_out and
158 * @a type_out!
160 int resolve (const char *name_in,
161 ACE_NS_WString &value_out,
162 char *&type_out);
164 /// Get value and type of a given name binding ( chars ). The caller
165 /// is responsible for deleting both @a value_out and @a type_out!
166 int resolve (const char *name_in,
167 char *&value_out,
168 char *&type_out);
170 /// Get a set of names matching a specified pattern (wchars). Matching
171 /// means the names must begin with the pattern string.
172 int list_names (ACE_PWSTRING_SET &set_out,
173 const ACE_NS_WString &pattern_in);
175 /// Get a set of names matching a specified pattern (chars). Matching
176 /// means the names must begin with the pattern string.
177 int list_names (ACE_PWSTRING_SET &set_out,
178 const char *pattern_in);
180 /// Get a set of values matching a specified pattern (wchars). Matching
181 /// means the values must begin with the pattern string.
182 int list_values (ACE_PWSTRING_SET &set_out,
183 const ACE_NS_WString &pattern_in);
185 /// Get a set of values matching a specified pattern (chars). Matching
186 /// means the values must begin with the pattern string.
187 int list_values (ACE_PWSTRING_SET &set_out,
188 const char *pattern_in);
190 /// Get a set of types matching a specified pattern (wchars). Matching
191 /// means the types must begin with the pattern string.
192 int list_types (ACE_PWSTRING_SET &set_out,
193 const ACE_NS_WString &pattern_in);
195 /// Get a set of types matching a specified pattern (chars). Matching
196 /// means the types must begin with the pattern string.
197 int list_types (ACE_PWSTRING_SET &set_out,
198 const char *pattern_in);
201 * Get a set of names matching a specified pattern (wchars). Matching
202 * means the names must begin with the pattern string. Returns the
203 * complete binding associated each pattern match.
205 virtual int list_name_entries (ACE_BINDING_SET &set_out,
206 const ACE_NS_WString &pattern_in);
209 * Get a set of names matching a specified pattern (wchars). Matching
210 * means the names must begin with the pattern string. Returns the
211 * complete binding associated each pattern match.
213 virtual int list_name_entries (ACE_BINDING_SET &set_out,
214 const char *pattern_in);
217 * Get a set of values matching a specified pattern (wchars). Matching
218 * means the values must begin with the pattern string. Returns the
219 * complete binding associated each pattern match.
221 virtual int list_value_entries (ACE_BINDING_SET &set_out,
222 const ACE_NS_WString &pattern_in);
225 * Get a set of values matching a specified pattern (wchars). Matching
226 * means the values must begin with the pattern string. Returns the
227 * complete binding associated each pattern match.
229 virtual int list_value_entries (ACE_BINDING_SET &set_out,
230 const char *pattern_in);
233 * Get a set of types matching a specified pattern (wchars). Matching
234 * means the types must begin with the pattern string. Returns the
235 * complete binding associated each pattern match.
237 virtual int list_type_entries (ACE_BINDING_SET &set_out,
238 const ACE_NS_WString &pattern_in);
241 * Get a set of types matching a specified pattern (wchars). Matching
242 * means the types must begin with the pattern string. Returns the
243 * complete binding associated each pattern match.
245 virtual int list_type_entries (ACE_BINDING_SET &set_out,
246 const char *pattern_in);
248 /// Dump the state of the object.
249 void dump ();
251 private:
252 /// Keep track of the options such as database name etc per Naming Context
253 ACE_Name_Options *name_options_;
255 /// Name space (can be either local or remote) dynamically bound.
256 ACE_Name_Space *name_space_;
258 /// Holds the local hostname.
259 ACE_TCHAR hostname_[MAXHOSTNAMELEN + 1];
261 /// Holds name of net name server.
262 const ACE_TCHAR *netnameserver_host_;
264 /// Holds port number of the net name server.
265 int netnameserver_port_;
267 /// 1 if we're on the same local machine as the name server, else 0.
268 int local ();
272 * @class ACE_Name_Options
274 * @brief Manages the options for the ACE Name_Server.
276 class ACE_Export ACE_Name_Options
278 public:
279 ACE_Name_Options ();
280 ~ACE_Name_Options ();
282 /// Parse arguments.
283 void parse_args (int argc,
284 ACE_TCHAR *argv[]);
286 /// Set the port number
287 void nameserver_port (int port);
289 /// Get the port number
290 int nameserver_port ();
292 /// Get the context
293 ACE_Naming_Context::Context_Scope_Type context ();
295 /// Set the context
296 void context (ACE_Naming_Context::Context_Scope_Type);
298 /// Set the host name
299 void nameserver_host (const ACE_TCHAR *host);
301 /// Get the host name
302 const ACE_TCHAR *nameserver_host ();
304 /// Set name space directory
305 void namespace_dir (const ACE_TCHAR *dir);
307 /// Get name space directory
308 const ACE_TCHAR *namespace_dir ();
310 /// Set process name
311 void process_name (const ACE_TCHAR *dir);
313 /// Get process name
314 const ACE_TCHAR *process_name ();
316 /// Set database name
317 void database (const ACE_TCHAR *);
319 /// Get database name
320 const ACE_TCHAR *database ();
322 /// Set base address of the underlying allocator
323 void base_address (char *address);
325 /// Get base address of the underlying allocator
326 char *base_address ();
328 /// Get use of registry in naming
329 bool use_registry () const;
331 /// Set use of registry in naming
332 void use_registry (bool x);
334 /// Return debug status
335 bool debug ();
337 /// Return verbose status
338 bool verbose ();
340 ACE_ALLOC_HOOK_DECLARE;
342 private:
343 /// Extra debugging info
344 bool debugging_;
346 /// Extra verbose messages
347 bool verbosity_;
349 /// Use Win32 Registry
350 bool use_registry_;
352 /// Port to connect to nameserver process.
353 int nameserver_port_;
355 /// Hostname of nameserver.
356 const ACE_TCHAR *nameserver_host_;
358 /// Directory to hold name_bindings.
359 ACE_TCHAR *namespace_dir_;
361 /// Name of this process.
362 const ACE_TCHAR *process_name_;
364 /// Name of the database that stores the name/value/type bindings.
365 const ACE_TCHAR *database_;
367 /// Base address of the underlying allocator
368 char *base_address_;
370 /// The context in which the naming database will be created.
371 ACE_Naming_Context::Context_Scope_Type context_;
374 ACE_FACTORY_DECLARE (ACE, ACE_Naming_Context)
375 ACE_STATIC_SVC_DECLARE_EXPORT (ACE, ACE_Naming_Context)
377 ACE_END_VERSIONED_NAMESPACE_DECL
379 #if defined (__ACE_INLINE__)
380 #include "ace/Naming_Context.inl"
381 #endif /* __ACE_INLINE__ */
383 #include /**/ "ace/post.h"
384 #endif /* ACE_NAMING_CONTEXT_H */