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 65 of file Transient_Naming_Context.cpp.

00066   : map_ (hash_table_size)
00067 {
00068 }

TAO_Transient_Bindings_Map::~TAO_Transient_Bindings_Map void   )  [virtual]
 

Destructor.

Definition at line 70 of file Transient_Naming_Context.cpp.

00071 {
00072 }


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 28 of file Transient_Naming_Context.cpp.

References shared_bind().

00032 {
00033   return this->shared_bind (id, kind, obj, type, 0);
00034 }

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 81 of file Transient_Naming_Context.cpp.

00082 {
00083   return map_.current_size ();
00084 }

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 46 of file Transient_Naming_Context.cpp.

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

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

TAO_Transient_Bindings_Map::HASH_MAP & TAO_Transient_Bindings_Map::map void   ) 
 

Get a reference to the underlying hash map.

Definition at line 75 of file Transient_Naming_Context.cpp.

Referenced by TAO_Transient_Naming_Context::list().

00076 {
00077   return map_;
00078 }

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 37 of file Transient_Naming_Context.cpp.

References shared_bind().

00041 {
00042   return this->shared_bind (id, kind, obj, type, 1);
00043 }

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 93 of file Transient_Naming_Context.cpp.

References TAO_IntId::type_.

Referenced by bind(), and rebind().

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

size_t TAO_Transient_Bindings_Map::total_size void   ) 
 

Return the size of the underlying hash table.

Definition at line 87 of file Transient_Naming_Context.cpp.

Referenced by TAO_Transient_Naming_Context::new_context().

00088 {
00089   return map_.total_size ();
00090 }

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 21 of file Transient_Naming_Context.cpp.

00022 {
00023   TAO_ExtId name (id, kind);
00024   return this->map_.unbind (name);
00025 }


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 Sun Jan 27 16:16:26 2008 for TAO_CosNaming by doxygen 1.3.6