IOR_Table_Impl.cpp

Go to the documentation of this file.
00001 /**
00002  * @file IOR_Table_Impl.cpp
00003  *
00004  * IOR_Table_Impl.cpp,v 1.11 2006/03/10 07:19:11 jtc Exp
00005  *
00006  * @author Carlos O'Ryan <coryan@uci.edu>
00007  *
00008  */
00009 
00010 #include "tao/IORTable/IOR_Table_Impl.h"
00011 #include "ace/Guard_T.h"
00012 
00013 ACE_RCSID (IORTable,
00014            IOR_Table_Impl,
00015            "IOR_Table_Impl.cpp,v 1.11 2006/03/10 07:19:11 jtc Exp")
00016 
00017 
00018 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00019 
00020 TAO_IOR_Table_Impl::TAO_IOR_Table_Impl (void)
00021 {
00022 }
00023 
00024 char *
00025 TAO_IOR_Table_Impl::find (const char *object_key
00026                           ACE_ENV_ARG_DECL)
00027       ACE_THROW_SPEC ((
00028         CORBA::SystemException,
00029         IORTable::NotFound
00030       ))
00031 {
00032   // We don't want the lock held during locate, so make it go out
00033   // of scope before then.
00034   {
00035     ACE_CString key (object_key);
00036     ACE_CString ior;
00037 
00038     ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
00039     if (this->map_.find (key, ior) == 0)
00040       {
00041         return CORBA::string_dup (ior.c_str ());
00042       }
00043     if (CORBA::is_nil (this->locator_.in ()))
00044       ACE_THROW_RETURN (IORTable::NotFound (), 0);
00045   }
00046 
00047   return this->locator_->locate (object_key ACE_ENV_ARG_PARAMETER);
00048 }
00049 
00050 void
00051 TAO_IOR_Table_Impl::bind (
00052         const char * object_key,
00053         const char * IOR
00054         ACE_ENV_ARG_DECL
00055       )
00056       ACE_THROW_SPEC ((
00057         CORBA::SystemException,
00058         IORTable::AlreadyBound
00059       ))
00060 {
00061   ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_);
00062   if (this->map_.bind (object_key, IOR) != 0)
00063     ACE_THROW (IORTable::AlreadyBound ());
00064 }
00065 
00066 void
00067 TAO_IOR_Table_Impl::rebind (
00068         const char * object_key,
00069         const char * IOR
00070         ACE_ENV_ARG_DECL_NOT_USED
00071       )
00072       ACE_THROW_SPEC ((
00073         CORBA::SystemException
00074       ))
00075 {
00076   ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_);
00077   this->map_.rebind (object_key, IOR);
00078 }
00079 
00080 void
00081 TAO_IOR_Table_Impl::unbind (
00082         const char * object_key
00083         ACE_ENV_ARG_DECL
00084       )
00085       ACE_THROW_SPEC ((
00086         CORBA::SystemException,
00087         IORTable::NotFound
00088       ))
00089 {
00090   ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_);
00091   if (this->map_.unbind (object_key) != 0)
00092     ACE_THROW (IORTable::NotFound ());
00093 }
00094 
00095 void
00096 TAO_IOR_Table_Impl::set_locator (
00097         IORTable::Locator_ptr locator
00098         ACE_ENV_ARG_DECL_NOT_USED
00099       )
00100       ACE_THROW_SPEC ((
00101         CORBA::SystemException
00102       ))
00103 {
00104   ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_);
00105   this->locator_ = IORTable::Locator::_duplicate (locator);
00106 }
00107 
00108 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 13:07:06 2006 for TAO_IORTable by doxygen 1.3.6