Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes

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_Array_Map
< CORBA::String_var,
ORB_Core_Ref_Counter,
TAO::String_Var_Equal_To > 
Table
typedef Table::key_type key_type
typedef Table::data_type data_type
typedef Table::value_type value_type
typedef Table::size_type size_type
typedef Table::iterator iterator

Public Member Functions

 ORB_Table (void)
 Constructor.
::TAO_ORB_Corefirst_orb (void)
void set_default (char const *orb_id)
void not_default (char const *orb_id)
Tabletable (void)
 Accessor to the underlying table_.
TAO_SYNCH_MUTEX & lock (void)
 Return reference to underlying lock.
The canonical ACE_Map methods.

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)

Static Public Member Functions

static ORB_Tableinstance (void)
 Return a unique instance.

Private Member Functions

 ORB_Table (const ORB_Table &)
void operator= (const ORB_Table &)
::TAO_ORB_Corefind_i (char const *orb_id)

Private Attributes

::TAO_SYNCH_MUTEX lock_
 Lock used to synchronize access to the internal state.
bool first_orb_not_default_
Table table_
 The underlying table.
::TAO_ORB_Corefirst_orb_
 The first ORB created by the user.

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 63 of file ORB_Table.h.


Member Typedef Documentation

typedef Table::data_type TAO::ORB_Table::data_type

Definition at line 78 of file ORB_Table.h.

typedef Table::iterator TAO::ORB_Table::iterator

Definition at line 81 of file ORB_Table.h.

typedef Table::key_type TAO::ORB_Table::key_type

Definition at line 77 of file ORB_Table.h.

typedef Table::size_type TAO::ORB_Table::size_type

Definition at line 80 of file ORB_Table.h.

typedef ACE_Array_Map<CORBA::String_var, ORB_Core_Ref_Counter, TAO::String_Var_Equal_To> TAO::ORB_Table::Table

Definition at line 76 of file ORB_Table.h.

typedef Table::value_type TAO::ORB_Table::value_type

Definition at line 79 of file ORB_Table.h.


Constructor & Destructor Documentation

TAO::ORB_Table::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 22 of file ORB_Table.cpp.

TAO::ORB_Table::ORB_Table ( const ORB_Table  )  [private]

Member Function Documentation

TAO::ORB_Table::iterator TAO::ORB_Table::begin ( void   ) 

Return TAO_ORB_Core corresponding to ORB with given orb_id.

Note:
The caller must decrease the reference count on the returned ORB_Core, i.e. the callers "owns" it.

Definition at line 18 of file ORB_Table.inl.

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

int TAO::ORB_Table::bind ( const char *  orb_id,
::TAO_ORB_Core orb_core 
)

Return TAO_ORB_Core corresponding to ORB with given orb_id.

Note:
The caller must decrease the reference count on the returned ORB_Core, i.e. the callers "owns" it.
TAO::ORB_Table::iterator TAO::ORB_Table::end ( void   ) 

Return TAO_ORB_Core corresponding to ORB with given orb_id.

Note:
The caller must decrease the reference count on the returned ORB_Core, i.e. the callers "owns" it.

Definition at line 24 of file ORB_Table.inl.

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

TAO_ORB_Core * TAO::ORB_Table::find ( const char *  orb_id  ) 

Return TAO_ORB_Core corresponding to ORB with given orb_id.

Note:
The caller must decrease the reference count on the returned ORB_Core, i.e. the callers "owns" it.

Definition at line 76 of file ORB_Table.cpp.

{
  TAO_ORB_Core * orb_core = 0;

  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
                    guard,
                    this->lock_,
                    0);

  iterator const i = this->table_.find (Table::key_type (orb_id));

  // Maintain ownership of the ORB_Core.
  if (i != this->end ())
    {
      orb_core = (*i).second.core ();
      (void) orb_core->_incr_refcnt ();
    }

  return orb_core;
}

::TAO_ORB_Core* TAO::ORB_Table::find_i ( char const *  orb_id  )  [private]

Return TAO_ORB_Core corresponding to ORB with given orb_id. (underlying unlocked implementation).

TAO_ORB_Core * TAO::ORB_Table::first_orb ( void   ) 

Obtain the first ORB for the ORB_Core_instance() implementation.

Definition at line 12 of file ORB_Table.inl.

{
  return this->first_orb_;
}

TAO::ORB_Table * TAO::ORB_Table::instance ( void   )  [static]

Return a unique instance.

Definition at line 173 of file ORB_Table.cpp.

TAO_SYNCH_MUTEX & TAO::ORB_Table::lock ( void   ) 

Return reference to underlying lock.

Definition at line 37 of file ORB_Table.inl.

{
  return this->lock_;
}

void TAO::ORB_Table::not_default ( char const *  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 143 of file ORB_Table.cpp.

{
  // @@  This method now works for restricted cases. Should work on
  //     generalizing it. It works if the first ORB that is registered
  //     decides to not want be the default ORB. Should generalize it
  //     to handle all cases.
  ACE_GUARD (TAO_SYNCH_MUTEX,
             guard,
             this->lock_);

  // Check if there is a default ORB already and if it is *not* the
  // same as the orb_id thats passed in.  We don't have to do
  // anything.
  if (this->first_orb_ != 0)
    {
      if (ACE_OS::strcmp (this->first_orb_->orbid (), orb_id) != 0)
        {
          // There is another default ORB. No need to change anything
          return;
        }
      else
        {
          // The ORB with orbid 'orb_id' is the default now. We need
          // to change it.
          this->first_orb_not_default_ = true;
        }
    }
}

void TAO::ORB_Table::operator= ( const ORB_Table  )  [private]
void TAO::ORB_Table::set_default ( char const *  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 130 of file ORB_Table.cpp.

{
  ACE_GUARD (TAO_SYNCH_MUTEX,
             guard,
             this->lock_);

  iterator const i = this->table_.find (key_type (orb_id));

  if (i != this->end ())
    this->first_orb_ = (*i).second.core ();
}

TAO::ORB_Table::Table * TAO::ORB_Table::table ( void   ) 

Accessor to the underlying table_.

Definition at line 31 of file ORB_Table.inl.

{
  return &this->table_;
}

int TAO::ORB_Table::unbind ( const char *  orb_id  ) 

Return TAO_ORB_Core corresponding to ORB with given orb_id.

Note:
The caller must decrease the reference count on the returned ORB_Core, i.e. the callers "owns" it.

Definition at line 98 of file ORB_Table.cpp.

{
  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
                    guard,
                    this->lock_,
                    -1);

  iterator const result = this->table_.find (key_type (orb_id));

  if (result != this->end ())
    {
      TAO::ORB_Core_Ref_Counter oc ((*result).second);

      this->table_.erase (result);

      if (oc.core () == this->first_orb_)
        {
          if (!this->table_.empty ())
            {
              this->first_orb_ = (*this->begin ()).second.core ();
            }
          else
            {
              this->first_orb_ = 0;
            }
        }
    }

  return 0;
}


Member Data Documentation

::TAO_ORB_Core* TAO::ORB_Table::first_orb_ [private]

The first ORB created by the user.

Definition at line 146 of file ORB_Table.h.

bool TAO::ORB_Table::first_orb_not_default_ [private]

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

Definition at line 140 of file ORB_Table.h.

::TAO_SYNCH_MUTEX TAO::ORB_Table::lock_ [private]

Lock used to synchronize access to the internal state.

Definition at line 136 of file ORB_Table.h.

Table TAO::ORB_Table::table_ [private]

The underlying table.

Definition at line 143 of file ORB_Table.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines