2 * @file IOR_Table_Impl.cpp
4 * @author Carlos O'Ryan <coryan@uci.edu>
7 #include "tao/IORTable/IOR_Table_Impl.h"
8 #include "tao/PortableServer/ForwardRequestC.h"
9 #include "ace/Guard_T.h"
11 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
13 TAO_IOR_Table_Impl_ptr
14 TAO::Objref_Traits
<TAO_IOR_Table_Impl
>::duplicate (TAO_IOR_Table_Impl_ptr p
)
16 if (!::CORBA::is_nil (p
))
25 TAO::Objref_Traits
<TAO_IOR_Table_Impl
>::release (TAO_IOR_Table_Impl_ptr p
)
30 TAO_IOR_Table_Impl_ptr
31 TAO::Objref_Traits
<TAO_IOR_Table_Impl
>::nil ()
33 return TAO_IOR_Table_Impl::_nil ();
37 TAO::Objref_Traits
<TAO_IOR_Table_Impl
>::marshal (const TAO_IOR_Table_Impl_ptr
,
43 TAO_IOR_Table_Impl::TAO_IOR_Table_Impl ()
48 TAO_IOR_Table_Impl::find (const char *object_key
)
50 // We don't want the lock held during locate, so make it go out
51 // of scope before then.
53 ACE_CString
key (object_key
);
56 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX
, ace_mon
, this->lock_
, 0);
57 if (this->map_
.find (key
, ior
) == 0)
59 return CORBA::string_dup (ior
.c_str ());
61 if (CORBA::is_nil (this->locator_
.in ()))
62 throw IORTable::NotFound ();
65 return this->locator_
->locate (object_key
);
69 TAO_IOR_Table_Impl::bind (const char * object_key
, const char * IOR
)
71 ACE_GUARD (TAO_SYNCH_MUTEX
, ace_mon
, this->lock_
);
72 if (this->map_
.bind (object_key
, IOR
) != 0)
73 throw IORTable::AlreadyBound ();
77 TAO_IOR_Table_Impl::rebind (const char * object_key
, const char * IOR
)
79 ACE_GUARD (TAO_SYNCH_MUTEX
, ace_mon
, this->lock_
);
80 this->map_
.rebind (object_key
, IOR
);
84 TAO_IOR_Table_Impl::unbind (const char * object_key
)
86 ACE_GUARD (TAO_SYNCH_MUTEX
, ace_mon
, this->lock_
);
87 if (this->map_
.unbind (object_key
) != 0)
88 throw IORTable::NotFound ();
92 TAO_IOR_Table_Impl::set_locator (IORTable::Locator_ptr locator
)
94 ACE_GUARD (TAO_SYNCH_MUTEX
, ace_mon
, this->lock_
);
95 this->locator_
= IORTable::Locator::_duplicate (locator
);
98 TAO_END_VERSIONED_NAMESPACE_DECL