TAO_PolicyFactory_Registry Class Reference

ORB-specific PortableInterceptor::PolicyFactory registry. More...

#include <PolicyFactory_Registry.h>

Inheritance diagram for TAO_PolicyFactory_Registry:

Inheritance graph
[legend]
Collaboration diagram for TAO_PolicyFactory_Registry:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Map_Manager< CORBA::PolicyType,
PortableInterceptor::PolicyFactory_ptr,
ACE_Null_Mutex
TABLE

Public Member Functions

 TAO_PolicyFactory_Registry (void)
 Constructor.

 ~TAO_PolicyFactory_Registry (void)
 Destructor. Releases duplicated PolicyFactory references.

void register_policy_factory (CORBA::PolicyType type, PortableInterceptor::PolicyFactory_ptr policy_factory)
CORBA::Policy_ptr create_policy (CORBA::PolicyType type, const CORBA::Any &value)
CORBA::Policy_ptr _create_policy (CORBA::PolicyType type)
bool factory_exists (CORBA::PolicyType &type) const

Private Attributes

TABLE factories_
 The table that maps policy type to policy factory.


Detailed Description

ORB-specific PortableInterceptor::PolicyFactory registry.

ORB-specific registry that contains all portable interceptor policy factories.

Definition at line 41 of file PolicyFactory_Registry.h.


Member Typedef Documentation

typedef ACE_Map_Manager<CORBA::PolicyType, PortableInterceptor::PolicyFactory_ptr, ACE_Null_Mutex> TAO_PolicyFactory_Registry::TABLE
 

The type of table that maps policy type to policy factory.

Note:
An ACE_Null_Mutex is used for this type since policy factories are only registered when CORBA::ORB_init() is called, at which a point a lock has already been acquired. In short, the table is only modified during ORB bootstrap-time.

Definition at line 58 of file PolicyFactory_Registry.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_PolicyFactory_Registry::TAO_PolicyFactory_Registry void   ) 
 

Constructor.

Definition at line 16 of file PolicyFactory_Registry.cpp.

References TAO_DEFAULT_POLICY_FACTORY_REGISTRY_SIZE.

00017   : factories_ (TAO_DEFAULT_POLICY_FACTORY_REGISTRY_SIZE)
00018 {
00019 }

TAO_PolicyFactory_Registry::~TAO_PolicyFactory_Registry void   ) 
 

Destructor. Releases duplicated PolicyFactory references.

Definition at line 21 of file PolicyFactory_Registry.cpp.

References factories_.

00022 {
00023   const TABLE::iterator end (this->factories_.end ());
00024 
00025   for (TABLE::iterator i = this->factories_.begin (); i != end; ++i)
00026     {
00027       ::CORBA::release ((*i).int_id_);
00028     }
00029 
00030   this->factories_.close ();
00031 }


Member Function Documentation

CORBA::Policy_ptr TAO_PolicyFactory_Registry::_create_policy CORBA::PolicyType  type  )  [virtual]
 

Create an empty policy, usually to be filled in later by demarshaling.

Implements TAO::PolicyFactory_Registry_Adapter.

Definition at line 96 of file PolicyFactory_Registry.cpp.

References PortableInterceptor::PolicyFactory::_nil(), ACE_ENV_ARG_PARAMETER, ACE_THROW_RETURN, and factories_.

00098 {
00099   PortableInterceptor::PolicyFactory_ptr policy_factory =
00100     PortableInterceptor::PolicyFactory::_nil ();
00101 
00102   if (this->factories_.find (type,
00103                              policy_factory) == -1)
00104     {
00105       // Policy factory corresponding to given policy type does not
00106       // exist in policy factory map.
00107       ACE_THROW_RETURN (
00108          CORBA::PolicyError (CORBA::BAD_POLICY_TYPE),  // @@ Right exception?
00109          CORBA::Policy::_nil ());
00110     }
00111 
00112   return policy_factory->_create_policy (type
00113                                          ACE_ENV_ARG_PARAMETER);
00114 }

CORBA::Policy_ptr TAO_PolicyFactory_Registry::create_policy CORBA::PolicyType  type,
const CORBA::Any &  value
[virtual]
 

Construct a policy of the given type with the information contained in the CORBA::Any value.

Implements TAO::PolicyFactory_Registry_Adapter.

Definition at line 74 of file PolicyFactory_Registry.cpp.

References PortableInterceptor::PolicyFactory::_nil(), ACE_ENV_ARG_PARAMETER, ACE_THROW_RETURN, and factories_.

00077 {
00078   PortableInterceptor::PolicyFactory_ptr policy_factory =
00079     PortableInterceptor::PolicyFactory::_nil ();
00080 
00081   if (this->factories_.find (type, policy_factory) == -1)
00082     {
00083       // Policy factory corresponding to given policy type does not
00084       // exist in policy factory map.
00085       ACE_THROW_RETURN (
00086          CORBA::PolicyError (CORBA::BAD_POLICY_TYPE),  // @@ Right exception?
00087          CORBA::Policy::_nil ());
00088     }
00089 
00090   return policy_factory->create_policy (type,
00091                                         value
00092                                         ACE_ENV_ARG_PARAMETER);
00093 }

bool TAO_PolicyFactory_Registry::factory_exists CORBA::PolicyType type  )  const [virtual]
 

Check if a PolicyFactory corresponding to the given type, exists.

Implements TAO::PolicyFactory_Registry_Adapter.

Definition at line 117 of file PolicyFactory_Registry.cpp.

References factories_.

00118 {
00119   return (this->factories_.find (type) == 0);
00120 }

void TAO_PolicyFactory_Registry::register_policy_factory CORBA::PolicyType  type,
PortableInterceptor::PolicyFactory_ptr  policy_factory
[virtual]
 

Register a PolicyFactory with the underlying PolicyFactory sequence. This method should only be called during ORB initialization.

Implements TAO::PolicyFactory_Registry_Adapter.

Definition at line 34 of file PolicyFactory_Registry.cpp.

References PortableInterceptor::PolicyFactory::_duplicate(), ACE_THROW, factories_, and CORBA::is_nil().

00038 {
00039   if (CORBA::is_nil (policy_factory))
00040     {
00041       ACE_THROW (CORBA::BAD_PARAM (
00042                    CORBA::SystemException::_tao_minor_code (
00043                      0,
00044                      EINVAL),
00045                    CORBA::COMPLETED_NO));
00046     }
00047 
00048   PortableInterceptor::PolicyFactory_ptr factory =
00049     PortableInterceptor::PolicyFactory::_duplicate (policy_factory);
00050 
00051   const int result = this->factories_.bind (type,
00052                                             factory);
00053 
00054   if (result != 0)
00055     {
00056       // Release the duplicated factory to prevent a memory leak
00057       ::CORBA::release (factory);
00058 
00059       if (result == 1)
00060         {
00061           // PolicyFactory of given type already exists.
00062           ACE_THROW (CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 16,
00063                                            CORBA::COMPLETED_NO));
00064         }
00065       else
00066         {
00067           // Could not add PolicyFactory due to internal bind failures.
00068           ACE_THROW (CORBA::INTERNAL ());
00069         }
00070     }
00071 }


Member Data Documentation

TABLE TAO_PolicyFactory_Registry::factories_ [private]
 

The table that maps policy type to policy factory.

Definition at line 94 of file PolicyFactory_Registry.h.

Referenced by _create_policy(), create_policy(), factory_exists(), register_policy_factory(), and ~TAO_PolicyFactory_Registry().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 12:52:37 2006 for TAO_PI by doxygen 1.3.6