Public Member Functions | Private Types | Private Attributes

TAO::PG_Group_Factory Class Reference

#include <PG_Group_Factory.h>

Collaboration diagram for TAO::PG_Group_Factory:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PG_Group_Factory ()
 Constructor.
 ~PG_Group_Factory ()
 Destructor.
void init (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableGroup::FactoryRegistry_ptr factory_registry)
TAO::PG_Object_Group * create_group (const char *type_id, const PortableGroup::Criteria &the_criteria, TAO::PG_Property_Set *typeid_properties)
void delete_group (PortableGroup::ObjectGroup_ptr object_group)
void delete_group (PortableGroup::ObjectGroupId group_id)
PortableGroup::ObjectGroupsgroups_at_location (const PortableGroup::Location &the_location)
int insert_group (::TAO::PG_Object_Group *group)
int insert_group (PortableGroup::ObjectGroupId group_id,::TAO::PG_Object_Group *group)
int find_group (PortableGroup::ObjectGroupId group_id,::TAO::PG_Object_Group *&group) const
int find_group (PortableGroup::ObjectGroup_ptr object_group,::TAO::PG_Object_Group *&group) const
int destroy_group (PortableGroup::ObjectGroupId object_group_id)
int destroy_group (PortableGroup::ObjectGroup_ptr object_group)

Private Types

typedef
ACE_Hash_Map_Manager_Ex
< PortableGroup::ObjectGroupId,::TAO::PG_Object_Group
*, ACE_Hash< ACE_UINT64 >
, ACE_Equal_To< ACE_UINT64 >
, TAO_SYNCH_MUTEX > 
Group_Map
typedef ACE_Hash_Map_Entry
< PortableGroup::ObjectGroupId,::TAO::PG_Object_Group * > 
Group_Map_Entry
typedef
ACE_Hash_Map_Iterator_Ex
< PortableGroup::ObjectGroupId,::TAO::PG_Object_Group
*, ACE_Hash< ACE_UINT64 >
, ACE_Equal_To< ACE_UINT64 >
, TAO_SYNCH_MUTEX > 
Group_Map_Iterator

Private Attributes

CORBA::ORB_var orb_
PortableServer::POA_var poa_
 Reference to the POA used to create object group references.
PortableGroup::FactoryRegistry_var factory_registry_
 The factory registry for replica factories.
::TAO::PG_Object_Group_Manipulator manipulator_
const char * domain_id_
Group_Map group_map_

Detailed Description

class PG_Group_Factory

Definition at line 52 of file PG_Group_Factory.h.


Member Typedef Documentation

typedef ACE_Hash_Map_Manager_Ex< PortableGroup::ObjectGroupId, ::TAO::PG_Object_Group *, ACE_Hash<ACE_UINT64>, ACE_Equal_To<ACE_UINT64>, TAO_SYNCH_MUTEX> TAO::PG_Group_Factory::Group_Map [private]

Definition at line 61 of file PG_Group_Factory.h.

typedef ACE_Hash_Map_Entry<PortableGroup::ObjectGroupId, ::TAO::PG_Object_Group *> TAO::PG_Group_Factory::Group_Map_Entry [private]

Definition at line 63 of file PG_Group_Factory.h.

typedef ACE_Hash_Map_Iterator_Ex< PortableGroup::ObjectGroupId, ::TAO::PG_Object_Group *, ACE_Hash<ACE_UINT64>, ACE_Equal_To<ACE_UINT64>, TAO_SYNCH_MUTEX> TAO::PG_Group_Factory::Group_Map_Iterator [private]

Definition at line 70 of file PG_Group_Factory.h.


Constructor & Destructor Documentation

TAO::PG_Group_Factory::PG_Group_Factory (  ) 

Constructor.

Definition at line 27 of file PG_Group_Factory.cpp.

  : orb_ (CORBA::ORB::_nil())
  , poa_ (PortableServer::POA::_nil())
  , manipulator_ ()
  , domain_id_ ("default-domain")

