00001 // -*- C++ -*- 00002 00003 // =================================================================== 00004 /** 00005 * @file PolicyFactory_Registry.h 00006 * 00007 * $Id: PolicyFactory_Registry.h 77151 2007-02-15 13:24:41Z johnnyw $ 00008 * 00009 * @author Ossama Othman <ossama@dre.vanderbilt.edu> 00010 * @author Johnny Willemsen <jwillemsen@remedy.nl> 00011 */ 00012 // =================================================================== 00013 00014 #ifndef TAO_POLICY_FACTORY_REGISTRY_H 00015 #define TAO_POLICY_FACTORY_REGISTRY_H 00016 00017 #include /**/ "ace/pre.h" 00018 00019 #include "tao/Basic_Types.h" 00020 00021 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00022 # pragma once 00023 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00024 00025 #include "tao/Basic_Types.h" 00026 #include "tao/PolicyFactory_Registry_Adapter.h" 00027 #include "ace/Map_Manager.h" 00028 #include "ace/Null_Mutex.h" 00029 00030 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00031 00032 /** 00033 * @class TAO_PolicyFactory_Registry 00034 * 00035 * @brief ORB-specific PortableInterceptor::PolicyFactory registry. 00036 * 00037 * ORB-specific registry that contains all portable interceptor 00038 * policy factories. 00039 */ 00040 class TAO_PolicyFactory_Registry 00041 : public TAO::PolicyFactory_Registry_Adapter 00042 { 00043 public: 00044 00045 /** 00046 * The type of table that maps policy type to policy factory. 00047 * 00048 * @note 00049 * An ACE_Null_Mutex is used for this type since policy factories 00050 * are only registered when CORBA::ORB_init() is called, at which a 00051 * point a lock has already been acquired. In short, the table is 00052 * only modified during ORB bootstrap-time. 00053 */ 00054 typedef ACE_Map_Manager<CORBA::PolicyType, 00055 PortableInterceptor::PolicyFactory_ptr, 00056 ACE_Null_Mutex> 00057 TABLE; 00058 00059 public: 00060 00061 /// Constructor 00062 TAO_PolicyFactory_Registry (void); 00063 00064 /// Destructor. Releases duplicated PolicyFactory references. 00065 ~TAO_PolicyFactory_Registry (void); 00066 00067 /// Register a PolicyFactory with the underlying PolicyFactory 00068 /// sequence. This method should only be called during ORB 00069 /// initialization. 00070 void register_policy_factory ( 00071 CORBA::PolicyType type, 00072 PortableInterceptor::PolicyFactory_ptr policy_factory); 00073 00074 /// Construct a policy of the given type with the information 00075 /// contained in the CORBA::Any @a value. 00076 CORBA::Policy_ptr create_policy (CORBA::PolicyType type, 00077 const CORBA::Any &value); 00078 00079 /// Create an empty policy, usually to be filled in later by 00080 /// demarshaling. 00081 CORBA::Policy_ptr _create_policy (CORBA::PolicyType type); 00082 00083 /// Check if a @c PolicyFactory corresponding to the given type, 00084 /// exists. 00085 bool factory_exists (CORBA::PolicyType & type) const; 00086 00087 private: 00088 00089 /// The table that maps policy type to policy factory. 00090 TABLE factories_; 00091 00092 }; 00093 00094 TAO_END_VERSIONED_NAMESPACE_DECL 00095 00096 #include /**/ "ace/post.h" 00097 00098 #endif /* TAO_POLICY_FACTORY_REGISTRY_H */