#include <Naming_Context.h>
Inheritance diagram for ACE_Naming_Context:
Public Types | |
enum | Context_Scope_Type { PROC_LOCAL, NODE_LOCAL, NET_LOCAL } |
Public Member Functions | |
ACE_Naming_Context (void) | |
"Do-nothing" constructor. | |
ACE_Naming_Context (Context_Scope_Type scope_in, int light=0) | |
int | open (Context_Scope_Type scope_in=ACE_Naming_Context::PROC_LOCAL, int light=0) |
int | close (void) |
int | close_down (void) |
Release all resources. Gets called by destructor and fini. | |
~ACE_Naming_Context (void) | |
virtual int | init (int argc, ACE_TCHAR *argv[]) |
virtual int | fini (void) |
Close down the test when dynamically unlinked. | |
virtual int | info (ACE_TCHAR **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_NS_WString &name_in, const ACE_NS_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_NS_WString &name_in, const ACE_NS_WString &value_in, const char *type_in="") |
int | rebind (const char *name_in, const char *value_in, const char *type_in="") |
int | unbind (const ACE_NS_WString &name_in) |
int | unbind (const char *name_in) |
int | resolve (const ACE_NS_WString &name_in, ACE_NS_WString &value_out, char *&type_out) |
int | resolve (const char *name_in, ACE_NS_WString &value_out, char *&type_out) |
int | resolve (const char *name_in, char *&value_out, char *&type_out) |
int | list_names (ACE_PWSTRING_SET &set_out, const ACE_NS_WString &pattern_in) |
int | list_names (ACE_PWSTRING_SET &set_out, const char *pattern_in) |
int | list_values (ACE_PWSTRING_SET &set_out, const ACE_NS_WString &pattern_in) |
int | list_values (ACE_PWSTRING_SET &set_out, const char *pattern_in) |
int | list_types (ACE_PWSTRING_SET &set_out, const ACE_NS_WString &pattern_in) |
int | list_types (ACE_PWSTRING_SET &set_out, const char *pattern_in) |
virtual int | list_name_entries (ACE_BINDING_SET &set_out, const ACE_NS_WString &pattern_in) |
virtual int | list_name_entries (ACE_BINDING_SET &set_out, const char *pattern_in) |
virtual int | list_value_entries (ACE_BINDING_SET &set_out, const ACE_NS_WString &pattern_in) |
virtual int | list_value_entries (ACE_BINDING_SET &set_out, const char *pattern_in) |
virtual int | list_type_entries (ACE_BINDING_SET &set_out, const ACE_NS_WString &pattern_in) |
virtual int | list_type_entries (ACE_BINDING_SET &set_out, const char *pattern_in) |
void | dump (void) |
Dump the state of the object. | |
Private Member Functions | |
int | local (void) |
1 if we're on the same local machine as the name server, else 0. | |
Private Attributes | |
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. | |
ACE_TCHAR | hostname_ [MAXHOSTNAMELEN+1] |
Holds the local hostname. | |
const ACE_TCHAR * | netnameserver_host_ |
Holds name of net name server. | |
int | netnameserver_port_ |
Holds port number of the net name server. |
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).
Definition at line 55 of file Naming_Context.h.
|
Definition at line 58 of file Naming_Context.h.
00059 { 00060 /// Name lookup is local to the process. 00061 PROC_LOCAL, 00062 /// Name lookup is local to the node (host). 00063 NODE_LOCAL, 00064 /// Name lookup is local to the (sub)network. 00065 NET_LOCAL 00066 }; |
|
"Do-nothing" constructor.
Definition at line 135 of file Naming_Context.cpp. References ACE_NEW, and ACE_TRACE.
00136 : name_options_ (0), 00137 name_space_ (0) 00138 { 00139 ACE_TRACE ("ACE_Naming_Context::ACE_Naming_Context"); 00140 00141 ACE_NEW (this->name_options_, 00142 ACE_Name_Options); 00143 } |
|
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. Definition at line 145 of file Naming_Context.cpp. References ACE_ERROR, ACE_NEW, ACE_TEXT, ACE_TRACE, LM_ERROR, and open().
00147 : name_options_ (0), 00148 name_space_ (0), 00149 netnameserver_host_ (0) 00150 { 00151 ACE_TRACE ("ACE_Naming_Context::ACE_Naming_Context"); 00152 00153 ACE_NEW (this->name_options_, 00154 ACE_Name_Options); 00155 00156 // Initialize. 00157 if (this->open (scope_in, lite) == -1) 00158 ACE_ERROR ((LM_ERROR, 00159 ACE_TEXT ("%p\n"), 00160 ACE_TEXT ("ACE_Naming_Context::ACE_Naming_Context"))); 00161 } |
|
destructor, do some cleanup :TBD: last dtor should "compress" file Definition at line 375 of file Naming_Context.cpp. References ACE_TRACE, and close_down().
00376 { 00377 ACE_TRACE ("ACE_Naming_Context::~ACE_Naming_Context"); 00378 00379 this->close_down (); 00380 } |
|
Bind a new name to a naming context ( character strings).
Definition at line 179 of file Naming_Context.cpp. References ACE_TRACE, and bind().
00182 { 00183 ACE_TRACE ("ACE_Naming_Context::bind"); 00184 return this->bind (ACE_NS_WString (name_in), 00185 ACE_NS_WString (value_in), 00186 type_in); 00187 } |
|
Bind a new name to a naming context (Wide character strings).
Definition at line 170 of file Naming_Context.cpp. References ACE_TRACE, ACE_Name_Space::bind(), and name_space_. Referenced by bind().
00173 { 00174 ACE_TRACE ("ACE_Naming_Context::bind"); 00175 return this->name_space_->bind (name_in, value_in, type_in); 00176 } |
|
Deletes the instance of Name Space. Must be called before switching name spaces. Definition at line 125 of file Naming_Context.cpp. References ACE_TRACE, and name_space_. Referenced by close_down().
00126 { 00127 ACE_TRACE ("ACE_Naming_Context::close"); 00128 00129 delete this->name_space_; 00130 this->name_space_ = 0; 00131 00132 return 0; 00133 } |
|
Release all resources. Gets called by destructor and fini.
Definition at line 114 of file Naming_Context.cpp. References ACE_TRACE, and close(). Referenced by fini(), and ~ACE_Naming_Context().
00115 { 00116 ACE_TRACE ("ACE_Naming_Context::close_down"); 00117 00118 delete this->name_options_; 00119 this->name_options_ = 0; 00120 00121 return this->close (); 00122 } |
|
Dump the state of the object.
Definition at line 383 of file Naming_Context.cpp. References ACE_TRACE, ACE_Name_Space::dump(), and name_space_.
00384 { 00385 #if defined (ACE_HAS_DUMP) 00386 ACE_TRACE ("ACE_Naming_Context::dump"); 00387 this->name_space_->dump(); 00388 #endif /* ACE_HAS_DUMP */ 00389 } |
|
Close down the test when dynamically unlinked.
Reimplemented from ACE_Shared_Object. Definition at line 402 of file Naming_Context.cpp. References ACE_DEBUG, ACE_TEXT, close_down(), ACE::debug(), and LM_DEBUG.
00403 { 00404 if (ACE::debug ()) 00405 ACE_DEBUG ((LM_DEBUG, 00406 ACE_TEXT ("ACE_Naming_Context::fini\n"))); 00407 this->close_down (); 00408 return 0; 00409 } |
|
Returns information about this context.
Reimplemented from ACE_Shared_Object. Definition at line 30 of file Naming_Context.cpp. References ACE_TCHAR, ACE_TEXT, ACE_TRACE, ACE_OS::sprintf(), ACE_OS::strdup(), ACE_OS::strlen(), and ACE_OS::strsncpy().
00032 { 00033 ACE_TRACE ("ACE_Naming_Context::info"); 00034 00035 ACE_TCHAR buf[BUFSIZ]; 00036 00037 ACE_OS::sprintf (buf, 00038 ACE_TEXT ("%s\t#%s\n"), 00039 ACE_TEXT ("ACE_Naming_Context"), 00040 ACE_TEXT ("Proxy for making calls to a Name Server")); 00041 00042 if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0) 00043 return -1; 00044 else 00045 ACE_OS::strsncpy (*strp, buf, length); 00046 return static_cast<int> (ACE_OS::strlen (buf)); 00047 } |
|
Initialize name options and naming context when dynamically linked. Reimplemented from ACE_Shared_Object. Definition at line 392 of file Naming_Context.cpp. References ACE_DEBUG, ACE_TCHAR, ACE_TEXT, ACE::debug(), LM_DEBUG, open(), and ACE_Name_Options::parse_args().
00393 { 00394 if (ACE::debug ()) 00395 ACE_DEBUG ((LM_DEBUG, 00396 ACE_TEXT ("ACE_Naming_Context::init\n"))); 00397 this->name_options_->parse_args (argc, argv); 00398 return this->open (this->name_options_->context ()); 00399 } |
|
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. Definition at line 331 of file Naming_Context.cpp. References ACE_BINDING_SET, ACE_TRACE, and list_name_entries().
00333 { 00334 ACE_TRACE ("ACE_Naming_Context::list_name_entries"); 00335 return this->list_name_entries (set_out, 00336 ACE_NS_WString (pattern_in)); 00337 } |
|
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. Definition at line 322 of file Naming_Context.cpp. References ACE_BINDING_SET, ACE_TRACE, ACE_Name_Space::list_name_entries(), and name_space_. Referenced by list_name_entries().
00324 { 00325 ACE_TRACE ("ACE_Naming_Context::list_name_entries"); 00326 return this->name_space_->list_name_entries (set_out, 00327 pattern_in); 00328 } |
|
Get a set of names matching a specified pattern (chars). Matching means the names must begin with the pattern string. Definition at line 277 of file Naming_Context.cpp. References ACE_PWSTRING_SET, ACE_TRACE, and list_names().
00279 { 00280 ACE_TRACE ("ACE_Naming_Context::list_names"); 00281 return this->list_names (set_out, 00282 ACE_NS_WString (pattern_in)); 00283 } |
|
Get a set of names matching a specified pattern (wchars). Matching means the names must begin with the pattern string. Definition at line 268 of file Naming_Context.cpp. References ACE_PWSTRING_SET, ACE_TRACE, ACE_Name_Space::list_names(), and name_space_. Referenced by list_names().
00270 { 00271 ACE_TRACE ("ACE_Naming_Context::list_names"); 00272 return this->name_space_->list_names (set_out, 00273 pattern_in); 00274 } |
|
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. Definition at line 367 of file Naming_Context.cpp. References ACE_BINDING_SET, ACE_TRACE, and list_type_entries().
00369 { 00370 ACE_TRACE ("ACE_Naming_Context::list_type_entries"); 00371 return this->list_type_entries (set_out, 00372 ACE_NS_WString (pattern_in)); 00373 } |
|
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. Definition at line 358 of file Naming_Context.cpp. References ACE_BINDING_SET, ACE_TRACE, ACE_Name_Space::list_type_entries(), and name_space_. Referenced by list_type_entries().
00360 { 00361 ACE_TRACE ("ACE_Naming_Context::list_type_entries"); 00362 return this->name_space_->list_type_entries (set_out, 00363 pattern_in); 00364 } |
|
Get a set of types matching a specified pattern (chars). Matching means the types must begin with the pattern string. Definition at line 313 of file Naming_Context.cpp. References ACE_PWSTRING_SET, ACE_TRACE, and list_types().
00315 { 00316 ACE_TRACE ("ACE_Naming_Context::list_types"); 00317 return this->list_types (set_out, 00318 ACE_NS_WString (pattern_in)); 00319 } |
|
Get a set of types matching a specified pattern (wchars). Matching means the types must begin with the pattern string. Definition at line 304 of file Naming_Context.cpp. References ACE_PWSTRING_SET, ACE_TRACE, ACE_Name_Space::list_types(), and name_space_. Referenced by list_types().
00306 { 00307 ACE_TRACE ("ACE_Naming_Context::list_types"); 00308 return this->name_space_->list_types (set_out, 00309 pattern_in); 00310 } |
|
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. Definition at line 349 of file Naming_Context.cpp. References ACE_BINDING_SET, ACE_TRACE, and list_value_entries().
00351 { 00352 ACE_TRACE ("ACE_Naming_Context::list_value_entries"); 00353 return this->list_value_entries (set_out, 00354 ACE_NS_WString (pattern_in)); 00355 } |
|
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. Definition at line 340 of file Naming_Context.cpp. References ACE_BINDING_SET, ACE_TRACE, ACE_Name_Space::list_value_entries(), and name_space_. Referenced by list_value_entries().
00342 { 00343 ACE_TRACE ("ACE_Naming_Context::list_value_entries"); 00344 return this->name_space_->list_value_entries (set_out, 00345 pattern_in); 00346 } |
|
Get a set of values matching a specified pattern (chars). Matching means the values must begin with the pattern string. Definition at line 295 of file Naming_Context.cpp. References ACE_PWSTRING_SET, ACE_TRACE, and list_values().
00297 { 00298 ACE_TRACE ("ACE_Naming_Context::list_values"); 00299 return this->list_values (set_out, 00300 ACE_NS_WString (pattern_in)); 00301 } |
|
Get a set of values matching a specified pattern (wchars). Matching means the values must begin with the pattern string. Definition at line 286 of file Naming_Context.cpp. References ACE_PWSTRING_SET, ACE_TRACE, ACE_Name_Space::list_values(), and name_space_. Referenced by list_values().
00288 { 00289 ACE_TRACE ("ACE_Naming_Context::list_values"); 00290 return this->name_space_->list_values (set_out, 00291 pattern_in); 00292 } |
|
1 if we're on the same local machine as the name server, else 0.
Definition at line 50 of file Naming_Context.cpp. References ACE_TEXT, ACE_TRACE, and ACE_OS::strcmp(). Referenced by open().
00051 { 00052 ACE_TRACE ("ACE_Naming_Context::local"); 00053 return ACE_OS::strcmp (this->netnameserver_host_, 00054 ACE_TEXT ("localhost")) == 0 00055 || ACE_OS::strcmp (this->netnameserver_host_, 00056 this->hostname_) == 0; 00057 } |
|
Returns the ACE_Name_Options associated with the Naming_Context.
Definition at line 164 of file Naming_Context.cpp.
00165 { 00166 return this->name_options_; 00167 } |
|
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. Definition at line 60 of file Naming_Context.cpp. References ACE_ERROR_RETURN, ACE_LOG_MSG, ACE_NEW_RETURN, ACE_TCHAR, ACE_TEXT, ACE_TRACE, ACE_OS::hostname(), LITE_LOCAL_NAME_SPACE, LM_ERROR, local(), LOCAL_NAME_SPACE, name_space_, ACE_Name_Options::nameserver_host(), ACE_Name_Options::nameserver_port(), NET_LOCAL, netnameserver_host_, netnameserver_port_, and ACE_Name_Options::use_registry(). Referenced by ACE_Naming_Context(), and init().
00061 { 00062 ACE_TRACE ("ACE_Naming_Context::open"); 00063 ACE_OS::hostname (this->hostname_, 00064 (sizeof this->hostname_ / sizeof (ACE_TCHAR))); 00065 00066 this->netnameserver_host_ = 00067 this->name_options_->nameserver_host (); 00068 this->netnameserver_port_ = 00069 this->name_options_->nameserver_port (); 00070 00071 // Perform factory operation to select appropriate type of 00072 // Name_Space subclass. 00073 00074 #if (defined (ACE_WIN32) && defined (ACE_USES_WCHAR)) 00075 // This only works on Win32 platforms when ACE_USES_WCHAR is turned on 00076 00077 if (this->name_options_->use_registry ()) 00078 // Use ACE_Registry 00079 ACE_NEW_RETURN (this->name_space_, 00080 ACE_Registry_Name_Space (this->name_options_), 00081 -1); 00082 #endif /* ACE_WIN32 && ACE_USES_WCHAR */ 00083 if (!this->name_options_->use_registry ()) 00084 if (scope_in == ACE_Naming_Context::NET_LOCAL && this->local () == 0) 00085 { 00086 // Use NET_LOCAL name space, set up connection with remote server. 00087 ACE_NEW_RETURN (this->name_space_, 00088 ACE_Remote_Name_Space (this->netnameserver_host_, 00089 (u_short) this->netnameserver_port_), 00090 -1); 00091 } 00092 else // Use NODE_LOCAL or PROC_LOCAL name space. 00093 { 00094 if (lite) 00095 ACE_NEW_RETURN (this->name_space_, 00096 LITE_LOCAL_NAME_SPACE (scope_in, 00097 this->name_options_), 00098 -1); 00099 else 00100 ACE_NEW_RETURN (this->name_space_, 00101 LOCAL_NAME_SPACE (scope_in, 00102 this->name_options_), 00103 -1); 00104 } 00105 00106 if (ACE_LOG_MSG->op_status () != 0 || this->name_space_ == 0) 00107 ACE_ERROR_RETURN ((LM_ERROR, 00108 ACE_TEXT ("NAME_SPACE::NAME_SPACE\n")), 00109 -1); 00110 return 0; 00111 } |
|
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) Definition at line 201 of file Naming_Context.cpp. References ACE_TRACE, and rebind().
00204 { 00205 ACE_TRACE ("ACE_Naming_Context::rebind"); 00206 return rebind (ACE_NS_WString (name_in), 00207 ACE_NS_WString (value_in), 00208 type_in); 00209 } |
|
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). Definition at line 190 of file Naming_Context.cpp. References ACE_TRACE, name_space_, and ACE_Name_Space::rebind(). Referenced by rebind().
00193 { 00194 ACE_TRACE ("ACE_Naming_Context::rebind"); 00195 return this->name_space_->rebind (name_in, 00196 value_in, 00197 type_in); 00198 } |
|
Get value and type of a given name binding ( chars ). The caller is responsible for deleting both value_out and type_out! Definition at line 234 of file Naming_Context.cpp. References ACE_TRACE, ACE_NS_WString::char_rep(), and resolve().
00237 { 00238 ACE_TRACE ("ACE_Naming_Context::resolve"); 00239 ACE_NS_WString val_str; 00240 00241 if (this->resolve (ACE_NS_WString (name_in), 00242 val_str, 00243 type_out) == -1) 00244 return -1; 00245 00246 // Note that <char_rep> *allocates* the memory! Thus, caller is 00247 // responsible for deleting it! 00248 value_out = val_str.char_rep (); 00249 00250 return value_out == 0 ? -1 : 0; 00251 } |
|
Get value and type of a given name binding (Wide chars output). The caller is responsible for deleting both value_out and type_out! Definition at line 223 of file Naming_Context.cpp. References ACE_TRACE, and resolve().
00226 { 00227 ACE_TRACE ("ACE_Naming_Context::resolve"); 00228 return this->resolve (ACE_NS_WString (name_in), 00229 value_out, 00230 type_out); 00231 } |
|
Get value and type of a given name binding (Wide chars). The caller is responsible for deleting both value_out> and type_out! Definition at line 212 of file Naming_Context.cpp. References ACE_TRACE, name_space_, and ACE_Name_Space::resolve(). Referenced by resolve().
00215 { 00216 ACE_TRACE ("ACE_Naming_Context::resolve"); 00217 return this->name_space_->resolve (name_in, 00218 value_out, 00219 type_out); 00220 } |
|
Delete a name from a ACE_Naming_Context (character strings interface). Definition at line 261 of file Naming_Context.cpp. References ACE_TRACE, and unbind().
00262 { 00263 ACE_TRACE ("ACE_Naming_Context::unbind"); 00264 return this->unbind (ACE_NS_WString (name_in)); 00265 } |
|
Delete a name from a ACE_Naming_Context (Wide charcter strings Interface). Definition at line 254 of file Naming_Context.cpp. References ACE_TRACE, name_space_, and ACE_Name_Space::unbind(). Referenced by unbind().
00255 { 00256 ACE_TRACE ("ACE_Naming_Context::unbind"); 00257 return this->name_space_->unbind (name_in); 00258 } |
|
Holds the local hostname.
Definition at line 262 of file Naming_Context.h. |
|
Keep track of the options such as database name etc per Naming Context.
Definition at line 256 of file Naming_Context.h. |
|
Name space (can be either local or remote) dynamically bound.
Definition at line 259 of file Naming_Context.h. Referenced by bind(), close(), dump(), list_name_entries(), list_names(), list_type_entries(), list_types(), list_value_entries(), list_values(), open(), rebind(), resolve(), and unbind(). |
|
Holds name of net name server.
Definition at line 265 of file Naming_Context.h. Referenced by open(). |
|
Holds port number of the net name server.
Definition at line 268 of file Naming_Context.h. Referenced by open(). |