#include <Registry.h>
Collaboration diagram for ACE_Registry::Naming_Context:

Public Types | |
| enum | { MAX_OBJECT_NAME_SIZE = BUFSIZ, MAX_CONTEXT_NAME_SIZE = MAXPATHLEN + 1 } |
Public Methods | |
| Naming_Context (void) | |
| Empty constructor: keys will be NULL. More... | |
| Naming_Context (const HKEY &key) | |
| Constructor: key_ will be set to <key>. More... | |
| ~Naming_Context (void) | |
| Destructor will call <Naming_Context::close>. More... | |
| int | bind_new (const Name &name, const Object &object) |
| int | bind_new (const ACE_TString &name, const Object &object) |
| int | bind (const Name &name, const Object &object) |
| int | bind (const ACE_TString &name, const Object &object) |
| int | rebind (const Name &name, const Object &object) |
| Update <object> with <name> in <this> context (Name version). More... | |
| int | rebind (const ACE_TString &name, const Object &object) |
| Update <object> with <name> in <this> context. More... | |
| int | resolve (const Name &name, Object &object) |
| Find <object> with <name> in <this> context (Name version). More... | |
| int | resolve (const ACE_TString &name, Object &object) |
| Find <object> with <name> in <this> context. More... | |
| int | unbind (const Name &name) |
| Delete object with <name> in <this> context (Name version). More... | |
| int | unbind (const ACE_TString &name) |
| Delete object with <name> in <this> context. More... | |
| int | new_context (Naming_Context &naming_context) |
| Create new <naming_context>. More... | |
| int | bind_new_context (const Name &name, Naming_Context &naming_context, u_long persistence=REG_OPTION_NON_VOLATILE, u_long security_access=KEY_ALL_ACCESS, LPSECURITY_ATTRIBUTES security_attributes=0) |
| int | bind_new_context (const ACE_TString &name, Naming_Context &naming_context, u_long persistence=REG_OPTION_NON_VOLATILE, u_long security_access=KEY_ALL_ACCESS, LPSECURITY_ATTRIBUTES security_attributes=0) |
| Insert <naming_context> with <name> relative to <this> context This will fail if <name> already exists. More... | |
| int | bind_context (const Name &name, Naming_Context &naming_context, u_long persistence=REG_OPTION_NON_VOLATILE, u_long security_access=KEY_ALL_ACCESS, LPSECURITY_ATTRIBUTES security_attributes=0) |
| int | bind_context (const ACE_TString &name, Naming_Context &naming_context, u_long persistence=REG_OPTION_NON_VOLATILE, u_long security_access=KEY_ALL_ACCESS, LPSECURITY_ATTRIBUTES security_attributes=0) |
| Insert or update <naming_context> with <name> relative to <this> context This will not fail if <name> already exists. More... | |
| int | rebind_context (const Name &name, Naming_Context &naming_context) |
| Rename <naming_context> to <name> (Name version). More... | |
| int | rebind_context (const ACE_TString &name, Naming_Context &naming_context) |
| Rename <naming_context> to <name>. More... | |
| int | resolve_context (const Name &name, Naming_Context &naming_context, u_long security_access=KEY_ALL_ACCESS) |
| Find <naming_context> with <name> in <this> context (Name version). More... | |
| int | resolve_context (const ACE_TString &name, Naming_Context &naming_context, u_long security_access=KEY_ALL_ACCESS) |
| Find <naming_context> with <name> in <this> context. More... | |
| int | unbind_context (const Name &name) |
| Remove naming_context with <name> from <this> context (Name version). More... | |
| int | unbind_context (const ACE_TString &name) |
| Remove naming_context with <name> from <this> context. More... | |
| int | destroy (void) |
| Same as <unbind_context> with <this> as naming_context. More... | |
| int | list (u_long how_many, Binding_List &list, Binding_Iterator &iterator) |
| int | list (Binding_List &list) |
| listing function: iterator creator This gives back a listing of all entries in <this> context. More... | |
| int | flush (void) |
| Sync content of context to disk. More... | |
| int | close (void) |
| Close the handle of the context Note: <close> does not call <flush>. More... | |
| HKEY | key (void) |
| Get key. More... | |
| HKEY | parent (void) |
| Get parent. More... | |
| void | name (Name &name) |
| Get name (Name version). More... | |
| void | name (ACE_TString &name) |
| Set name (String version). More... | |
| ACE_TString | name (void) |
| Get name (String version). More... | |
Protected Methods | |
| void | key (HKEY key) |
| Set key. More... | |
| void | parent (HKEY parent) |
| Set parent. More... | |
| void | name (const Name &name) |
| Set name (Name version). More... | |
| void | name (const ACE_TString &name) |
| Set name (String version). More... | |
Private Methods | |
| Naming_Context (const Naming_Context &rhs) | |
| Disallow copy constructors. More... | |
| const Naming_Context & | operator= (const Naming_Context &rhs) |
| Disallow assignment. More... | |
Private Attributes | |
| HKEY | key_ |
| Key for self. More... | |
| HKEY | parent_key_ |
| Key for parent. More... | |
| ACE_TString | name_ |
| Name of self. More... | |
Friends | |
| class | ACE_Predefined_Naming_Contexts |
| Friend factory. More... | |
Think about a context as being similar to a directory in a file system.
Definition at line 176 of file Registry.h.
|
|
Definition at line 182 of file Registry.h.
00182 {
00183 /// Max sizes of names
00184 /// (Not too sure about this value)
00185 MAX_OBJECT_NAME_SIZE = BUFSIZ,
00186
00187 /// Max size of context name
00188 MAX_CONTEXT_NAME_SIZE = MAXPATHLEN + 1
00189 };
|
|
|
Empty constructor: keys will be NULL.
Definition at line 173 of file Registry.cpp. Referenced by rebind_context.
00174 : key_ ((HKEY) 0), 00175 parent_key_ ((HKEY) 0), 00176 name_ () 00177 { 00178 } |
|
|
Constructor: key_ will be set to <key>.
Definition at line 182 of file Registry.cpp.
00183 : key_ (key), 00184 parent_key_ ((HKEY) 0), 00185 name_ () 00186 { 00187 } |
|
|
Destructor will call <Naming_Context::close>.
Definition at line 212 of file Registry.cpp. References close.
00213 {
00214 this->close ();
00215 }
|
|
|
Disallow copy constructors.
Definition at line 190 of file Registry.cpp.
00191 : key_ (rhs.key_), 00192 parent_key_ (rhs.parent_key_), 00193 name_ (rhs.name_) 00194 { 00195 // This is incorrect. 00196 // Rather than copying key, we should call ::DuplicateHandle() 00197 // But since this is private (and not used), I don't care much 00198 } |
|
||||||||||||
|
Insert or update <object> with <name> into <this> context This will not fail if <name> already exists (String version) Definition at line 260 of file Registry.cpp. References ACE_REGISTRY_CALL_RETURN, and ACE_String_Base< char >::c_str.
00262 {
00263 long result = ACE_TEXT_RegSetValueEx (this->key_,
00264 name.c_str (),
00265 0,
00266 object.type (),
00267 (const BYTE *) object.data (),
00268 object.size ());
00269 ACE_REGISTRY_CALL_RETURN (result);
00270 }
|
|
||||||||||||
|
Insert or update <object> with <name> into <this> context This will not fail if <name> already exists (Name version) Definition at line 250 of file Registry.cpp. References ACE_Registry::make_string. Referenced by ACE_Registry_Name_Space::bind, bind_new, and rebind.
00252 {
00253 return this->bind (ACE_Registry::make_string (name), object);
00254 }
|
|
||||||||||||||||||||||||
|
Insert or update <naming_context> with <name> relative to <this> context This will not fail if <name> already exists.
Definition at line 454 of file Registry.cpp. References ACE_REGISTRY_CALL_RETURN, and ACE_String_Base< char >::c_str.
00459 {
00460 u_long reason;
00461
00462 long result = ACE_TEXT_RegCreateKeyEx (this->key_,
00463 name.c_str (),
00464 0,
00465 0,
00466 persistence,
00467 security_access,
00468 security_attributes,
00469 &naming_context.key_,
00470 &reason);
00471 if (result == ERROR_SUCCESS)
00472 {
00473 // Set the correct parent
00474 naming_context.parent (this->key_);
00475 // Set the correct name
00476 naming_context.name (name);
00477 }
00478
00479 ACE_REGISTRY_CALL_RETURN (result);
00480 }
|
|
||||||||||||||||||||||||
|
Insert or update <naming_context> with <name> relative to <this> context This will not fail if <name> already exists (Name version) Definition at line 437 of file Registry.cpp. References ACE_Registry::make_string. Referenced by ACE_Registry_Name_Space::open.
00442 {
00443 return this->bind_context (ACE_Registry::make_string (name),
00444 naming_context,
00445 persistence,
00446 security_access,
00447 security_attributes);
00448 }
|
|
||||||||||||
|
Insert <object> with <name> into <this> context This will fail if <name> already exists (String version) Definition at line 231 of file Registry.cpp.
|
|
||||||||||||
|
Insert <object> with <name> into <this> context This will fail if <name> already exists (Name version) Definition at line 221 of file Registry.cpp. References ACE_Registry::make_string.
00223 {
00224 return this->bind_new (ACE_Registry::make_string (name), object);
00225 }
|
|
||||||||||||||||||||||||
|
Insert <naming_context> with <name> relative to <this> context This will fail if <name> already exists.
Definition at line 389 of file Registry.cpp. References ACE_REGISTRY_CALL_RETURN, and ACE_String_Base< char >::c_str.
00394 {
00395 u_long reason;
00396
00397 long result = ACE_TEXT_RegCreateKeyEx (this->key_,
00398 name.c_str (),
00399 0,
00400 0,
00401 persistence,
00402 security_access,
00403 security_attributes,
00404 &naming_context.key_,
00405 &reason);
00406 if (result == ERROR_SUCCESS)
00407 // If create succeeds
00408 {
00409 if (reason == REG_CREATED_NEW_KEY)
00410 // If new key: success
00411 {
00412 // Set the correct parent
00413 naming_context.parent (this->key_);
00414 // Set the correct name
00415 naming_context.name (name);
00416 }
00417 else
00418 // reason == REG_OPENED_EXISTING_KEY
00419 // Failed to make new key
00420 {
00421 // reset result to failure
00422 result = -1;
00423 // Close the key first
00424 ::RegCloseKey (naming_context.key_);
00425 // Reset key
00426 naming_context.key_ = (HKEY) 0;
00427 }
00428 }
00429
00430 ACE_REGISTRY_CALL_RETURN (result);
00431 }
|
|
||||||||||||||||||||||||
|
Insert <naming_context> with <name> relative to <this> context This will fail if <name> already exists (Name version) Definition at line 372 of file Registry.cpp. References ACE_Registry::make_string. Referenced by rebind_context.
00377 {
00378 return this->bind_new_context (ACE_Registry::make_string (name),
00379 naming_context,
00380 persistence,
00381 security_access,
00382 security_attributes);
00383 }
|
|
|
Close the handle of the context Note: <close> does not call <flush>.
Definition at line 601 of file Registry.cpp. References ACE_REGISTRY_CALL_RETURN, and key_. Referenced by ~Naming_Context.
00602 {
00603 long result = this->key_ ? ::RegCloseKey (this->key_) : ERROR_SUCCESS;
00604 ACE_REGISTRY_CALL_RETURN (result);
00605 }
|
|
|
Same as <unbind_context> with <this> as naming_context.
Definition at line 580 of file Registry.cpp. References ACE_REGISTRY_CALL_RETURN.
00581 {
00582 // hopefully the parent_key_ is still open
00583 long result = ACE_TEXT_RegDeleteKey (this->parent_key_,
00584 this->name_.c_str ());
00585
00586 ACE_REGISTRY_CALL_RETURN (result);
00587 }
|
|
|
Sync content of context to disk.
Definition at line 592 of file Registry.cpp. References ACE_REGISTRY_CALL_RETURN, and key_.
00593 {
00594 long result = ::RegFlushKey (this->key_);
00595 ACE_REGISTRY_CALL_RETURN (result);
00596 }
|
|
|
Set key.
Definition at line 673 of file Registry.cpp.
|
|
|
Get key.
Definition at line 681 of file Registry.cpp. References key_. Referenced by key.
00682 {
00683 return this->key_;
00684 }
|
|
|
listing function: iterator creator This gives back a listing of all entries in <this> context.
Definition at line 781 of file Registry.cpp. References ACE_Registry::Binding_List, ACE_Registry::Binding_Iterator::current_enumeration, ACE_Unbounded_Set::insert, ACE_Registry::Binding_Iterator::naming_context, ACE_Registry::Binding_Iterator::next_one, and ACE_Registry::Binding_Iterator::object_iteration_.
00782 {
00783 // Empty list
00784 static const ACE_Registry::Binding_List empty_list;
00785 // Make sure that the list is empty
00786 list = empty_list;
00787
00788 // Create an iterator
00789 ACE_Registry::Binding_Iterator iterator;
00790
00791 // Make sure that the iterator uses <this> naming context
00792 iterator.naming_context (*this);
00793
00794 // Start iterations from the objects
00795 iterator.current_enumeration (iterator.object_iteration_);
00796
00797 long result = 0;
00798 while (1)
00799 {
00800 ACE_Registry::Binding binding;
00801 result = iterator.next_one (binding);
00802 if (result == 0)
00803 list.insert (binding);
00804 else
00805 break;
00806 }
00807 return 0;
00808 }
|
|
||||||||||||||||
|
listing function: iterator creator This is useful when there are many objects and contexts in <this> context and you only want to look at a few entries at a time Definition at line 753 of file Registry.cpp. References ACE_Registry::Binding_List, and ACE_Unbounded_Set::reset. Referenced by ACE_Registry_Name_Space::list_name_entries.
00756 {
00757 // Empty list
00758 static const ACE_Registry::Binding_List empty_list;
00759 // Make sure that the list is empty
00760 list = empty_list;
00761
00762 // Correctly initalize the iterator
00763 iter.reset ();
00764
00765 // Make sure that the iterator uses <this> naming context
00766 iter.naming_context (*this);
00767
00768 // Start iterations from the objects
00769 iter.current_enumeration (iter.object_iteration_);
00770
00771 // Get the next <how_many> values
00772 long result = iter.next_n (how_many,
00773 list);
00774 return result;
00775 }
|
|
|
Set name (String version).
Definition at line 724 of file Registry.cpp. References name_.
00725 {
00726 this->name_ = name;
00727 }
|
|
|
Set name (Name version).
Definition at line 706 of file Registry.cpp. References ACE_Registry::make_string, and name_.
00707 {
00708 this->name_ = ACE_Registry::make_string (name);
00709 }
|
|
|
Get name (String version).
Definition at line 733 of file Registry.cpp. References name_.
00734 {
00735 return this->name_;
00736 }
|
|
|
Set name (String version).
Definition at line 742 of file Registry.cpp. References name_.
00743 {
00744 name = this->name_;
00745 }
|
|
|
Get name (Name version).
Definition at line 715 of file Registry.cpp. References ACE_Registry::make_name.
00716 {
00717 name = ACE_Registry::make_name (this->name_);
00718 }
|
|
|
Create new <naming_context>.
Definition at line 362 of file Registry.cpp.
00363 {
00364 // Make sure that we reset the state and close keys
00365 return naming_context.close ();
00366 }
|
|
|
Disallow assignment.
Definition at line 202 of file Registry.cpp.
00203 {
00204 ACE_UNUSED_ARG(rhs);
00205
00206 // Not implemented
00207 return *this;
00208 }
|
|
|
Set parent.
Definition at line 689 of file Registry.cpp. References parent, and parent_key_.
00690 {
00691 this->parent_key_ = parent;
00692 }
|
|
|
Get parent.
Definition at line 697 of file Registry.cpp. References parent_key_. Referenced by parent.
00698 {
00699 return this->parent_key_;
00700 }
|
|
||||||||||||
|
Update <object> with <name> in <this> context.
Definition at line 286 of file Registry.cpp.
|
|
||||||||||||
|
Update <object> with <name> in <this> context (Name version).
Definition at line 276 of file Registry.cpp. References ACE_Registry::make_string. Referenced by ACE_Registry_Name_Space::rebind.
00278 {
00279 return this->rebind (ACE_Registry::make_string (name), new_object);
00280 }
|
|
||||||||||||
|
Rename <naming_context> to <name>.
Definition at line 497 of file Registry.cpp. References bind_new_context, Naming_Context, resolve_context, and unbind_context.
00499 {
00500 Naming_Context old_naming_context;
00501 // find the old one first
00502 long result = this->resolve_context (name,
00503 old_naming_context);
00504 if (result == 0)
00505 {
00506 // naming_context is found: delete entry
00507 result = this->unbind_context (name);
00508 if (result == 0)
00509 {
00510 // successful deletion; rebind
00511 // beware of race conditions here
00512 // (lets resolve this later)
00513 result = this->bind_new_context (name, new_naming_context);
00514 }
00515 }
00516 return result;
00517 }
|
|
||||||||||||
|
Rename <naming_context> to <name> (Name version).
Definition at line 486 of file Registry.cpp. References ACE_Registry::make_string.
00488 {
00489 return this->rebind_context (ACE_Registry::make_string (name),
00490 new_naming_context);
00491 }
|
|
||||||||||||
|
Find <object> with <name> in <this> context.
Definition at line 312 of file Registry.cpp. References ACE_REGISTRY_CALL_RETURN, and ACE_String_Base< char >::c_str.
00314 {
00315 // Get object state
00316 u_long type;
00317 void *data = object.data ();
00318 u_long size = object.size ();
00319
00320 long result = ACE_TEXT_RegQueryValueEx (this->key_,
00321 name.c_str (),
00322 0,
00323 &type,
00324 (BYTE *)data,
00325 &size);
00326 if (result == ERROR_SUCCESS)
00327 {
00328 // Reset object state
00329 // No need to set object.data()
00330 object.type (type);
00331 object.size (size);
00332 }
00333
00334 ACE_REGISTRY_CALL_RETURN (result);
00335 }
|
|
||||||||||||
|
Find <object> with <name> in <this> context (Name version).
Definition at line 302 of file Registry.cpp. References ACE_Registry::make_string. Referenced by bind_new, rebind, and ACE_Registry_Name_Space::resolve.
00304 {
00305 return this->resolve (ACE_Registry::make_string (name), object);
00306 }
|
|
||||||||||||||||
|
Find <naming_context> with <name> in <this> context.
Definition at line 557 of file Registry.cpp. References ACE_REGISTRY_CALL_RETURN, and ACE_String_Base< char >::c_str.
00560 {
00561 long result = ACE_TEXT_RegOpenKeyEx (this->key_,
00562 name.c_str (),
00563 0,
00564 security_access,
00565 &naming_context.key_);
00566 if (result == ERROR_SUCCESS)
00567 {
00568 // set the correct parent
00569 naming_context.parent (this->key_);
00570 // set the correct name
00571 naming_context.name (name);
00572 }
00573
00574 ACE_REGISTRY_CALL_RETURN (result);
00575 }
|
|
||||||||||||||||
|
Find <naming_context> with <name> in <this> context (Name version).
Definition at line 544 of file Registry.cpp. References ACE_Registry::make_string. Referenced by rebind_context.
00547 {
00548 return this->resolve_context (ACE_Registry::make_string (name),
00549 naming_context,
00550 security_access);
00551 }
|
|
|
Delete object with <name> in <this> context.
Definition at line 350 of file Registry.cpp. References ACE_REGISTRY_CALL_RETURN, and ACE_String_Base< char >::c_str.
00351 {
00352 long result = ACE_TEXT_RegDeleteValue (this->key_,
00353 name.c_str ());
00354
00355 ACE_REGISTRY_CALL_RETURN (result);
00356 }
|
|
|
Delete object with <name> in <this> context (Name version).
Definition at line 341 of file Registry.cpp. References ACE_Registry::make_string. Referenced by ACE_Registry_Name_Space::unbind.
00342 {
00343 return this->unbind (ACE_Registry::make_string (name));
00344 }
|
|
|
Remove naming_context with <name> from <this> context.
Definition at line 532 of file Registry.cpp. References ACE_REGISTRY_CALL_RETURN, and ACE_String_Base< char >::c_str.
00533 {
00534 long result = ACE_TEXT_RegDeleteKey (this->key_,
00535 name.c_str ());
00536
00537 ACE_REGISTRY_CALL_RETURN (result);
00538 }
|
|
|
Remove naming_context with <name> from <this> context (Name version).
Definition at line 523 of file Registry.cpp. References ACE_Registry::make_string. Referenced by rebind_context.
00524 {
00525 return this->unbind_context (ACE_Registry::make_string (name));
00526 }
|
|
|
Friend factory.
Definition at line 180 of file Registry.h. |
|
|
Key for self.
Definition at line 401 of file Registry.h. Referenced by close, ACE_Predefined_Naming_Contexts::connect, flush, and key. |
|
|
Name of self.
Definition at line 407 of file Registry.h. Referenced by name. |
|
|
Key for parent.
Definition at line 404 of file Registry.h. Referenced by parent. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002