{
}

TAO::PG_Group_Factory::~PG_Group_Factory ( void   ) 

Destructor.

Definition at line 36 of file PG_Group_Factory.cpp.

{
  for (Group_Map_Iterator it = this->group_map_.begin ();
    it != this->group_map_.end ();
    ++it)
  {
    TAO::PG_Object_Group * group = (*it).int_id_;
    delete group;
  }
  this->group_map_.unbind_all ();
}


Member Function Documentation

TAO::PG_Object_Group * TAO::PG_Group_Factory::create_group ( const char *  type_id,
const PortableGroup::Criteria the_criteria,
TAO::PG_Property_Set *  typeid_properties 
)

Definition at line 71 of file PG_Group_Factory.cpp.

{
  ///////////////////////////////////
  // Create an empty group reference

  PortableGroup::ObjectGroupId group_id = 0;
  PortableGroup::ObjectGroup_var empty_group =
    this->manipulator_.create_object_group (
      type_id,
      this->domain_id_,
      group_id);

  // pick up the object group information as assigned by
  // ObjectGroupManager

  PortableGroup::TagGroupTaggedComponent tagged_component;
  if (! TAO::PG_Utils::get_tagged_component (empty_group, tagged_component))
  {
    throw PortableGroup::ObjectNotCreated();
  }

  TAO::PG_Object_Group * objectGroup = 0;

  ACE_NEW_THROW_EX (
    objectGroup,
    TAO::PG_Object_Group (
      this->orb_.in (),
      this->factory_registry_.in (),
      this->manipulator_,
      empty_group.in (),
      tagged_component,
      type_id,
      the_criteria,
      typeid_properties
      ),
    CORBA::NO_MEMORY());

  if (this->group_map_.bind (group_id, objectGroup) != 0)
  {
    delete objectGroup;
    throw PortableGroup::ObjectNotCreated();
  }
  return objectGroup;
}

void TAO::PG_Group_Factory::delete_group ( PortableGroup::ObjectGroupId  group_id  ) 

Definition at line 128 of file PG_Group_Factory.cpp.

{
  if (! destroy_group (group_id))
  {
    throw PortableGroup::ObjectNotFound ();
  }
}

void TAO::PG_Group_Factory::delete_group ( PortableGroup::ObjectGroup_ptr  object_group  ) 

Definition at line 119 of file PG_Group_Factory.cpp.

{
  if (! destroy_group (object_group))
  {
    throw PortableGroup::ObjectNotFound ();
  }
}

int TAO::PG_Group_Factory::destroy_group ( PortableGroup::ObjectGroup_ptr  object_group  ) 

remove group from map and delete it. note: uses group id extracted from object_group

Returns:
bool true if found

Definition at line 174 of file PG_Group_Factory.cpp.

{
  PortableGroup::TagGroupTaggedComponent tc;
  TAO::PG_Utils::get_tagged_component (object_group, tc);
  return destroy_group (tc.object_group_id);
}

int TAO::PG_Group_Factory::destroy_group ( PortableGroup::ObjectGroupId  object_group_id  ) 

remove group from map and delete it.

Returns:
bool true if found

Definition at line 163 of file PG_Group_Factory.cpp.

{
  ::TAO::PG_Object_Group * group = 0;
  int result = (this->group_map_.unbind (group_id, group) == 0);
  if (result)
  {
    delete group;
  }
  return result;
}

int TAO::PG_Group_Factory::find_group ( PortableGroup::ObjectGroupId  group_id,
::TAO::PG_Object_Group *&  group 
) const

find group

Returns:
bool true if found

Definition at line 147 of file PG_Group_Factory.cpp.

{
  return (this->group_map_.find (group_id , group) == 0);
}

int TAO::PG_Group_Factory::find_group ( PortableGroup::ObjectGroup_ptr  object_group,
::TAO::PG_Object_Group *&  group 
) const

find group note: uses group id extracted from object_group

