#include <Control_Registry.h>
Classes | |
class | Map_Error |
Exception thrown in the event that something goes wrong / when adding to the registry. More... | |
Public Types | |
typedef Monitor::NameList | NameList |
Reusing NameList that comes from the TAO Monitor library. | |
Public Member Functions | |
~TAO_Control_Registry (void) | |
Empty out the map of objects. | |
bool | add (TAO_NS_Control *type) |
Adds an object to the map. /// Throws Map_Error if the object is null or if there /// is a fatal error adding it to the map. /// Returns true if the object is successfully added to the map. /// Returns false otherwise. | |
bool | remove (const ACE_CString &name) |
Removes an object from the map. /// Returns true if the object is successfully removed from the map. /// Returns false otherwise. | |
const NameList & | names (void) |
Returns a list of names stored in the registry. | |
TAO_NS_Control * | get (const ACE_CString &name) const |
Gets an object from the map /// Returns the object if it is successfully located. /// Returns null otherwise. | |
Static Public Member Functions | |
static TAO_Control_Registry * | instance (void) |
Return the singleton instance of the registry. | |
Private Types | |
typedef ACE_Hash_Map_Manager < ACE_CString, TAO_NS_Control *, ACE_SYNCH_NULL_MUTEX > | Map |
Private Attributes | |
TAO_SYNCH_RW_MUTEX | mutex_ |
Map | map_ |
NameList | name_cache_ |
Definition at line 18 of file Control_Registry.h.
typedef ACE_Hash_Map_Manager<ACE_CString, TAO_NS_Control*, ACE_SYNCH_NULL_MUTEX> TAO_Control_Registry::Map [private] |
Definition at line 73 of file Control_Registry.h.
typedef Monitor::NameList TAO_Control_Registry::NameList |
Reusing NameList that comes from the TAO Monitor library.
Definition at line 22 of file Control_Registry.h.
TAO_Control_Registry::~TAO_Control_Registry | ( | void | ) |
Empty out the map of objects.
Definition at line 12 of file Control_Registry.cpp.
{ ACE_WRITE_GUARD (TAO_SYNCH_RW_MUTEX, guard, this->mutex_); Map::iterator itr (this->map_); Map::value_type* entry = 0; while (itr.next (entry)) { delete entry->item (); itr.advance (); } }
bool TAO_Control_Registry::add | ( | TAO_NS_Control * | type | ) |
Adds an object to the map. /// Throws Map_Error if the object is null or if there /// is a fatal error adding it to the map. /// Returns true if the object is successfully added to the map. /// Returns false otherwise.
Definition at line 27 of file Control_Registry.cpp.
{ ACE_WRITE_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard, this->mutex_, false); if (type == 0) { throw Map_Error (Map_Error::MAP_ERROR_INVALID_VALUE); } int status = this->map_.bind(type->name(), type); if (status == -1) { throw Map_Error (Map_Error::MAP_ERROR_BIND_FAILURE); } else if (status == 0) { // Invalidate the name list cache. this->name_cache_.length (0); } return (status == 0); }
TAO_NS_Control * TAO_Control_Registry::get | ( | const ACE_CString & | name | ) | const |
Gets an object from the map /// Returns the object if it is successfully located. /// Returns null otherwise.
Definition at line 100 of file Control_Registry.cpp.
{ ACE_READ_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard, this->mutex_, 0); Map::data_type type = 0; this->map_.find (name, type); return type; }
TAO_Control_Registry * TAO_Control_Registry::instance | ( | void | ) | [static] |
Return the singleton instance of the registry.
Definition at line 7 of file Control_Registry.cpp.
const TAO_Control_Registry::NameList & TAO_Control_Registry::names | ( | void | ) |
Returns a list of names stored in the registry.
Definition at line 71 of file Control_Registry.cpp.
{ if (this->name_cache_.length () == 0) { ACE_WRITE_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard, this->mutex_, this->name_cache_); if (this->name_cache_.length () == 0) { CORBA::ULong length = 0; Map::iterator itr (this->map_); Map::value_type* entry = 0; while (itr.next (entry)) { this->name_cache_.length (length + 1); this->name_cache_[length++] = CORBA::string_dup (entry->key ().c_str ()); itr.advance (); } } } return this->name_cache_; }
bool TAO_Control_Registry::remove | ( | const ACE_CString & | name | ) |
Removes an object from the map. /// Returns true if the object is successfully removed from the map. /// Returns false otherwise.
Definition at line 52 of file Control_Registry.cpp.
{ ACE_WRITE_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard, this->mutex_, false); Map::data_type type = 0; int status = this->map_.unbind(name, type); if (status != 0) { return false; } // Invalidate the name list cache. this->name_cache_.length (0); delete type; return true; }
Map TAO_Control_Registry::map_ [private] |
Definition at line 76 of file Control_Registry.h.
TAO_SYNCH_RW_MUTEX TAO_Control_Registry::mutex_ [mutable, private] |
Definition at line 75 of file Control_Registry.h.
NameList TAO_Control_Registry::name_cache_ [private] |
Definition at line 77 of file Control_Registry.h.