Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tao / IORTable / IOR_Table_Impl.cpp
blob8137e5d1eb7d5905145fef22630d369253cd6adb
1 /**
2 * @file IOR_Table_Impl.cpp
4 * @author Carlos O'Ryan <coryan@uci.edu>
5 */
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))
18 p->_add_ref ();
21 return p;
24 void
25 TAO::Objref_Traits <TAO_IOR_Table_Impl>::release (TAO_IOR_Table_Impl_ptr p)
27 ::CORBA::release (p);
30 TAO_IOR_Table_Impl_ptr
31 TAO::Objref_Traits <TAO_IOR_Table_Impl>::nil ()
33 return TAO_IOR_Table_Impl::_nil ();
36 ::CORBA::Boolean
37 TAO::Objref_Traits <TAO_IOR_Table_Impl>::marshal (const TAO_IOR_Table_Impl_ptr,
38 TAO_OutputCDR &)
40 return false;
43 TAO_IOR_Table_Impl::TAO_IOR_Table_Impl ()
47 char *
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);
54 ACE_CString ior;
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);
68 void
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 ();
76 void
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);
83 void
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 ();
91 void
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