Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TAO_ORB_Table Class Reference

Keep a table with all the ORBs in the system. More...

#include <ORB_Table.h>

Collaboration diagram for TAO_ORB_Table:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Hash_Map_Manager_Ex<
const char *, TAO_ORB_Core *,
ACE_Hash< const char * >,
ACE_Equal_To< const char * >,
ACE_Null_Mutex
Table
typedef Table::iterator Iterator

Public Methods

 TAO_ORB_Table (void)
 Constructor. More...

 ~TAO_ORB_Table (void)
 destructor. More...

TAO_ORB_Corefirst_orb (void)
 Obtain the first ORB for the ORB_Core_instance() implementation. More...

void set_default (const char *orb_id)
 Set the ORB related to the orb_id as the default ORB and not the ORB that is first binded. More...

void not_default (const char *orb_id)
 Method the ORB invokes to specify that it doesnt want to be the default ORB if there are more than one ORB registered. More...

Tabletable (void)
 Accessor to the underlying table_. More...

Iterator begin (void)
Iterator end (void)
int bind (const char *orb_id, TAO_ORB_Core *orb_core)
TAO_ORB_Corefind (const char *orb_id)
int unbind (const char *orb_id)
TAO_ORB_Core *const * get_orbs (size_t &num_orbs)

Static Public Methods

TAO_ORB_Table * instance (void)
 Return a unique instance. More...


Private Methods

 TAO_ORB_Table (const TAO_ORB_Table &)
 Prevent copying. More...

void operator= (const TAO_ORB_Table &)
void update_orbs ()
 Update our list of orbs. More...


Private Attributes

CORBA::Boolean first_orb_not_default_
 Variable to check if the first ORB decides not to be the default. More...

Table table_
 The implementation. More...

TAO_ORB_Corefirst_orb_
 The first ORB created by the user. More...

TAO_ORB_Core ** orbs_
 List of orbs for get_orbs call. More...

size_t num_orbs_

Detailed Description

Keep a table with all the ORBs in the system.

CORBA::ORB_init() is supposed to return the same ORB if the user specifies the same ORBid, either in the ORB_init() parameter or in the -ORBid option. This class is used to implement that feature. It is also useful when trying to determine if an object reference is collocated or not.

Note:
This class should be instantiated via its instance() method. Normally this would be enforced by making the constructor protected but that forces a friend declaration containing a template type (TAO_Singleton) with a static member to be introduced. In turn, this potentially introduces problems in MS Windows DLL environments due to the occurance of multiple singleton instances. There should only be one!

Definition at line 55 of file ORB_Table.h.


Member Typedef Documentation

typedef Table::iterator TAO_ORB_Table::Iterator
 

Definition at line 70 of file ORB_Table.h.

Referenced by TAO_ORB_Core::create_object, unbind, and ~TAO_ORB_Table.

typedef ACE_Hash_Map_Manager_Ex<const char *, TAO_ORB_Core *, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex> TAO_ORB_Table::Table
 

Definition at line 69 of file ORB_Table.h.


Constructor & Destructor Documentation

TAO_ORB_Table::TAO_ORB_Table void   
 

Constructor.

Note:
See the note in the class description for an explanation of why this constructor is not protected.

Definition at line 18 of file ORB_Table.cpp.

References TAO_DEFAULT_ORB_TABLE_SIZE.

00019   : first_orb_not_default_ (0),
00020     table_ (TAO_DEFAULT_ORB_TABLE_SIZE),
00021     first_orb_ (0),
00022     orbs_( 0 ),
00023     num_orbs_( 0 )
00024 {
00025 }

TAO_ORB_Table::~TAO_ORB_Table void   
 

destructor.

Definition at line 27 of file ORB_Table.cpp.

References begin, ACE_Hash_Map_Manager_Ex< const char *, TAO_ORB_Core *, ACE_Hash< const char * >, ACE_Equal_To< const char * >, ACE_Null_Mutex >::close, end, Iterator, CORBA::string_free, and table_.

00028 {
00029   for (Iterator i = this->begin ();
00030        i != this->end ();
00031        ++i)
00032     {
00033       // Deallocate the ORBid.
00034       CORBA::string_free (ACE_const_cast (char *, (*i).ext_id_));
00035 
00036       // Destroy the ORB_Core
00037       (void) (*i).int_id_->_decr_refcnt ();
00038     }
00039 
00040   this->table_.close ();
00041 }

TAO_ORB_Table::TAO_ORB_Table const TAO_ORB_Table &    [private]
 

Prevent copying.


Member Function Documentation

TAO_ORB_Table::Iterator TAO_ORB_Table::begin void   
 

Definition at line 44 of file ORB_Table.cpp.

