#include <Storable_Naming_Context.h>
Inheritance diagram for TAO_Storable_Bindings_Map:
Public Types | |
typedef ACE_Hash_Map_Manager< TAO_Storable_ExtId, TAO_Storable_IntId, ACE_Null_Mutex > | HASH_MAP |
Underlying data structure - typedef for ease of use. | |
Public Member Functions | |
TAO_Storable_Bindings_Map (size_t hash_table_size, CORBA::ORB_ptr orb) | |
Constructor. | |
virtual | ~TAO_Storable_Bindings_Map (void) |
Destructor. | |
HASH_MAP & | map (void) |
Get a reference to the underlying hash map. | |
size_t | total_size (void) |
Return the size of the underlying hash table. | |
virtual size_t | current_size (void) |
virtual int | bind (const char *id, const char *kind, CORBA::Object_ptr obj, CosNaming::BindingType type) |
virtual int | rebind (const char *id, const char *kind, CORBA::Object_ptr obj, CosNaming::BindingType type) |
virtual int | unbind (const char *id, const char *kind) |
virtual int | find (const char *id, const char *kind, CORBA::Object_ptr &obj, CosNaming::BindingType &type) |
Private Member Functions | |
int | shared_bind (const char *id, const char *kind, CORBA::Object_ptr obj, CosNaming::BindingType type, int rebind) |
Helper: factors common code from <bind> and <rebind>. | |
Private Attributes | |
HASH_MAP | map_ |
Hash map used for storage. | |
CORBA::ORB_var | orb_ |
A thin wrapper on top of ACE_Hash_Map_Manager. Supports TAO_Bindings_Map interface. Used by TAO_Transient_Naming_Context.
Definition at line 119 of file Storable_Naming_Context.h.
typedef ACE_Hash_Map_Manager<TAO_Storable_ExtId, TAO_Storable_IntId, ACE_Null_Mutex> TAO_Storable_Bindings_Map::HASH_MAP |
Underlying data structure - typedef for ease of use.
Definition at line 126 of file Storable_Naming_Context.h.
TAO_Storable_Bindings_Map::TAO_Storable_Bindings_Map | ( | size_t | hash_table_size, | |
CORBA::ORB_ptr | orb | |||
) |
Constructor.
Definition at line 188 of file Storable_Naming_Context.cpp.
References ACE_TRACE.
00190 : map_ (hash_table_size), 00191 orb_(CORBA::ORB::_duplicate (orb)) 00192 { 00193 ACE_TRACE("TAO_Storable_Bindings_Map"); 00194 }
TAO_Storable_Bindings_Map::~TAO_Storable_Bindings_Map | ( | void | ) | [virtual] |
Destructor.
Definition at line 196 of file Storable_Naming_Context.cpp.
References ACE_TRACE.
00197 { 00198 ACE_TRACE("~TAO_Storable_Bindings_Map"); 00199 }
int TAO_Storable_Bindings_Map::bind | ( | const char * | id, | |
const char * | kind, | |||
CORBA::Object_ptr | obj, | |||
CosNaming::BindingType | type | |||
) | [virtual] |
Add a binding with the specified parameters to the table. Return 0 on success and -1 on failure, 1 if there already is a binding with <id> and <kind>.
Implements TAO_Bindings_Map.
Definition at line 146 of file Storable_Naming_Context.cpp.
References ACE_TRACE, and shared_bind().
Referenced by TAO_Storable_Naming_Context::load_map().
00150 { 00151 ACE_TRACE("bind"); 00152 return this->shared_bind (id, kind, obj, type, 0); 00153 }
size_t TAO_Storable_Bindings_Map::current_size | ( | void | ) | [virtual] |
Return current number of entries (name bindings) in the underlying hash map.
Implements TAO_Bindings_Map.
Definition at line 209 of file Storable_Naming_Context.cpp.
References ACE_TRACE, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::current_size(), and map_.
Referenced by TAO_Storable_Naming_Context::Write().
00210 { 00211 ACE_TRACE("current_size"); 00212 return map_.current_size (); 00213 }
int TAO_Storable_Bindings_Map::find | ( | const char * | id, | |
const char * | kind, | |||
CORBA::Object_ptr & | obj, | |||
CosNaming::BindingType & | type | |||
) | [virtual] |
Find the binding containing <id> and <kind> in the table, and pass binding's type and object back to the caller by reference. Return 0 on success and -1 on failure. Note: a 'duplicated' object reference is assigned to <obj>, so the caller is responsible for its deallocation.
Implements TAO_Bindings_Map.
Definition at line 166 of file Storable_Naming_Context.cpp.
References ACE_TRACE, orb_, TAO_Storable_IntId::ref_, and TAO_Storable_IntId::type_.
00170 { 00171 ACE_TRACE("find"); 00172 TAO_Storable_ExtId name (id, kind); 00173 TAO_Storable_IntId entry; 00174 00175 if (this->map_.find (name, entry) != 0) 00176 { 00177 return -1; 00178 } 00179 else 00180 { 00181 obj = orb_->string_to_object (entry.ref_.in()); 00182 type = entry.type_; 00183 00184 return 0; 00185 } 00186 }
TAO_Storable_Bindings_Map::HASH_MAP & TAO_Storable_Bindings_Map::map | ( | void | ) |
Get a reference to the underlying hash map.
Definition at line 202 of file Storable_Naming_Context.cpp.
References ACE_TRACE, and map_.
Referenced by TAO_Storable_Naming_Context::list(), and TAO_Storable_Naming_Context::Write().
int TAO_Storable_Bindings_Map::rebind | ( | const char * | id, | |
const char * | kind, | |||
CORBA::Object_ptr | obj, | |||
CosNaming::BindingType | type | |||
) | [virtual] |
Overwrite a binding containing <id> and <kind> (or create a new one if one doesn't exist) with the specified parameters. Return 0 or 1 on success. Return -1 or -2 on failure. (-2 is returned if the new and old bindings differ in type).
Implements TAO_Bindings_Map.
Definition at line 156 of file Storable_Naming_Context.cpp.
References ACE_TRACE, and shared_bind().
00160 { 00161 ACE_TRACE("rebind"); 00162 return this->shared_bind (id, kind, obj, type, 1); 00163 }
int TAO_Storable_Bindings_Map::shared_bind | ( | const char * | id, | |
const char * | kind, | |||
CORBA::Object_ptr | obj, | |||
CosNaming::BindingType | type, | |||
int | rebind | |||
) | [private] |
Helper: factors common code from <bind> and <rebind>.
Definition at line 223 of file Storable_Naming_Context.cpp.
References ACE_TRACE, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind(), map_, orb_, and ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::rebind().
Referenced by bind(), and rebind().
00228 { 00229 ACE_TRACE("shared_bind"); 00230 TAO_Storable_ExtId new_name (id, kind); 00231 CORBA::String_var ior = orb_->object_to_string(obj); 00232 TAO_Storable_IntId new_entry (ior.in(), type); 00233 TAO_Storable_IntId old_entry; 00234 00235 if (rebind == 0) 00236 { 00237 // Do a normal bind. 00238 return this->map_.bind (new_name, new_entry); 00239 } 00240 else 00241 // Rebind. 00242 { 00243 // Check that types of old and new entries match. 00244 if (this->map_.find (new_name, 00245 old_entry) == 0 00246 && type != old_entry.type_) 00247 return -2; 00248 00249 else 00250 return this->map_.rebind (new_name, new_entry); 00251 } 00252 }
size_t TAO_Storable_Bindings_Map::total_size | ( | void | ) |
Return the size of the underlying hash table.
Definition at line 216 of file Storable_Naming_Context.cpp.
References ACE_TRACE, map_, and ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::total_size().
Referenced by TAO_Storable_Naming_Context::new_context().
00217 { 00218 ACE_TRACE("total_size"); 00219 return map_.total_size (); 00220 }
int TAO_Storable_Bindings_Map::unbind | ( | const char * | id, | |
const char * | kind | |||
) | [virtual] |
Remove a binding containing <id> and <kind> from the table. Return 0 on success and -1 on failure.
Implements TAO_Bindings_Map.
Definition at line 138 of file Storable_Naming_Context.cpp.
References ACE_TRACE, map_, and ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind().
00139 { 00140 ACE_TRACE("unbind"); 00141 TAO_Storable_ExtId name (id, kind); 00142 return this->map_.unbind (name); 00143 }
HASH_MAP TAO_Storable_Bindings_Map::map_ [private] |
Hash map used for storage.
Definition at line 199 of file Storable_Naming_Context.h.
Referenced by current_size(), map(), shared_bind(), total_size(), and unbind().