TAO_Transient_Bindings_Map Class Reference

Provides hash-table-based transient storage for name to object bindings in a Naming Context. More...

#include <Transient_Naming_Context.h>

Inheritance diagram for TAO_Transient_Bindings_Map:

Inheritance graph
[legend]
Collaboration diagram for TAO_Transient_Bindings_Map:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Hash_Map_Manager<
TAO_ExtId, TAO_IntId, ACE_Null_Mutex
HASH_MAP
 Underlying data structure - typedef for ease of use.


Public Member Functions

 TAO_Transient_Bindings_Map (size_t hash_table_size)
 Constructor.

virtual ~TAO_Transient_Bindings_Map (void)
 Destructor.

HASH_MAPmap (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 and .


Private Attributes

HASH_MAP map_
 Hash map used for storage.


Detailed Description

Provides hash-table-based transient storage for name to object bindings in a Naming Context.

A thin wrapper on top of ACE_Hash_Map_Manager. Supports TAO_Bindings_Map interface. Used by TAO_Transient_Naming_Context.

Definition at line 38 of file Transient_Naming_Context.h.


Member Typedef Documentation

typedef ACE_Hash_Map_Manager<TAO_ExtId, TAO_IntId, ACE_Null_Mutex> TAO_Transient_Bindings_Map::HASH_MAP
 

Underlying data structure - typedef for ease of use.

Definition at line 43 of file Transient_Naming_Context.h.


Constructor & Destructor Documentation

TAO_Transient_Bindings_Map::TAO_Transient_Bindings_Map size_t  hash_table_size  ) 
 

Constructor.

Definition at line 70 of file Transient_Naming_Context.cpp.

00071   : map_ (hash_table_size)
00072 {
00073 }

TAO_Transient_Bindings_Map::~TAO_Transient_Bindings_Map void   )  [virtual]
 

Destructor.

Definition at line 75 of file Transient_Naming_Context.cpp.

00076 {
00077 }


Member Function Documentation

int TAO_Transient_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 and .

Implements TAO_Bindings_Map.

Definition at line 33 of file Transient_Naming_Context.cpp.

References shared_bind().

00037 {
00038   return this->shared_bind (id, kind, obj, type, 0);
00039 }

size_t TAO_Transient_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 86 of file Transient_Naming_Context.cpp.

00087 {
00088   return map_.current_size ();
00089 }

int TAO_Transient_Bindings_Map::find const char *  id,
const char *  kind,
CORBA::Object_ptr obj,
CosNaming::BindingType type
[virtual]
 

Find the binding containing and 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 , so the caller is responsible for its deallocation.

Implements TAO_Bindings_Map.

Definition at line 51 of file Transient_Naming_Context.cpp.

References CORBA::Object::_duplicate(), TAO_IntId::ref_, and TAO_IntId::type_.

00055 {
00056   TAO_ExtId name (id, kind);
00057   TAO_IntId entry;
00058 
00059   if (this->map_.find (name,
00060                        entry) != 0)
00061     return -1;
00062   else
00063     {
00064       obj = CORBA::Object::_duplicate (entry.ref_);
00065       type = entry.type_;
00066       return 0;
00067     }
00068 }

TAO_Transient_Bindings_Map::HASH_MAP & TAO_Transient_Bindings_Map::map void   ) 
 

Get a reference to the underlying hash map.

Definition at line 80 of file Transient_Naming_Context.cpp.

Referenced by TAO_Transient_Naming_Context::list().

00081 {
00082   return map_;
00083 }

int TAO_Transient_Bindings_Map::rebind const char *  id,
const char *  kind,
CORBA::Object_ptr  obj,
CosNaming::BindingType  type
[virtual]
 

Overwrite a binding containing and (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 42 of file Transient_Naming_Context.cpp.

References shared_bind().

00046 {
00047   return this->shared_bind (id, kind, obj, type, 1);
00048 }

int TAO_Transient_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 and .

Definition at line 98 of file Transient_Naming_Context.cpp.

References TAO_IntId::type_.

Referenced by bind(), and rebind().

00103 {
00104   TAO_ExtId new_name (id, kind);
00105   TAO_IntId new_entry (obj, type);
00106   TAO_IntId old_entry;
00107 
00108   if (rebind == 0)
00109     // Do a normal bind.
00110     return this->map_.bind (new_name, new_entry);
00111 
00112   else
00113     // Rebind.
00114     {
00115       // Check that types of old and new entries match.
00116       if (this->map_.find (new_name,
00117                            old_entry) == 0
00118           && type != old_entry.type_)
00119         return -2;
00120 
00121       else
00122         return this->map_.rebind (new_name, new_entry);
00123     }
00124 }

size_t TAO_Transient_Bindings_Map::total_size void   ) 
 

Return the size of the underlying hash table.

Definition at line 92 of file Transient_Naming_Context.cpp.

Referenced by TAO_Transient_Naming_Context::new_context().

00093 {
00094   return map_.total_size ();
00095 }

TAO_BEGIN_VERSIONED_NAMESPACE_DECL int TAO_Transient_Bindings_Map::unbind const char *  id,
const char *  kind
[virtual]
 

Remove a binding containing and from the table. Return 0 on success and -1 on failure.

Implements TAO_Bindings_Map.

Definition at line 25 of file Transient_Naming_Context.cpp.

00027 {
00028   TAO_ExtId name (id, kind);
00029   return this->map_.unbind (name);
00030 }


Member Data Documentation

HASH_MAP TAO_Transient_Bindings_Map::map_ [private]
 

Hash map used for storage.

Definition at line 117 of file Transient_Naming_Context.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 13:57:52 2006 for TAO_CosNaming by doxygen 1.3.6