1
#include "ValueFactory_Map.h"
2
#include "ValueFactory.h"
3
#include "tao/CORBA_String.h"
5
#if !defined (__ACE_INLINE__)
6
# include "ValueFactory_Map.inl"
7
#endif /* ! __ACE_INLINE__ */
11
"ValueFactory_Map.cpp,v 1.3 2003/10/28 18:29:34 bala Exp")
13
TAO_ValueFactory_Map::TAO_ValueFactory_Map (void)
14
: map_ (TAO_DEFAULT_VALUE_FACTORY_TABLE_SIZE)
18
TAO_ValueFactory_Map::~TAO_ValueFactory_Map (void)
20
// Initialize an iterator. We need to go thru each entry and free
21
// up storage allocated to hold the external ids and invoke
22
// _remove_ref () on the internal ids.
23
FACTORY_MAP_MANAGER::ITERATOR iterator (this->map_);
25
for (FACTORY_MAP_MANAGER::ENTRY *entry = 0;
26
iterator.next (entry) != 0;
29
// We had allocated memory and stored the string. So we free the
31
CORBA::string_free ((char *) entry->ext_id_);
33
entry->int_id_->_remove_ref ();
41
TAO_ValueFactory_Map::rebind (const char *repo_id,
42
CORBA::ValueFactory &factory)
44
// ACE_READ_GUARD_RETURN (TAO_SYNCH_RW_MUTEX, guard, map_->mutex(),-1);
45
// --- but must be recursive
46
const char *prev_repo_id;
47
CORBA::ValueFactory prev_factory;
49
ret = this->map_.rebind (CORBA::string_dup (repo_id),
54
if (ret > -1) // ok, no error
56
factory->_add_ref (); // The map owns one reference.
58
if (ret == 1) // there was a previous factory
60
factory = prev_factory;
61
CORBA::string_free (ACE_const_cast(char*,prev_repo_id));
69
TAO_ValueFactory_Map::unbind (const char *repo_id,
70
CORBA::ValueFactory &factory)
72
FACTORY_MAP_MANAGER::ENTRY *prev_entry;
74
ret = this->map_.find (repo_id,
76
if (ret == 0) // there was a matching factory
78
// set factory to the previous factory,
79
factory = prev_entry->int_id_;
80
char *temp = ACE_const_cast (char *, prev_entry->ext_id_);
81
ret = this->map_.unbind (prev_entry);
85
CORBA::string_free (temp);
94
TAO_ValueFactory_Map::find (const char *repo_id,
95
CORBA::ValueFactory &factory)
98
ret = this->map_.find (repo_id,
100
// %! this must be guarded to be atomic !!!!!!!!!!!!!!!!!!
103
factory->_add_ref (); // The caller gets one reference as gift.
109
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
110
template class ACE_Hash_Map_Iterator_Base_Ex<const char *, CORBA::ValueFactoryBase *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, TAO_SYNCH_RW_MUTEX>;
111
template class ACE_Hash_Map_Iterator_Ex<const char *, CORBA::ValueFactoryBase *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, TAO_SYNCH_RW_MUTEX>;
112
template class ACE_Hash_Map_Reverse_Iterator_Ex<const char *, CORBA::ValueFactoryBase *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, TAO_SYNCH_RW_MUTEX>;
113
template class ACE_Hash_Map_Manager_Ex<const char *, CORBA::ValueFactoryBase *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, TAO_SYNCH_RW_MUTEX>;
114
template class ACE_Hash_Map_Entry<const char *, CORBA::ValueFactoryBase *>;
115
template class TAO_Singleton<TAO_ValueFactory_Map, TAO_SYNCH_MUTEX>;
117
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
118
#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<const char *, CORBA::ValueFactoryBase *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, TAO_SYNCH_RW_MUTEX>
119
#pragma instantiate ACE_Hash_Map_Iterator_Ex<const char *, CORBA::ValueFactoryBase *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, TAO_SYNCH_RW_MUTEX>
120
#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<const char *, CORBA::ValueFactoryBase *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, TAO_SYNCH_RW_MUTEX>
121
#pragma instantiate ACE_Hash_Map_Manager_Ex<const char *, CORBA::ValueFactoryBase *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, TAO_SYNCH_RW_MUTEX>
122
#pragma instantiate ACE_Hash_Map_Entry<const char *, CORBA::ValueFactoryBase *>
123
#pragma instantiate TAO_Singleton<TAO_ValueFactory_Map, TAO_SYNCH_MUTEX>
125
#elif defined (__GNUC__) && (defined (_AIX) || defined (__hpux) || defined (VXWORKS))
126
template TAO_Singleton<TAO_ValueFactory_Map, TAO_SYNCH_MUTEX> * TAO_Singleton<TAO_ValueFactory_Map, TAO_SYNCH_MUTEX>::singleton_;
128
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */