#include <ValueFactory_Map.h>

Public Member Functions | |
| TAO_ValueFactory_Map (void) | |
| ~TAO_ValueFactory_Map (void) | |
| int | rebind (const char *repo_id, CORBA::ValueFactory &factory) |
| int | unbind (const char *repo_id, CORBA::ValueFactory &factory) |
| int | find (const char *repo_id, CORBA::ValueFactory &factory) |
| void | dump (void) |
Static Public Member Functions | |
| static TAO_ValueFactory_Map * | instance (void) |
| Return singleton instance of this class. | |
Private Types | |
| typedef ACE_Hash_Map_Manager_Ex< const char *, CORBA::ValueFactory, ACE_Hash< const char * > , ACE_Equal_To< const char * > , ACE_SYNCH_NULL_MUTEX > | FACTORY_MAP_MANAGER |
| The hash table data structure. | |
Private Attributes | |
| FACTORY_MAP_MANAGER | map_ |
| TAO_SYNCH_MUTEX | mutex_ |
| synchronization of the map | |
Definition at line 37 of file ValueFactory_Map.h.
typedef ACE_Hash_Map_Manager_Ex<const char *, CORBA::ValueFactory, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_SYNCH_NULL_MUTEX> TAO_ValueFactory_Map::FACTORY_MAP_MANAGER [private] |
The hash table data structure.
Definition at line 81 of file ValueFactory_Map.h.
| TAO_ValueFactory_Map::TAO_ValueFactory_Map | ( | void | ) |
Definition at line 11 of file ValueFactory_Map.cpp.
| TAO_ValueFactory_Map::~TAO_ValueFactory_Map | ( | void | ) |
Definition at line 16 of file ValueFactory_Map.cpp.
{
// Initialize an iterator. We need to go thru each entry and free
// up storage allocated to hold the external ids and invoke
// _remove_ref () on the internal ids.
FACTORY_MAP_MANAGER::ITERATOR iterator (this->map_);
for (FACTORY_MAP_MANAGER::ENTRY *entry = 0;
iterator.next (entry) != 0;
iterator.advance ())
{
// We had allocated memory and stored the string. So we free the
// memory.
CORBA::string_free ((char *) entry->ext_id_);
entry->ext_id_ = 0;
entry->int_id_->_remove_ref ();
entry->int_id_ = 0;
}
}
| 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 90 of file ValueFactory_Map.cpp.
{
ACE_GUARD_RETURN(TAO_SYNCH_MUTEX, guard, this->mutex_, -1);
int const ret = this->map_.find (repo_id, factory);
if (ret > -1)
{
factory->_add_ref (); // The caller gets one reference as gift.
}
return ret;
}
| static TAO_ValueFactory_Map* TAO_ValueFactory_Map::instance | ( | void | ) | [static] |
Return singleton instance of this class.
| 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 37 of file ValueFactory_Map.cpp.
{
ACE_GUARD_RETURN(TAO_SYNCH_MUTEX, guard, this->mutex_, -1);
const char *prev_repo_id = 0;
CORBA::ValueFactory prev_factory = 0;
int const ret = this->map_.rebind (CORBA::string_dup (repo_id),
factory,
prev_repo_id,
prev_factory);
if (ret > -1) // ok, no error
{
factory->_add_ref (); // The map owns one reference.
if (ret == 1) // there was a previous factory
{
factory = prev_factory;
CORBA::string_free (const_cast<char*> (prev_repo_id));
}
}
return ret;
}
| 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 64 of file ValueFactory_Map.cpp.
{
ACE_GUARD_RETURN(TAO_SYNCH_MUTEX, guard, this->mutex_, -1);
FACTORY_MAP_MANAGER::ENTRY *prev_entry = 0;
int ret = this->map_.find (repo_id, prev_entry);
if (ret == 0) // there was a matching factory
{
// set factory to the previous factory,
factory = prev_entry->int_id_;
char *temp = const_cast<char *> (prev_entry->ext_id_);
ret = this->map_.unbind (prev_entry);
if (ret == 0)
{
CORBA::string_free (temp);
}
}
return ret;
}
Definition at line 82 of file ValueFactory_Map.h.
TAO_SYNCH_MUTEX TAO_ValueFactory_Map::mutex_ [private] |
synchronization of the map
Definition at line 85 of file ValueFactory_Map.h.
1.7.0