Returns:
bool true if found

Definition at line 152 of file PG_Group_Factory.cpp.

{
  int result = 0;
  PortableGroup::TagGroupTaggedComponent tc;
  if (TAO::PG_Utils::get_tagged_component (object_group, tc))
  {
    result = find_group (tc.object_group_id, group);
  }
  return result;
}

PortableGroup::ObjectGroups * TAO::PG_Group_Factory::groups_at_location ( const PortableGroup::Location the_location  ) 

Definition at line 184 of file PG_Group_Factory.cpp.

{
  size_t upper_limit = this->group_map_.current_size ();
  PortableGroup::ObjectGroups * result = 0;
  ACE_NEW_THROW_EX (
    result,
    PortableGroup::ObjectGroups (upper_limit),
    CORBA::NO_MEMORY());

  result->length(upper_limit);

  size_t group_count = 0;
  for (Group_Map_Iterator it = this->group_map_.begin ();
    it != this->group_map_.end ();
    ++it)
  {
    TAO::PG_Object_Group * group = (*it).int_id_;
    if (group->has_member_at (the_location))
    {
      (*result)[group_count] = group->reference ();
      ++group_count;
    }
  }
  result->length (group_count);
  return result;
}

void TAO::PG_Group_Factory::init ( CORBA::ORB_ptr  orb,
PortableServer::POA_ptr  poa,
PortableGroup::FactoryRegistry_ptr  factory_registry 
)

Definition at line 49 of file PG_Group_Factory.cpp.

{
  ACE_ASSERT (CORBA::is_nil (this->orb_.in ()));
  ACE_ASSERT (CORBA::is_nil (this->poa_.in ()));
  ACE_ASSERT (CORBA::is_nil (this->factory_registry_.in ()));

  this->orb_ = CORBA::ORB::_duplicate(orb);
  this->poa_ = PortableServer::POA::_duplicate (poa);
  this->factory_registry_ = PortableGroup::FactoryRegistry::_duplicate (factory_registry);


  ACE_ASSERT (!CORBA::is_nil (this->orb_.in ()));
  ACE_ASSERT (!CORBA::is_nil (this->poa_.in ()));
  ACE_ASSERT (!CORBA::is_nil (this->factory_registry_.in ()));

  this->manipulator_.init (orb, poa);
}

int TAO::PG_Group_Factory::insert_group ( PortableGroup::ObjectGroupId  group_id,
::TAO::PG_Object_Group *  group 
)

insert group. Take ownership

Returns:
bool true if insertion successful

Definition at line 142 of file PG_Group_Factory.cpp.

{
  return (this->group_map_.bind (group_id, group) == 0);
}

int TAO::PG_Group_Factory::insert_group ( ::TAO::PG_Object_Group *  group  ) 

insert existing group. Take ownership note: uses group id extracted from group object

Returns:
bool true if insertion successful

Definition at line 137 of file PG_Group_Factory.cpp.

{
  return insert_group (group->get_object_group_id(), group);
}


Member Data Documentation

const char* TAO::PG_Group_Factory::domain_id_ [private]

Definition at line 156 of file PG_Group_Factory.h.

PortableGroup::FactoryRegistry_var TAO::PG_Group_Factory::factory_registry_ [private]

The factory registry for replica factories.

Definition at line 152 of file PG_Group_Factory.h.

Group_Map TAO::PG_Group_Factory::group_map_ [private]

Definition at line 158 of file PG_Group_Factory.h.

::TAO::PG_Object_Group_Manipulator TAO::PG_Group_Factory::manipulator_ [private]

Definition at line 154 of file PG_Group_Factory.h.

CORBA::ORB_var TAO::PG_Group_Factory::orb_ [private]

Definition at line 146 of file PG_Group_Factory.h.

PortableServer::POA_var TAO::PG_Group_Factory::poa_ [private]

Reference to the POA used to create object group references.

Definition at line 149 of file PG_Group_Factory.h.


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