References ACE_Hash_Map_Manager_Ex< const char *, TAO_ORB_Core *, ACE_Hash< const char * >, ACE_Equal_To< const char * >, ACE_Null_Mutex >::begin, and table_.

Referenced by TAO_ORB_Core::create_object, unbind, and ~TAO_ORB_Table.

00045 {
00046   return this->table_.begin ();
00047 }

int TAO_ORB_Table::bind const char *    orb_id,
TAO_ORB_Core   orb_core
 

Definition at line 63 of file ORB_Table.cpp.

References TAO_ORB_Core::_incr_refcnt, ACE_Hash_Map_Manager_Ex< const char *, TAO_ORB_Core *, ACE_Hash< const char * >, ACE_Equal_To< const char * >, ACE_Null_Mutex >::bind, ACE_Hash_Map_Manager_Ex< const char *, TAO_ORB_Core *, ACE_Hash< const char * >, ACE_Equal_To< const char * >, ACE_Null_Mutex >::current_size, first_orb_, first_orb_not_default_, CORBA::string_dup, and table_.

00065 {
00066   // Make sure that the supplied ORB core pointer is valid,
00067   // i.e. non-zero.
00068   if (orb_id == 0 || orb_core == 0)
00069     {
00070       errno = EINVAL;
00071       return -1;
00072     };
00073 
00074   CORBA::String_var id = CORBA::string_dup (orb_id);
00075 
00076   int result = this->table_.bind (id.in (), orb_core);
00077   if (result == 0)
00078     {
00079       // Make sure the ORB table owns the ORB Core by increasing the
00080       // reference count on it.
00081       (void) orb_core->_incr_refcnt ();
00082 
00083       // This is not the first ORB .. but the first ORB registered
00084       // decided not be the default if there are more than one
00085       // orb... then set the second ORB that is registered as the
00086       // default ORB.
00087       if ((this->first_orb_ != 0)
00088           && (this->first_orb_not_default_)
00089           && this->table_.current_size () == 2)
00090         {
00091           this->first_orb_ = orb_core;
00092         }
00093 
00094       // Only set the "first_orb_" member if the given ORB Core was
00095       // successfully added to the ORB table.
00096       if (this->first_orb_ == 0)
00097         this->first_orb_ = orb_core;
00098 
00099       (void) id._retn ();  // ORB Table now owns the id.
00100     }
00101 
00102   return result;
00103 }

TAO_ORB_Table::Iterator TAO_ORB_Table::end void   
 

Definition at line 50 of file ORB_Table.cpp.

References ACE_Hash_Map_Manager_Ex< const char *, TAO_ORB_Core *, ACE_Hash< const char * >, ACE_Equal_To< const char * >, ACE_Null_Mutex >::end, and table_.

Referenced by TAO_ORB_Core::create_object, unbind, and ~TAO_ORB_Table.

00051 {
00052   return this->table_.end ();
00053 }

TAO_ORB_Core * TAO_ORB_Table::find const char *    orb_id
 

Definition at line 106 of file ORB_Table.cpp.

References ACE_Hash_Map_Manager_Ex< const char *, TAO_ORB_Core *, ACE_Hash< const char * >, ACE_Equal_To< const char * >, ACE_Null_Mutex >::find, and table_.

00107 {
00108   TAO_ORB_Core *found = 0;
00109 
00110   this->table_.find (orb_id, found);
00111 
00112   return found;
00113 }

ACE_INLINE TAO_ORB_Core * TAO_ORB_Table::first_orb void   
 

Obtain the first ORB for the ORB_Core_instance() implementation.

Definition at line 6 of file ORB_Table.inl.

References first_orb_.

Referenced by TAO_ORB_Core_instance.

00007 {
00008   return this->first_orb_;
00009 }

TAO_ORB_Core *const * TAO_ORB_Table::get_orbs size_t &    num_orbs
 

Definition at line 56 of file ORB_Table.cpp.

References num_orbs_, and orbs_.

00057 {
00058   num_orbs = this->num_orbs_;
00059   return this->orbs_;
00060 }

TAO_ORB_Table * TAO_ORB_Table::instance void    [static]
 

Return a unique instance.

Definition at line 192 of file ORB_Table.cpp.

References TAO_Singleton::instance.

Referenced by TAO_ORB_Core::create_object, TAO_ORB_Core::destroy, TAO_ORB_Core::not_default, TAO_ORB_Core::set_default, and TAO_ORB_Core_instance.

void TAO_ORB_Table::not_default const char *    orb_id
 

Method the ORB invokes to specify that it doesnt want to be the default ORB if there are more than one ORB registered.

Definition at line 158 of file ORB_Table.cpp.

References first_orb_, first_orb_not_default_, and ACE_OS_String::strcmp.

