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

TAO_Object_Ref_Table Class Reference

Keep a table de-stringified object references registered with the ORB. More...

#include <Object_Ref_Table.h>

Collaboration diagram for TAO_Object_Ref_Table:
Collaboration graph
[legend]

List of all members.

Public Types

typedef ACE_Array_Map
< CORBA::String_var,
CORBA::Object_var,
TAO::String_Var_Equal_To > 
Table
typedef Table::iterator iterator

Public Member Functions

 TAO_Object_Ref_Table (void)
 Constructor.
int register_initial_reference (const char *id, CORBA::Object_ptr obj, bool rebind=false)
CORBA::Object_ptr unregister_initial_reference (const char *id)
CORBA::Object_ptr resolve_initial_reference (const char *id)
void destroy (void)
 Explicitly destroy the contents of the object reference table.
size_t current_size (void) const
 Return the current size of the underlying table.
Forward Iterators

iterator begin (void)
iterator end (void)

Private Member Functions

 TAO_Object_Ref_Table (const TAO_Object_Ref_Table &)
void operator= (const TAO_Object_Ref_Table &)
The canonical ACE_Map methods

int bind_i (const char *orb_id, CORBA::Object_ptr obj)
CORBA::Object_ptr find_i (const char *orb_id)
int unbind_i (const char *orb_id)

Private Attributes

Table table_
 The implementation.
TAO_SYNCH_MUTEX lock_
 Table synchronization lock.

Detailed Description

Keep a table de-stringified object references registered with the ORB.

The class is necessary to allow local objects to be accessible via the resolve_initial_references() mechanism. Since local object references cannot be stringified, they cannot be placed into the initial reference map that maps object key/name to stringified object reference. Hence, another table is needed.

Note:
The stringified reference table is still needed since it is sometimes necessary to delay de-stringification of an IOR until it is needed. For example, "corbaname" may return different results on each use.

Definition at line 51 of file Object_Ref_Table.h.


Member Typedef Documentation

Definition at line 59 of file Object_Ref_Table.h.

Definition at line 57 of file Object_Ref_Table.h.


Constructor & Destructor Documentation

TAO_Object_Ref_Table::TAO_Object_Ref_Table ( void   ) 

Constructor.

Definition at line 8 of file Object_Ref_Table.inl.

TAO_Object_Ref_Table::TAO_Object_Ref_Table ( const TAO_Object_Ref_Table  )  [private]

Member Function Documentation

TAO_Object_Ref_Table::iterator TAO_Object_Ref_Table::begin ( void   ) 

Definition at line 39 of file Object_Ref_Table.inl.

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

int TAO_Object_Ref_Table::bind_i ( const char *  orb_id,
CORBA::Object_ptr  obj 
) [private]

Definition at line 73 of file Object_Ref_Table.cpp.

{
  // Make sure that the supplied Object reference is valid,
  // i.e. not nil.
  if (id == 0
      || ACE_OS::strlen (id) == 0
      || ::CORBA::is_nil (obj))
    {
      errno = EINVAL;
      return -1;
    };

  Table::value_type const value =
    std::make_pair (CORBA::String_var (id),
                    CORBA::Object_var (CORBA::Object::_duplicate (obj)));

  std::pair<iterator, bool> const result = this->table_.insert (value);

  if (!result.second)
    {
      if (TAO_debug_level > 1)
        {
          ACE_ERROR ((LM_ERROR,
                      ACE_TEXT ("(%P|%t) Object_Ref_Table::bind_i: ")
                      ACE_TEXT ("Could not register duplicate object <%C> ")
                      ACE_TEXT ("with the ORB\n"),
                      id));
        }

      return -1;
    }

  return 0;
}

size_t TAO_Object_Ref_Table::current_size ( void   )  const

Return the current size of the underlying table.

Definition at line 51 of file Object_Ref_Table.inl.

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

void TAO_Object_Ref_Table::destroy ( void   ) 

Explicitly destroy the contents of the object reference table.

Definition at line 27 of file Object_Ref_Table.inl.

{
  Table tmp;

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

  this->table_.swap (tmp);  // Force release of memory held by our table.
}

TAO_Object_Ref_Table::iterator TAO_Object_Ref_Table::end ( void   ) 

Definition at line 45 of file Object_Ref_Table.inl.

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

CORBA::Object_ptr TAO_Object_Ref_Table::find_i ( const char *  orb_id  )  [private]

Definition at line 15 of file Object_Ref_Table.inl.

{
  iterator const found =
    this->table_.find (CORBA::String_var (id));

  if (found == this->table_.end ())
    return CORBA::Object::_nil ();

  return CORBA::Object::_duplicate ((*found).second.in ());
}

void TAO_Object_Ref_Table::operator= ( const TAO_Object_Ref_Table  )  [private]
int TAO_Object_Ref_Table::register_initial_reference ( const char *  id,
CORBA::Object_ptr  obj,
bool  rebind = false 
)

Register an object reference with the table, and map the given ID to it.

Return values:
0 Success
-1 Duplicate id if rebind is false

Definition at line 26 of file Object_Ref_Table.cpp.

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

  if (rebind)
    {
      if (this->unbind_i (id) == -1)
        return -1;
      else
        return this->bind_i (id, obj);
    }
  else
    return this->bind_i (id, obj);
}

CORBA::Object_ptr TAO_Object_Ref_Table::resolve_initial_reference ( const char *  id  ) 

Return the object reference associated with the given ID. A duplicate is returned.

Definition at line 109 of file Object_Ref_Table.cpp.

{
  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
                    guard,
                    this->lock_,
                    CORBA::Object::_nil ());

  return this->find_i (id);  // Returns a duplicate.
}

int TAO_Object_Ref_Table::unbind_i ( const char *  orb_id  )  [private]

Definition at line 57 of file Object_Ref_Table.inl.

{
  return
    (this->table_.erase (CORBA::String_var (id)) == 0 ? -1 : 0);
}

CORBA::Object_ptr TAO_Object_Ref_Table::unregister_initial_reference ( const char *  id  ) 

Unregister an object reference with the table

Definition at line 48 of file Object_Ref_Table.cpp.

{
  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
                    guard,
                    this->lock_,
                    CORBA::Object::_nil());

  CORBA::Object_ptr obj = this->find_i (id);
  if (this->unbind_i (id) == -1)
    {
      if (TAO_debug_level > 1)
        {
          ACE_ERROR ((LM_ERROR,
                      ACE_TEXT ("(%P|%t) Object_Ref_Table::bind_i: ")
                      ACE_TEXT ("Could not unregister object <%C> ")
                      ACE_TEXT ("from the ORB\n"),
                      id));
        }
    }

  return obj;
}


Member Data Documentation

TAO_SYNCH_MUTEX TAO_Object_Ref_Table::lock_ [private]

Table synchronization lock.

Definition at line 120 of file Object_Ref_Table.h.

The implementation.

Definition at line 117 of file Object_Ref_Table.h.


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