POA Abstraction. More...
#include <POA_Helper.h>


Public Member Functions | |
| TAO_Notify_POA_Helper (void) | |
| Default Constructor. | |
| void | init (PortableServer::POA_ptr parent_poa, const char *poa_name) |
| Create a new PortableServer::POA. | |
| void | init_persistent (PortableServer::POA_ptr parent_poa, const char *poa_name) |
| Create a new persistent PortableServer::POA. | |
| void | init (PortableServer::POA_ptr parent_poa) |
| Create a new PortableServer::POA. The name is chosen at random. | |
| virtual | ~TAO_Notify_POA_Helper () |
| Destructor. | |
| PortableServer::POA_ptr | poa (void) |
| Get underlying POA. | |
| void | destroy (void) |
| Destroy underlying POA. | |
| CORBA::Object_ptr | activate (PortableServer::Servant servant, CORBA::Long &id) |
| Activate Object, the POA will assign an ID and return its value. | |
| CORBA::Object_ptr | activate_with_id (PortableServer::Servant servant, CORBA::Long id) |
| Activate Object, using existing ID. | |
| void | deactivate (CORBA::Long id) const |
| Deactivate Object with ID. | |
| CORBA::Object_ptr | id_to_reference (CORBA::Long id) const |
| Convert ID to reference. | |
| PortableServer::ServantBase * | reference_to_servant (CORBA::Object_ptr ptr) const |
| Convert reference to pointer to servant. | |
| CORBA::Object_ptr | servant_to_reference (PortableServer::ServantBase *servant) const |
| ACE_CString | get_unique_id (void) |
| Generate a unique id for each POA created. | |
Protected Member Functions | |
| virtual void | set_policy (PortableServer::POA_ptr parent_poa, CORBA::PolicyList &policy_list) |
| Set default POA policies. | |
| virtual void | set_persistent_policy (PortableServer::POA_ptr parent_poa, CORBA::PolicyList &policy_list) |
| Set persistent POA policies. | |
| void | create_i (PortableServer::POA_ptr parent_poa, const char *poa_name, CORBA::PolicyList &policy_list) |
| Apply the polices and create child POA. | |
| PortableServer::ObjectId * | long_to_ObjectId (CORBA::Long id) const |
| Convert id to ObjectID. | |
Protected Attributes | |
| PortableServer::POA_var | poa_ |
| POA. | |
| TAO_Notify_ID_Factory | id_factory_ |
| ID Factory for objects. | |
POA Abstraction.
Definition at line 36 of file POA_Helper.h.
| TAO_Notify_POA_Helper::TAO_Notify_POA_Helper | ( | void | ) |
| TAO_Notify_POA_Helper::~TAO_Notify_POA_Helper | ( | void | ) | [virtual] |
| CORBA::Object_ptr TAO_Notify_POA_Helper::activate | ( | PortableServer::Servant | servant, | |
| CORBA::Long & | id | |||
| ) |
Activate Object, the POA will assign an ID and return its value.
Definition at line 155 of file POA_Helper.cpp.
{
// Generate a new ID.
id = this->id_factory_.id ();
if (DEBUG_LEVEL > 0)
{
CORBA::String_var the_name = this->poa_->the_name ();
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) POA_Helper Activating object with ")
ACE_TEXT ("id = %d in POA : %C\n"),
id, the_name.in ()
));
}
// Convert CORBA::Long to ObjectId
PortableServer::ObjectId_var oid = this->long_to_ObjectId (id);
poa_->activate_object_with_id (oid.in (), servant);
return poa_->id_to_reference (oid.in ());
}
| CORBA::Object_ptr TAO_Notify_POA_Helper::activate_with_id | ( | PortableServer::Servant | servant, | |
| CORBA::Long | id | |||
| ) |
Activate Object, using existing ID.
Definition at line 179 of file POA_Helper.cpp.
{
if (DEBUG_LEVEL > 0)
{
CORBA::String_var the_name = this->poa_->the_name ();
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) POA_Helper Activating object with ")
ACE_TEXT ("existing id = %d in POA : %C\n"),
id, the_name.in ()
));
}
this->id_factory_.set_last_used (id);
// Convert CORBA::Long to ObjectId
PortableServer::ObjectId_var oid = this->long_to_ObjectId (id);
poa_->activate_object_with_id (oid.in (), servant);
return poa_->id_to_reference (oid.in ());
}
| void TAO_Notify_POA_Helper::create_i | ( | PortableServer::POA_ptr | parent_poa, | |
| const char * | poa_name, | |||
| CORBA::PolicyList & | policy_list | |||
| ) | [protected] |
Apply the polices and create child POA.
Definition at line 98 of file POA_Helper.cpp.
{
PortableServer::POAManager_var manager =
parent_poa->the_POAManager ();
// Create the child POA.
this->poa_ = parent_poa->create_POA (poa_name, manager.in (), policy_list);
if (DEBUG_LEVEL > 0)
{
CORBA::String_var the_name = this->poa_->the_name ();
ACE_DEBUG ((LM_DEBUG, "Created POA : %C\n", the_name.in ()));
}
/*
// Destroy the policies
for (CORBA::ULong index = 0; index < policy_list.length (); ++index)
{
policy_list[index]->destroy ();
}
*/
}
| void TAO_Notify_POA_Helper::deactivate | ( | CORBA::Long | id | ) | const |
Deactivate Object with ID.
Definition at line 201 of file POA_Helper.cpp.
{
// Convert CORBA::Long to ObjectId
PortableServer::ObjectId_var oid = this->long_to_ObjectId (id);
if (DEBUG_LEVEL > 0)
{
CORBA::String_var the_name = this->poa_->the_name ();
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) POA_Helper Deactivating object with")
ACE_TEXT ("id = %d in POA : %C\n"),
id, the_name.in ()));
}
poa_->deactivate_object (oid.in ());
}
| void TAO_Notify_POA_Helper::destroy | ( | void | ) |
Destroy underlying POA.
Definition at line 241 of file POA_Helper.cpp.
{
poa_->destroy (true, false);
// The <wait_for_completion> flag = 0
}
| ACE_CString TAO_Notify_POA_Helper::get_unique_id | ( | void | ) |
Generate a unique id for each POA created.
Factory for generating unique ids for the POAs.
Definition at line 28 of file POA_Helper.cpp.
{
/// Factory for generating unique ids for the POAs.
static TAO_Notify_ID_Factory poa_id_factory;
char buf[32];
ACE_OS::itoa (poa_id_factory.id (), buf, 10);
return ACE_CString (buf);
}
| CORBA::Object_ptr TAO_Notify_POA_Helper::id_to_reference | ( | CORBA::Long | id | ) | const |
Convert ID to reference.
Definition at line 218 of file POA_Helper.cpp.
{
// Convert CORBA::Long to ObjectId
PortableServer::ObjectId_var oid = this->long_to_ObjectId (id);
return poa_->id_to_reference (oid.in ());
}
| void TAO_Notify_POA_Helper::init | ( | PortableServer::POA_ptr | parent_poa, | |
| const char * | poa_name | |||
| ) |
Create a new PortableServer::POA.
Definition at line 40 of file POA_Helper.cpp.
{
CORBA::PolicyList policy_list (2);
this->set_policy (parent_poa, policy_list);
this->create_i (parent_poa, poa_name, policy_list);
}
| void TAO_Notify_POA_Helper::init | ( | PortableServer::POA_ptr | parent_poa | ) |
Create a new PortableServer::POA. The name is chosen at random.
Reimplemented in TAO_Notify_RT_POA_Helper.
Definition at line 62 of file POA_Helper.cpp.
{
ACE_CString child_poa_name = this->get_unique_id ();
this->init (parent_poa, child_poa_name.c_str ());
}
| void TAO_Notify_POA_Helper::init_persistent | ( | PortableServer::POA_ptr | parent_poa, | |
| const char * | poa_name | |||
| ) |
Create a new persistent PortableServer::POA.
Definition at line 51 of file POA_Helper.cpp.
{
CORBA::PolicyList policy_list (2);
this->set_persistent_policy (parent_poa, policy_list);
this->create_i (parent_poa, poa_name, policy_list);
}
| PortableServer::ObjectId * TAO_Notify_POA_Helper::long_to_ObjectId | ( | CORBA::Long | id | ) | const [protected] |
Convert id to ObjectID.
Definition at line 125 of file POA_Helper.cpp.
{
// Modified code from string_to_ObjectId ..
//
CORBA::ULong buffer_size = 4;
// Create the buffer for the Id
CORBA::Octet *buffer = PortableServer::ObjectId::allocbuf (buffer_size);
// Copy the contents
ACE_OS::memcpy (buffer, (char*)&id, buffer_size);
// @@ Pradeep: TAO guarantees that Long is 4 bytes wide, but the
// standard only guarantees that it is at least 4 bytes wide. You
// may want to think about that....
// Create and return a new ID
PortableServer::ObjectId *obj_id = 0;
ACE_NEW_THROW_EX (obj_id,
PortableServer::ObjectId (buffer_size,
buffer_size,
buffer,
1),
CORBA::NO_MEMORY ());
return obj_id;
}
| PortableServer::POA_ptr TAO_Notify_POA_Helper::poa | ( | void | ) |
| PortableServer::ServantBase * TAO_Notify_POA_Helper::reference_to_servant | ( | CORBA::Object_ptr | ptr | ) | const |
Convert reference to pointer to servant.
Definition at line 227 of file POA_Helper.cpp.
{
return poa_->reference_to_servant (ptr);
}
| CORBA::Object_ptr TAO_Notify_POA_Helper::servant_to_reference | ( | PortableServer::ServantBase * | servant | ) | const |
Definition at line 233 of file POA_Helper.cpp.
{
return poa_->servant_to_reference (servant);
}
| void TAO_Notify_POA_Helper::set_persistent_policy | ( | PortableServer::POA_ptr | parent_poa, | |
| CORBA::PolicyList & | policy_list | |||
| ) | [protected, virtual] |
Set persistent POA policies.
Definition at line 84 of file POA_Helper.cpp.
{
policy_list.length (2);
policy_list[0] =
parent_poa->create_lifespan_policy (PortableServer::PERSISTENT);
policy_list[1] =
parent_poa->create_id_assignment_policy (PortableServer::USER_ID);
}
| void TAO_Notify_POA_Helper::set_policy | ( | PortableServer::POA_ptr | parent_poa, | |
| CORBA::PolicyList & | policy_list | |||
| ) | [protected, virtual] |
Set default POA policies.
Definition at line 70 of file POA_Helper.cpp.
{
policy_list.length (2);
policy_list[0] =
parent_poa->create_id_uniqueness_policy (PortableServer::UNIQUE_ID);
policy_list[1] =
parent_poa->create_id_assignment_policy (PortableServer::USER_ID);
}
ID Factory for objects.
Definition at line 108 of file POA_Helper.h.
PortableServer::POA_var TAO_Notify_POA_Helper::poa_ [protected] |
POA.
Definition at line 105 of file POA_Helper.h.
1.7.0