Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_Registry_Name_Space Class Reference

Interface to a Name Server Database which is maintained by the Win32 Registry. Allows to add, change, remove and resolve NameBindings. More...

#include <Registry_Name_Space.h>

Inheritance diagram for ACE_Registry_Name_Space:

Inheritance graph
[legend]
Collaboration diagram for ACE_Registry_Name_Space:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_Registry_Name_Space (void)
 Constructor. More...

 ACE_Registry_Name_Space (ACE_Name_Options *name_options)
 Contacts and opens the registry on the specified server. More...

 ~ACE_Registry_Name_Space (void)
 Destructor. More...

int open (ACE_Name_Options *name_options)
 Contacts and opens the registry on the specified server. More...

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). More...

int rebind (const ACE_NS_WString &name_in, const ACE_NS_WString &value_in, const char *type_in="")
int unbind (const ACE_NS_WString &name_in)
 Delete a name from a ACE_Name_Space (Wide charcter strings Interface). More...

int resolve (const ACE_NS_WString &name_in, ACE_NS_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>! More...

int list_names (ACE_WSTRING_SET &set_out, const ACE_NS_WString &pattern_in)
 Get a set of names matching a specified pattern (wchars). Matching means the names must begin with the pattern string. More...

int list_values (ACE_WSTRING_SET &set_out, const ACE_NS_WString &pattern_in)
 Get a set of values matching a specified pattern (wchars). Matching means the values must begin with the pattern string. More...

int list_types (ACE_WSTRING_SET &set_out, const ACE_NS_WString &pattern_in)
 Get a set of types matching a specified pattern (wchars). Matching means the types must begin with the pattern string. More...

int list_name_entries (ACE_BINDING_SET &set, const ACE_NS_WString &pattern)
int list_value_entries (ACE_BINDING_SET &set, const ACE_NS_WString &pattern)
int list_type_entries (ACE_BINDING_SET &set, const ACE_NS_WString &pattern)
void dump (void) const
 Dump the state of the object. More...


Private Attributes

ACE_Registry::Naming_Context context_
 current context. More...


Detailed Description

Interface to a Name Server Database which is maintained by the Win32 Registry. Allows to add, change, remove and resolve NameBindings.

Manages a Naming Service for a registry name space which includes bindings for all contexts. All strings are stored in wide character format. A Name Binding consists of a name (that's the key), a value string. There is no type string support in this Name Space.

Definition at line 44 of file Registry_Name_Space.h.


Constructor & Destructor Documentation

ACE_Registry_Name_Space::ACE_Registry_Name_Space void   
 

Constructor.

Definition at line 11 of file Registry_Name_Space.cpp.

00012 {
00013 }

ACE_Registry_Name_Space::ACE_Registry_Name_Space ACE_Name_Options   name_options
 

Contacts and opens the registry on the specified server.

Definition at line 15 of file Registry_Name_Space.cpp.

References ACE_ERROR, ACE_LIB_TEXT, LM_ERROR, and open.

00016 {
00017   if (this->open (name_options) != 0)
00018     ACE_ERROR ((LM_ERROR,  ACE_LIB_TEXT ("%p\n"),
00019                 ACE_LIB_TEXT ("ACE_Registry_Name_Space::open")));
00020 }

ACE_Registry_Name_Space::~ACE_Registry_Name_Space void   
 

Destructor.

Definition at line 23 of file Registry_Name_Space.cpp.

00024 {
00025 }


Member Function Documentation

int ACE_Registry_Name_Space::bind const ACE_NS_WString   name_in,
const ACE_NS_WString   value_in,
const char *    type_in = ""
[virtual]
 

Bind a new name to a naming context (Wide character strings).

Implements ACE_Name_Space.

Definition at line 61 of file Registry_Name_Space.cpp.

References ACE_WSTRING_TYPE, ACE_Registry::Naming_Context::bind, ACE_NS_WString::char_rep, context_, ACE_String_Base< ACE_WSTRING_TYPE >::fast_rep, and ACE_String_Base< ACE_WSTRING_TYPE >::length.

00064 {
00065   ACE_UNUSED_ARG(type);
00066 
00067   // Pointer to data
00068   const ACE_WSTRING_TYPE *data = value.fast_rep ();
00069 
00070   // Size
00071   u_long size = value.length () * sizeof (ACE_WSTRING_TYPE);
00072 
00073   // Represent value as an ACE_Registry::Object
00074   ACE_Registry::Object object ((void *) data,
00075                                size,
00076                                REG_SZ);
00077   // Add new <key>/<value> pair
00078 #if defined ACE_USES_WCHAR
00079   return this->context_.bind (name.fast_rep(),
00080                               object);
00081 #else
00082   return this->context_.bind (name.char_rep(),
00083                               object);
00084 #endif /* ACE_HAS_WCHAR */
00085 }

void ACE_Registry_Name_Space::dump void    const [virtual]
 

Dump the state of the object.

Implements ACE_Name_Space.

Definition at line 284 of file Registry_Name_Space.cpp.

00285 {
00286 }

int ACE_Registry_Name_Space::list_name_entries ACE_BINDING_SET   set,
const ACE_NS_WString   pattern
[virtual]
 

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.

Implements ACE_Name_Space.

Definition at line 225 of file Registry_Name_Space.cpp.

References ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_Registry::Binding_List, ACE_String_Base< char >::c_str, context_, ACE_Unbounded_Set::insert, ACE_Registry::Naming_Context::list, LM_ERROR, ACE_Registry::Binding::name, ACE_Registry::OBJECT, resolve, and ACE_Registry::Binding::type.

Referenced by list_names, list_type_entries, list_value_entries, and list_values.

00227 {
00228   ACE_UNUSED_ARG(pattern);
00229 
00230   ACE_Registry::Binding_List list;
00231   int result = this->context_.list (list);
00232   if (result != 0)
00233     return result;
00234 
00235   // Iterator through all entries
00236   for (ACE_Registry::Binding_List::iterator i = list.begin ();
00237        i != list.end ();
00238        i++)
00239     {
00240       // Yeeesss! STL rules!
00241       ACE_Registry::Binding &binding = *i;
00242 
00243       if (binding.type () == ACE_Registry::OBJECT)
00244         {
00245           // Key
00246           ACE_TString string = binding.name ();
00247           ACE_NS_WString key (string.c_str ());
00248 
00249           // Value
00250           ACE_NS_WString value;
00251           char *type = 0;
00252           result = this->resolve (key,
00253                                   value,
00254                                   type);
00255           if (result != 0)
00256             ACE_ERROR_RETURN ((LM_ERROR,  ACE_LIB_TEXT ("%p\n"),  ACE_LIB_TEXT ("ACE_Registry::Naming_Context::resolve")), result);
00257 
00258           // Complete binding
00259           ACE_Name_Binding binding (key, value, type);
00260           set.insert (binding);
00261         }
00262     }
00263   return 0;
00264 }

int ACE_Registry_Name_Space::list_names ACE_WSTRING_SET   set_out,
const ACE_NS_WString   pattern_in
[virtual]
 

Get a set of names matching a specified pattern (wchars). Matching means the names must begin with the pattern string.

Implements ACE_Name_Space.

Definition at line 170 of file Registry_Name_Space.cpp.

References ACE_Unbounded_Set_Iterator::advance, ACE_Unbounded_Set::insert, list_name_entries, ACE_Name_Binding::name_, and ACE_Unbounded_Set_Iterator::next.

00172 {
00173   ACE_BINDING_SET binding_set;
00174   int result = this->list_name_entries (binding_set,
00175                                         pattern);
00176   if (result != 0)
00177     return result;
00178 
00179   ACE_BINDING_ITERATOR iterator (binding_set);
00180 
00181   for (ACE_Name_Binding *entry = 0;
00182        iterator.next (entry) !=0;
00183        iterator.advance())
00184     {
00185       set.insert (entry->name_);
00186     }
00187   return 0;
00188 }

int ACE_Registry_Name_Space::list_type_entries ACE_BINDING_SET   set,
const ACE_NS_WString   pattern
[virtual]
 

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.

Implements ACE_Name_Space.

Definition at line 276 of file Registry_Name_Space.cpp.

References list_name_entries.

00278 {
00279   return this->list_name_entries (set, pattern);
00280 }

int ACE_Registry_Name_Space::list_types ACE_WSTRING_SET   set_out,
const ACE_NS_WString   pattern_in
[virtual]
 

Get a set of types matching a specified pattern (wchars). Matching means the types must begin with the pattern string.

Implements ACE_Name_Space.

Definition at line 214 of file Registry_Name_Space.cpp.

00216 {
00217   ACE_UNUSED_ARG(set);
00218   ACE_UNUSED_ARG(pattern);
00219 
00220   return 0;
00221 }

int ACE_Registry_Name_Space::list_value_entries ACE_BINDING_SET   set,
const ACE_NS_WString   pattern
[virtual]
 

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.

Implements ACE_Name_Space.

Definition at line 268 of file Registry_Name_Space.cpp.

References list_name_entries.

00270 {
00271   return this->list_name_entries (set, pattern);
00272 }

int ACE_Registry_Name_Space::list_values ACE_WSTRING_SET   set_out,
const ACE_NS_WString   pattern_in
[virtual]
 

Get a set of values matching a specified pattern (wchars). Matching means the values must begin with the pattern string.

Implements ACE_Name_Space.

Definition at line 192 of file Registry_Name_Space.cpp.

References ACE_Unbounded_Set_Iterator::advance, ACE_Unbounded_Set::insert, list_name_entries, ACE_Unbounded_Set_Iterator::next, and ACE_Name_Binding::value_.

00194 {
00195   ACE_BINDING_SET binding_set;
00196   int result = this->list_name_entries (binding_set,
00197                                         pattern);
00198   if (result != 0)
00199     return result;
00200 
00201   ACE_BINDING_ITERATOR iterator (binding_set);
00202 
00203   for (ACE_Name_Binding *entry = 0;
00204        iterator.next (entry) !=0;
00205        iterator.advance())
00206     {
00207       set.insert (entry->value_);
00208     }
00209   return 0;
00210 }

int ACE_Registry_Name_Space::open ACE_Name_Options   name_options
 

Contacts and opens the registry on the specified server.

Definition at line 29 of file Registry_Name_Space.cpp.

References ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_TCHAR, ACE_Registry::Naming_Context::bind_context, ACE_Predefined_Naming_Contexts::connect, ACE_Name_Options::database, LM_ERROR, ACE_Name_Options::nameserver_host, ACE_Name_Options::namespace_dir, and ACE_Registry::STRING_SEPARATOR.

Referenced by ACE_Registry_Name_Space.

00030 {
00031   const ACE_TCHAR *host = name_options->nameserver_host ();
00032   ACE_Registry::Naming_Context predefined;
00033 
00034   int result = ACE_Predefined_Naming_Contexts::connect (predefined,
00035                                                         HKEY_LOCAL_MACHINE,
00036                                                         host);
00037   if (result != 0)
00038     ACE_ERROR_RETURN ((LM_ERROR,  ACE_LIB_TEXT ("%p\n"),
00039                        ACE_LIB_TEXT ("ACE_Predefined_Naming_Context::connect")),
00040                       result);
00041   else
00042     {
00043       // Directory
00044       ACE_TString name = name_options->namespace_dir ();
00045       // Separator
00046       name += ACE_Registry::STRING_SEPARATOR;
00047       // Filename
00048       name += name_options->database ();
00049 
00050       // Create new context or bind to existing one
00051       result = predefined.bind_context (name,
00052                                         this->context_);
00053       if (result != 0)
00054         ACE_ERROR_RETURN ((LM_ERROR,  ACE_LIB_TEXT ("%p\n"),  ACE_LIB_TEXT ("ACE_Registry::Naming_Context::bind_context")), result);
00055     }
00056   return 0;
00057 }

int ACE_Registry_Name_Space::rebind const ACE_NS_WString   name_in,
const ACE_NS_WString   value_in,
const char *    type_in = ""
[virtual]
 

Overwrite the value or type of an existing name in a ACE_Name_Space or bind a new name to the context, if it didn't exist yet. (Wide charcter strings interface).

Implements ACE_Name_Space.

Definition at line 89 of file Registry_Name_Space.cpp.

References ACE_WSTRING_TYPE, ACE_NS_WString::char_rep, context_, ACE_String_Base< ACE_WSTRING_TYPE >::fast_rep, ACE_String_Base< ACE_WSTRING_TYPE >::length, and ACE_Registry::Naming_Context::rebind.

00092 {
00093   ACE_UNUSED_ARG(type);
00094 
00095   // Pointer to data
00096   const ACE_WSTRING_TYPE *data = value.fast_rep ();
00097 
00098   // Size
00099   u_long size = value.length () * sizeof (ACE_WSTRING_TYPE);
00100 
00101   // Represent value as an ACE_Registry::Object
00102   ACE_Registry::Object object ((void *) data,
00103                                size,
00104                                REG_SZ);
00105   // Add new <key>/<value> pair
00106 #if defined (ACE_USES_WCHAR)
00107   return this->context_.rebind (name.fast_rep (),
00108                                 object);
00109 #else
00110   return this->context_.rebind (name.char_rep (),
00111                                 object);
00112 #endif /* ACE_USES_WCHAR */
00113 }

int ACE_Registry_Name_Space::resolve const ACE_NS_WString   name_in,
ACE_NS_WString   value_out,
char *&    type_out
[virtual]
 

Get value and type of a given name binding (Wide chars). The caller is responsible for deleting both <value_out> and <type_out>!

Implements ACE_Name_Space.

Definition at line 128 of file Registry_Name_Space.cpp.

References ACE_NS_WString::char_rep, context_, ACE_String_Base< ACE_WSTRING_TYPE >::fast_rep, ACE_String_Base< ACE_WSTRING_TYPE >::resize, ACE_Registry::Naming_Context::resolve, and ACE_Registry::Object::size.

Referenced by list_name_entries.

00131 {
00132   ACE_UNUSED_ARG(type);
00133 
00134   // This object will be used to query the size of the data.
00135   // Note: The query_object.data will be null for this invocation.
00136   ACE_Registry::Object query_object;
00137   int result =
00138 #if defined (ACE_USES_WCHAR)
00139     this->context_.resolve (name.fast_rep (), query_object);
00140 #else
00141     this->context_.resolve (name.char_rep (), query_object);
00142 #endif /* ACE_USES_WCHAR */
00143   if (result != 0)
00144     return result;
00145 
00146   // Resize the value passed by the user
00147   // Note: -1 is used because the size includes the null terminator
00148   value.resize ((query_object.size () - 1) / sizeof (ACE_WSTRING_TYPE));
00149 
00150   // Represent new space as an ACE_Registry::Object
00151   ACE_Registry::Object object ((void *) value.fast_rep (),
00152                                query_object.size (),
00153                                REG_SZ);
00154 
00155 #if defined (ACE_USES_WCHAR)
00156   result = this->context_.resolve (name.fast_rep (), object);
00157 #else
00158   result = this->context_.resolve (name.char_rep (), object);
00159 #endif /* ACE_USES_WCHAR */
00160   if (object.size () != query_object.size ())
00161     return -1;
00162   if (result != 0)
00163     return result;
00164 
00165   return 0;
00166 }

int ACE_Registry_Name_Space::unbind const ACE_NS_WString   name_in [virtual]
 

Delete a name from a ACE_Name_Space (Wide charcter strings Interface).

Implements ACE_Name_Space.

Definition at line 117 of file Registry_Name_Space.cpp.

References ACE_NS_WString::char_rep, context_, ACE_String_Base< ACE_WSTRING_TYPE >::fast_rep, and ACE_Registry::Naming_Context::unbind.

00118 {
00119 #if defined (ACE_USES_WCHAR)
00120   return this->context_.unbind (name.fast_rep ());
00121 #else
00122   return this->context_.unbind (name.char_rep ());
00123 #endif /* ACE_USES_WCHAR */
00124 }


Member Data Documentation

ACE_Registry::Naming_Context ACE_Registry_Name_Space::context_ [private]
 

current context.

Definition at line 129 of file Registry_Name_Space.h.

Referenced by bind, list_name_entries, rebind, resolve, and unbind.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:55:15 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002