Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TAO_ValueFactory_Map Class Reference

#include <ValueFactory_Map.h>

Collaboration diagram for TAO_ValueFactory_Map:

Collaboration graph
[legend]
List of all members.

Public Methods

 TAO_ValueFactory_Map ()
 ~TAO_ValueFactory_Map ()
int rebind (const char *repo_id, CORBA_ValueFactory &factory)
int unbind (const char *repo_id, CORBA_ValueFactory &factory)
 Removes entry for repo_id from the map and sets factory to the tied one. More...

int find (const char *repo_id, CORBA_ValueFactory &factory)
void dump (void)

Private Types

typedef ACE_Hash_Map_Manager_Ex<
const char *, CORBA_ValueFactory,
ACE_Hash< const char * >,
ACE_Equal_To< const char * >,
TAO_SYNCH_RW_MUTEX > 
FACTORY_MAP_MANAGER
 The hash table data structure. More...


Private Attributes

FACTORY_MAP_MANAGER map_

Member Typedef Documentation

typedef ACE_Hash_Map_Manager_Ex<const char *, CORBA_ValueFactory, ACE_Hash<const char *>, ACE_Equal_To<const char *>, TAO_SYNCH_RW_MUTEX> TAO_ValueFactory_Map::FACTORY_MAP_MANAGER [private]
 

The hash table data structure.

Definition at line 65 of file ValueFactory_Map.h.


Constructor & Destructor Documentation

TAO_ValueFactory_Map::TAO_ValueFactory_Map  
 

Definition at line 30 of file ValueFactory_Map.cpp.

00031   : map_ ()   // use default size and allocator
00032 {
00033 }

TAO_ValueFactory_Map::~TAO_ValueFactory_Map  
 

Definition at line 35 of file ValueFactory_Map.cpp.

References CORBA::string_free.

00036 {
00037   // Initialize an iterator.  We need to go thru each entry and free
00038   // up storage allocated to hold the external ids and invoke
00039   // _remove_ref () on the internal ids.
00040   FACTORY_MAP_MANAGER::ITERATOR iterator (this->map_);
00041 
00042   for (FACTORY_MAP_MANAGER::ENTRY *entry = 0;
00043        iterator.next (entry) != 0;
00044        iterator.advance ())
00045     {
00046       // We had allocated memory and stored the string. So we free the
00047       // memory.
00048       CORBA::string_free ((char *) entry->ext_id_);
00049       entry->ext_id_ = 0;
00050       entry->int_id_->_remove_ref ();
00051       entry->int_id_ = 0;
00052     }
00053 }


Member Function Documentation

void TAO_ValueFactory_Map::dump void   
 

int TAO_ValueFactory_Map::find const char *    repo_id,
CORBA_ValueFactory   factory
 

Lookup a matching factory for repo_id. Invokes _add_ref () on the factory if found. Returns -1 on failure and 0 on success.

Definition at line 111 of file ValueFactory_Map.cpp.

References CORBA_ValueFactoryBase::_add_ref, ACE_Hash_Map_Manager_Ex< const char *, CORBA_ValueFactory, ACE_Hash< const char * >, ACE_Equal_To< const char * >, TAO_SYNCH_RW_MUTEX >::find, and map_.

Referenced by CORBA_ORB::lookup_value_factory.

00113 {
00114   int ret = 0;
00115   ret = this->map_.find (repo_id,
00116                          factory);
00117   // %! this must be guarded to be atomic  !!!!!!!!!!!!!!!!!!
00118   if (ret > -1)
00119     {
00120       factory->_add_ref ();    // The caller gets one reference as gift.
00121     }
00122 
00123   return ret;
00124 }

int TAO_ValueFactory_Map::rebind const char *    repo_id,
CORBA_ValueFactory   factory
 

Associate the factory (int_id) with the repo_id (ext_id). Invokes _add_ref () on the factory. If previous factory had been bind with this repo_id, this one is returned in factory (and the caller holds a reference). Returns -1 on failure, 0 on success and 1 if a previous factory is found (and returned in factory).

Definition at line 58 of file ValueFactory_Map.cpp.

References CORBA_ValueFactoryBase::_add_ref, map_, ACE_Hash_Map_Manager_Ex< const char *, CORBA_ValueFactory, ACE_Hash< const char * >, ACE_Equal_To< const char * >, TAO_SYNCH_RW_MUTEX >::rebind, and CORBA::string_free.

Referenced by CORBA_ORB::register_value_factory.

00060 {
00061 //  ACE_READ_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard, map_->mutex(),-1);
00062 //   --- but must be recursive
00063   const char *prev_repo_id;
00064   CORBA_ValueFactory prev_factory;
00065   int ret = 0;
00066   ret = this->map_.rebind (CORBA::string_dup (repo_id),
00067                            factory,
00068                            prev_repo_id,
00069                            prev_factory);
00070 
00071   if (ret > -1)   // ok, no error
00072     {
00073       factory->_add_ref ();    // The map owns one reference.
00074 
00075       if (ret == 1)    // there was a previous factory
00076         {
00077           factory = prev_factory;
00078           CORBA::string_free (ACE_const_cast(char*,prev_repo_id));
00079         }
00080     }
00081 
00082   return ret;
00083 }

int TAO_ValueFactory_Map::unbind const char *    repo_id,
CORBA_ValueFactory   factory
 

Removes entry for repo_id from the map and sets factory to the tied one.

Definition at line 86 of file ValueFactory_Map.cpp.

References ACE_Hash_Map_Manager_Ex< const char *, CORBA_ValueFactory, ACE_Hash< const char * >, ACE_Equal_To< const char * >, TAO_SYNCH_RW_MUTEX >::find, map_, CORBA::string_free, and ACE_Hash_Map_Manager_Ex< const char *, CORBA_ValueFactory, ACE_Hash< const char * >, ACE_Equal_To< const char * >, TAO_SYNCH_RW_MUTEX >::unbind.

00088 {
00089   FACTORY_MAP_MANAGER::ENTRY *prev_entry;
00090   int ret = 0;
00091   ret = this->map_.find (repo_id,
00092                          prev_entry);
00093   if (ret == 0)    // there was a matching factory
00094     {
00095       // set factory to the previous factory,
00096       factory = prev_entry->int_id_;
00097       char *temp = ACE_const_cast (char *, prev_entry->ext_id_);
00098       ret = this->map_.unbind (prev_entry);
00099 
00100       if (ret == 0)
00101         {
00102           CORBA::string_free (temp);
00103         }
00104     }
00105 
00106   return ret;
00107 }


Member Data Documentation

FACTORY_MAP_MANAGER TAO_ValueFactory_Map::map_ [private]
 

Definition at line 66 of file ValueFactory_Map.h.

Referenced by find, rebind, and unbind.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:46:24 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002