#include <PolicyFactory_Registry.h>
Collaboration diagram for TAO_PolicyFactory_Registry:
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. |
ORB-specific registry that contains all portable interceptor policy factories.
Definition at line 40 of file PolicyFactory_Registry.h.
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.
Definition at line 57 of file PolicyFactory_Registry.h.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_PolicyFactory_Registry::TAO_PolicyFactory_Registry | ( | void | ) |
Constructor.
Definition at line 16 of file PolicyFactory_Registry.cpp.
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 ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::close(), factories_, and CORBA::release().
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 }
CORBA::Policy_ptr TAO_PolicyFactory_Registry::_create_policy | ( | CORBA::PolicyType | type | ) |
Create an empty policy, usually to be filled in later by demarshaling.
Definition at line 89 of file PolicyFactory_Registry.cpp.
References PortableInterceptor::PolicyFactory::_create_policy(), PortableInterceptor::PolicyFactory::_nil(), and CORBA::BAD_POLICY_TYPE.
00090 { 00091 PortableInterceptor::PolicyFactory_ptr policy_factory = 00092 PortableInterceptor::PolicyFactory::_nil (); 00093 00094 if (this->factories_.find (type, policy_factory) == -1) 00095 { 00096 // Policy factory corresponding to given policy type does not 00097 // exist in policy factory map. 00098 throw ::CORBA::PolicyError (CORBA::BAD_POLICY_TYPE); 00099 } 00100 00101 return policy_factory->_create_policy (type); 00102 }
CORBA::Policy_ptr TAO_PolicyFactory_Registry::create_policy | ( | CORBA::PolicyType | type, | |
const CORBA::Any & | value | |||
) |
Construct a policy of the given type with the information contained in the CORBA::Any value.
Definition at line 72 of file PolicyFactory_Registry.cpp.
References PortableInterceptor::PolicyFactory::_nil(), CORBA::BAD_POLICY_TYPE, and PortableInterceptor::PolicyFactory::create_policy().
00074 { 00075 PortableInterceptor::PolicyFactory_ptr policy_factory = 00076 PortableInterceptor::PolicyFactory::_nil (); 00077 00078 if (this->factories_.find (type, policy_factory) == -1) 00079 { 00080 // Policy factory corresponding to given policy type does not 00081 // exist in policy factory map. 00082 throw ::CORBA::PolicyError (CORBA::BAD_POLICY_TYPE); 00083 } 00084 00085 return policy_factory->create_policy (type, value); 00086 }
bool TAO_PolicyFactory_Registry::factory_exists | ( | CORBA::PolicyType & | type | ) | const |
Check if a PolicyFactory
corresponding to the given type, exists.
Definition at line 105 of file PolicyFactory_Registry.cpp.
void TAO_PolicyFactory_Registry::register_policy_factory | ( | CORBA::PolicyType | type, | |
PortableInterceptor::PolicyFactory_ptr | policy_factory | |||
) |
Register a PolicyFactory with the underlying PolicyFactory sequence. This method should only be called during ORB initialization.
Definition at line 34 of file PolicyFactory_Registry.cpp.
References PortableInterceptor::PolicyFactory::_duplicate(), CORBA::SystemException::_tao_minor_code(), ACE_Map_Manager< EXT_ID, INT_ID, ACE_LOCK >::bind(), CORBA::COMPLETED_NO, factories_, CORBA::is_nil(), CORBA::OMGVMCID, and release().
00037 { 00038 if (CORBA::is_nil (policy_factory)) 00039 { 00040 throw ::CORBA::BAD_PARAM ( 00041 CORBA::SystemException::_tao_minor_code ( 00042 0, 00043 EINVAL), 00044 CORBA::COMPLETED_NO); 00045 } 00046 00047 PortableInterceptor::PolicyFactory_ptr factory = 00048 PortableInterceptor::PolicyFactory::_duplicate (policy_factory); 00049 00050 const int result = this->factories_.bind (type, factory); 00051 00052 if (result != 0) 00053 { 00054 // Release the duplicated factory to prevent a memory leak 00055 ::CORBA::release (factory); 00056 00057 if (result == 1) 00058 { 00059 // PolicyFactory of given type already exists. 00060 throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 16, 00061 CORBA::COMPLETED_NO); 00062 } 00063 else 00064 { 00065 // Could not add PolicyFactory due to internal bind failures. 00066 throw ::CORBA::INTERNAL (); 00067 } 00068 } 00069 }
TABLE TAO_PolicyFactory_Registry::factories_ [private] |
The table that maps policy type to policy factory.
Definition at line 90 of file PolicyFactory_Registry.h.
Referenced by register_policy_factory(), and ~TAO_PolicyFactory_Registry().