Referenced by TAO_ORB_Core::not_default.

00159 {
00160   // @@  This method now works for restricted cases. Should work on
00161   // generalizing it. It works if the first ORB that is registered
00162   // decides to not want be the default ORB. Should generalize it to
00163   // handle all cases.
00164 
00165   //check if there is a default ORB already and if
00166   // it is *not* the same as the orb_id thats passed in.. we dont have
00167   // to do anything.
00168   if (this->first_orb_ != 0)
00169     {
00170       if (ACE_OS::strcmp (this->first_orb_->orbid (), orb_id) != 0)
00171         {
00172           // There is another default ORB. No need to change anything
00173           return;
00174         }
00175       else
00176         {
00177           // The ORB with orbid 'orb_id' is the default now. We need
00178           // to change it.
00179           this->first_orb_not_default_ = 1;
00180         }
00181     }
00182 }

void TAO_ORB_Table::operator= const TAO_ORB_Table &    [private]
 

void TAO_ORB_Table::set_default const char *    orb_id
 

Set the ORB related to the orb_id as the default ORB and not the ORB that is first binded.

Definition at line 152 of file ORB_Table.cpp.

References ACE_Hash_Map_Manager_Ex< const char *, TAO_ORB_Core *, ACE_Hash< const char * >, ACE_Equal_To< const char * >, ACE_Null_Mutex >::find, and table_.

Referenced by TAO_ORB_Core::set_default.

00153 {
00154   this->table_.find (orb_id, this->first_orb_);
00155 }

ACE_Hash_Map_Manager_Ex< const char *, TAO_ORB_Core *, ACE_Hash< const char * >, ACE_Equal_To< const char * >, ACE_Null_Mutex > * TAO_ORB_Table::table void   
 

Accessor to the underlying table_.

Definition at line 186 of file ORB_Table.cpp.

References table_.

00187 {
00188   return &this->table_;
00189 }

int TAO_ORB_Table::unbind const char *    orb_id
 

Definition at line 116 of file ORB_Table.cpp.

References TAO_ORB_Core::_decr_refcnt, begin, end, ACE_Hash_Map_Manager_Ex< const char *, TAO_ORB_Core *, ACE_Hash< const char * >, ACE_Equal_To< const char * >, ACE_Null_Mutex >::find, first_orb_, Iterator, CORBA::string_free, table_, and ACE_Hash_Map_Manager_Ex< const char *, TAO_ORB_Core *, ACE_Hash< const char * >, ACE_Equal_To< const char * >, ACE_Null_Mutex >::unbind.

Referenced by TAO_ORB_Core::destroy.

00117 {
00118   Table::ENTRY *entry = 0;
00119 
00120   int result = this->table_.find (orb_id, entry);
00121 
00122   if (result == 0)
00123     {
00124       // Deallocate the external ID and obtain the ORB core pointer
00125       // before unbinding the entry since the entry is deallocated
00126       // during the call to unbind().
00127       CORBA::string_free (ACE_const_cast (char *, entry->ext_id_));
00128       TAO_ORB_Core *orb_core = entry->int_id_;
00129 
00130       result = this->table_.unbind (entry);
00131 
00132       if (result != 0)
00133         return result;
00134 
00135       if (orb_core == this->first_orb_)
00136         {
00137           Iterator begin = this->begin ();
00138           Iterator end = this->end ();
00139           if (begin != end)
00140             this->first_orb_ = (*begin).int_id_;
00141           else
00142             this->first_orb_ = 0;
00143         }
00144 
00145       orb_core->_decr_refcnt ();
00146     }
00147 
00148   return result;
00149 }

void TAO_ORB_Table::update_orbs   [private]
 

Update our list of orbs.


Member Data Documentation

TAO_ORB_Core* TAO_ORB_Table::first_orb_ [private]
 

The first ORB created by the user.

Definition at line 117 of file ORB_Table.h.

Referenced by bind, first_orb, not_default, and unbind.

CORBA::Boolean TAO_ORB_Table::first_orb_not_default_ [private]
 

Variable to check if the first ORB decides not to be the default.

Definition at line 111 of file ORB_Table.h.

Referenced by bind, and not_default.

size_t TAO_ORB_Table::num_orbs_ [private]
 

Definition at line 121 of file ORB_Table.h.

Referenced by get_orbs.

TAO_ORB_Core** TAO_ORB_Table::orbs_ [private]
 

List of orbs for get_orbs call.

Definition at line 120 of file ORB_Table.h.

Referenced by get_orbs.

Table TAO_ORB_Table::table_ [private]
 

The implementation.

Definition at line 114 of file ORB_Table.h.

Referenced by begin, bind, end, find, set_default, table, unbind, and ~TAO_ORB_Table.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:32:03 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002