#include <Monitor_Point_Registry.h>
Collaboration diagram for ACE::Monitor_Control::Monitor_Point_Registry:
Public Member Functions | |
bool | add (Monitor_Base *type) |
Adds a monitor to the registry. | |
bool | remove (const char *name) |
Remove a monitor from the registry. | |
Monitor_Control_Types::NameList | names (void) |
Returns a list of names stored in the registry. | |
Monitor_Base * | get (const ACE_CString &name) const |
long | constraint_id (void) |
Returns a unique id for a constraint when it is created. | |
void | cleanup (void) |
Static Public Member Functions | |
static Monitor_Point_Registry * | instance (void) |
Private Types | |
typedef ACE_Hash_Map_Manager< ACE_CString, Monitor_Base *, ACE_SYNCH_NULL_MUTEX > | Map |
Underlying container for the registry. | |
Private Member Functions | |
Monitor_Point_Registry (void) | |
Prevent that users can make an instance. | |
Private Attributes | |
ACE_SYNCH_MUTEX | mutex_ |
Map | map_ |
long | constraint_id_ |
Friends | |
class | ACE_Singleton< Monitor_Point_Registry, ACE_SYNCH_MUTEX > |
Definition at line 46 of file Monitor_Point_Registry.h.
typedef ACE_Hash_Map_Manager<ACE_CString, Monitor_Base*, ACE_SYNCH_NULL_MUTEX> ACE::Monitor_Control::Monitor_Point_Registry::Map [private] |
ACE::Monitor_Control::Monitor_Point_Registry::Monitor_Point_Registry | ( | void | ) | [private] |
Prevent that users can make an instance.
Definition at line 22 of file Monitor_Point_Registry.cpp.
00023 : constraint_id_ (0) 00024 { 00025 }
bool ACE::Monitor_Control::Monitor_Point_Registry::add | ( | Monitor_Base * | type | ) |
Adds a monitor to the registry.
Definition at line 28 of file Monitor_Point_Registry.cpp.
References ACE_ERROR_RETURN, ACE_GUARD_RETURN, ACE_SYNCH_MUTEX, ACE::Monitor_Control::Monitor_Base::add_ref(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind(), LM_ERROR, map_, and ACE::Monitor_Control::Monitor_Base::name().
Referenced by ACE::Monitor_Control::Monitor_Admin::monitor_point().
00029 { 00030 if (type == 0) 00031 { 00032 ACE_ERROR_RETURN ((LM_ERROR, 00033 "registry add: null type\n"), 00034 false); 00035 } 00036 00037 int status = 0; 00038 00039 { 00040 ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, false); 00041 00042 type->add_ref (); 00043 00044 status = this->map_.bind (type->name (), type); 00045 } 00046 00047 if (status == -1) 00048 { 00049 ACE_ERROR_RETURN ((LM_ERROR, 00050 "registry add: map bind failed\n"), 00051 false); 00052 } 00053 00054 return (status == 0); 00055 }
void ACE::Monitor_Control::Monitor_Point_Registry::cleanup | ( | void | ) |
Decrements the reference count on all remaining entries, called right before we go out of scope (i.e., process exits).
Definition at line 143 of file Monitor_Point_Registry.cpp.
References ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::end(), and map_.
Referenced by ACE::Monitor_Control::Monitor_Admin::~Monitor_Admin().
00144 { 00145 for (Map::ITERATOR i = this->map_.begin (); 00146 i != this->map_.end (); 00147 i.advance ()) 00148 { 00149 Map::ENTRY* entry = 0; 00150 i.next (entry); 00151 entry->int_id_->remove_ref (); 00152 } 00153 }
long ACE::Monitor_Control::Monitor_Point_Registry::constraint_id | ( | void | ) |
Returns a unique id for a constraint when it is created.
Definition at line 129 of file Monitor_Point_Registry.cpp.
References ACE_GUARD_RETURN, ACE_SYNCH_MUTEX, and constraint_id_.
Referenced by ACE::Monitor_Control::Monitor_Base::add_constraint().
00130 { 00131 long retval = 0; 00132 00133 { 00134 ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, -1); 00135 00136 retval = this->constraint_id_++; 00137 } 00138 00139 return retval; 00140 }
Monitor_Base * ACE::Monitor_Control::Monitor_Point_Registry::get | ( | const ACE_CString & | name | ) | const |
Increments the refcount, so the caller is responsible for decrementing it when finished.
Definition at line 110 of file Monitor_Point_Registry.cpp.
References ACE_GUARD_RETURN, ACE_SYNCH_MUTEX, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), and map_.
Referenced by ACE::Monitor_Control::Monitor_Admin::monitor_point().
00111 { 00112 Map::data_type mp = 0; 00113 00114 { 00115 ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, 0); 00116 00117 this->map_.find (name, mp); 00118 } 00119 00120 if (mp != 0) 00121 { 00122 mp->add_ref (); 00123 } 00124 00125 return mp; 00126 }
Monitor_Point_Registry * ACE::Monitor_Control::Monitor_Point_Registry::instance | ( | void | ) | [static] |
Used to help ensure that there is only a single instance per process of Monitor_Point_Registry.
Definition at line 16 of file Monitor_Point_Registry.cpp.
References ACE_Singleton< TYPE, ACE_LOCK >::instance().
Referenced by ACE::Monitor_Control::Monitor_Base::add_constraint(), ACE::Monitor_Control::Monitor_Admin::monitor_point(), ACE::Monitor_Control::Monitor_Base::remove_from_registry(), and ACE::Monitor_Control::Monitor_Admin::~Monitor_Admin().
00017 { 00018 return 00019 ACE_Singleton<Monitor_Point_Registry, ACE_SYNCH_MUTEX>::instance (); 00020 }
Monitor_Control_Types::NameList ACE::Monitor_Control::Monitor_Point_Registry::names | ( | void | ) |
Returns a list of names stored in the registry.
Definition at line 93 of file Monitor_Point_Registry.cpp.
References ACE_GUARD_RETURN, ACE_SYNCH_MUTEX, ACE_Hash_Map_Const_Iterator_Base_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::done(), and ACE_Vector< T, DEFAULT_SIZE >::push_back().
00094 { 00095 Monitor_Control_Types::NameList name_holder_; 00096 00097 { 00098 ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, 0); 00099 00100 for (Map::CONST_ITERATOR i (this->map_); !i.done (); i.advance ()) 00101 { 00102 name_holder_.push_back (i->key ()); 00103 } 00104 } 00105 00106 return name_holder_; 00107 }
bool ACE::Monitor_Control::Monitor_Point_Registry::remove | ( | const char * | name | ) |
Remove a monitor from the registry.
Definition at line 58 of file Monitor_Point_Registry.cpp.
References ACE_ERROR_RETURN, ACE_GUARD_RETURN, ACE_SYNCH_MUTEX, LM_ERROR, map_, and ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind().
00059 { 00060 if (name == 0) 00061 { 00062 ACE_ERROR_RETURN ((LM_ERROR, 00063 "registry remove: null name\n"), 00064 false); 00065 } 00066 00067 int status = 0; 00068 Map::data_type mp = 0; 00069 00070 { 00071 ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, false); 00072 00073 ACE_CString name_str (name, 0, false); 00074 status = this->map_.unbind (name_str, mp); 00075 } 00076 00077 if (status == -1) 00078 { 00079 ACE_ERROR_RETURN ((LM_ERROR, 00080 "registry remove: unbind failed for %s\n", 00081 name), 00082 false); 00083 } 00084 else 00085 { 00086 mp->remove_ref (); 00087 } 00088 00089 return (status == 0); 00090 }
friend class ACE_Singleton< Monitor_Point_Registry, ACE_SYNCH_MUTEX > [friend] |
Definition at line 49 of file Monitor_Point_Registry.h.
long ACE::Monitor_Control::Monitor_Point_Registry::constraint_id_ [private] |
Since we're accessed as a singleton, we can keep track of dispensing unique ids for constraints.
Definition at line 89 of file Monitor_Point_Registry.h.
Referenced by constraint_id().
ACE_SYNCH_MUTEX ACE::Monitor_Control::Monitor_Point_Registry::mutex_ [mutable, private] |
Definition at line 84 of file Monitor_Point_Registry.h.