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 Member Functions

 ACE_Registry_Name_Space (void)
 Constructor.

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

 ~ACE_Registry_Name_Space (void)
 Destructor.

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

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 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)
int resolve (const ACE_NS_WString &name_in, ACE_NS_WString &value_out, char *&type_out)
int list_names (ACE_WSTRING_SET &set_out, const ACE_NS_WString &pattern_in)
int list_values (ACE_WSTRING_SET &set_out, const ACE_NS_WString &pattern_in)
int list_types (ACE_WSTRING_SET &set_out, const ACE_NS_WString &pattern_in)
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.


Private Attributes

ACE_Registry::Naming_Context context_
 current context


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 46 of file Registry_Name_Space.h.


Constructor & Destructor Documentation

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Registry_Name_Space::ACE_Registry_Name_Space void   ) 
 

Constructor.

Definition at line 12 of file Registry_Name_Space.cpp.

00013 {
00014 }

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 16 of file Registry_Name_Space.cpp.

References ACE_ERROR, ACE_LIB_TEXT, LM_ERROR, and open().

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

ACE_Registry_Name_Space::~ACE_Registry_Name_Space void   ) 
 

Destructor.

Definition at line 24 of file Registry_Name_Space.cpp.

00025 {
00026 }


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 62 of file Registry_Name_Space.cpp.

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

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

void ACE_Registry_Name_Space::dump void   )  const [virtual]
 

Dump the state of the object.

Implements ACE_Name_Space.

Definition at line 285 of file Registry_Name_Space.cpp.

00286 {
00287 #if defined (ACE_HAS_DUMP)
00288 #endif /* ACE_HAS_DUMP */
00289 }

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 226 of file Registry_Name_Space.cpp.

References ACE_BINDING_SET, ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_TString, ACE_Unbounded_Set< T >::begin(), ACE_Registry::Binding_List, ACE_String_Base< CHAR >::c_str(), ACE_Unbounded_Set< T >::end(), ACE_Unbounded_Set< T >::insert(), ACE_Registry::Naming_Context::list(), LM_ERROR, ACE_Registry::Binding::name(), resolve(), and ACE_Registry::Binding::type().

Referenced by list_names(), list_type_entries(), list_value_entries(), and list_values().

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

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 171 of file Registry_Name_Space.cpp.

References ACE_BINDING_ITERATOR, ACE_BINDING_SET, ACE_WSTRING_SET, ACE_Unbounded_Set_Iterator< T >::advance(), ACE_Unbounded_Set< T >::insert(), list_name_entries(), ACE_Name_Binding::name_, and ACE_Unbounded_Set_Iterator< T >::next().

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

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 277 of file Registry_Name_Space.cpp.

References ACE_BINDING_SET, and list_name_entries().

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

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 215 of file Registry_Name_Space.cpp.

References ACE_WSTRING_SET.

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

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 269 of file Registry_Name_Space.cpp.

References ACE_BINDING_SET, and list_name_entries().

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

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 193 of file Registry_Name_Space.cpp.

References ACE_BINDING_ITERATOR, ACE_BINDING_SET, ACE_WSTRING_SET, ACE_Unbounded_Set_Iterator< T >::advance(), ACE_Unbounded_Set< T >::insert(), list_name_entries(), ACE_Unbounded_Set_Iterator< T >::next(), and ACE_Name_Binding::value_.

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

int ACE_Registry_Name_Space::open ACE_Name_Options name_options  ) 
 

Contacts and opens the registry on the specified server.

Definition at line 30 of file Registry_Name_Space.cpp.

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

Referenced by ACE_Registry_Name_Space().

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

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 90 of file Registry_Name_Space.cpp.

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

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

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 and !

Implements ACE_Name_Space.

Definition at line 129 of file Registry_Name_Space.cpp.

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

Referenced by list_name_entries().

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

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 118 of file Registry_Name_Space.cpp.

References ACE_NS_WString::char_rep(), ACE_String_Base< CHAR >::fast_rep(), and ACE_Registry::Naming_Context::unbind().

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


Member Data Documentation

ACE_Registry::Naming_Context ACE_Registry_Name_Space::context_ [private]
 

current context

Definition at line 131 of file Registry_Name_Space.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:28:08 2006 for ACE by doxygen 1.3.6