00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file PG_PropertyManager.h 00006 * 00007 * $Id: PG_PropertyManager.h 77001 2007-02-12 07:54:49Z johnnyw $ 00008 * 00009 * @author Ossama Othman <ossama@uci.edu> 00010 */ 00011 //============================================================================= 00012 00013 #ifndef TAO_PG_PROPERTY_MANAGER_H 00014 #define TAO_PG_PROPERTY_MANAGER_H 00015 00016 #include /**/ "ace/pre.h" 00017 00018 #include "ace/config-all.h" 00019 00020 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00021 #pragma once 00022 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00023 00024 #include "orbsvcs/PortableGroup/PG_Default_Property_Validator.h" 00025 #include "orbsvcs/PortableGroup/portablegroup_export.h" 00026 #include "orbsvcs/PortableGroupS.h" 00027 00028 #include "ace/SString.h" 00029 #include "ace/Null_Mutex.h" 00030 #include "ace/Functor.h" 00031 #include "ace/Hash_Map_Manager_T.h" 00032 00033 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00034 00035 /// Forward declarations. 00036 class TAO_PG_ObjectGroupManager; 00037 00038 /** 00039 * @class TAO_PG_PropertyManager 00040 * 00041 * @brief Class that implements the PortableGroup::PropertyManager 00042 * interface. 00043 * 00044 * Only the default and type-specific properties are housed in this 00045 * class. The properties used at creation time of an object group and 00046 * those set dynamically after object group creation are stored in the 00047 * TAO_PG_ObjectGroup_Map_Entry structure. However, the 00048 * PropertyManager is still used to manage those properties. 00049 */ 00050 class TAO_PortableGroup_Export TAO_PG_PropertyManager 00051 : public virtual POA_PortableGroup::PropertyManager 00052 { 00053 public: 00054 00055 /// Constructor. 00056 TAO_PG_PropertyManager (TAO_PG_ObjectGroupManager & object_group_manager); 00057 00058 /** 00059 * @name PortableGroup::PropertyManager methods 00060 * 00061 * Methods required by the PortableGroup::PropertyManager 00062 * interface. 00063 */ 00064 //@{ 00065 00066 /// Set the default properties to be used by all object groups. 00067 virtual void set_default_properties ( 00068 const PortableGroup::Properties & props); 00069 00070 /// Get the default properties used by all object groups. 00071 virtual PortableGroup::Properties * get_default_properties (); 00072 00073 /// Remove default properties. 00074 virtual void remove_default_properties ( 00075 const PortableGroup::Properties & props); 00076 00077 /// Set properties associated with a given Member type. These 00078 /// properties override the default properties. 00079 virtual void set_type_properties ( 00080 const char * type_id, 00081 const PortableGroup::Properties & overrides); 00082 00083 /** 00084 * Return the properties associated with a give Replica type. These 00085 * properties include the type-specific properties in use, in 00086 * addition to the default properties that were not overridden. 00087 */ 00088 virtual PortableGroup::Properties * get_type_properties ( 00089 const char * type_id); 00090 00091 /// Remove the given properties associated with the Replica type ID. 00092 virtual void remove_type_properties ( 00093 const char * type_id, 00094 const PortableGroup::Properties & props); 00095 00096 /** 00097 * Dynamically set the properties associated with a given object 00098 * group as the load balancer and replicas are being executed. 00099 * These properties override the type-specific and default 00100 * properties. 00101 */ 00102 virtual void set_properties_dynamically ( 00103 PortableGroup::ObjectGroup_ptr object_group, 00104 const PortableGroup::Properties & overrides); 00105 00106 /** 00107 * Return the properties currently in use by the given object 00108 * group. These properties include those that were set dynamically, 00109 * type-specific properties that weren't overridden, properties that 00110 * were used when the replica was created, and default properties 00111 * that weren't overridden. 00112 */ 00113 virtual PortableGroup::Properties * get_properties ( 00114 PortableGroup::ObjectGroup_ptr object_group); 00115 00116 //@} 00117 00118 /// Type-specific property hash map. 00119 typedef ACE_Hash_Map_Manager_Ex< 00120 ACE_CString, 00121 PortableGroup::Properties, 00122 ACE_Hash<ACE_CString>, 00123 ACE_Equal_To<ACE_CString>, 00124 ACE_Null_Mutex> Type_Prop_Table; 00125 00126 private: 00127 00128 /// Remove properties "to_be_removed" from the given list of 00129 /// properties. 00130 void remove_properties (const PortableGroup::Properties & to_be_removed, 00131 PortableGroup::Properties &properties); 00132 00133 private: 00134 00135 /// Table that maps ObjectId to Object Group related information. 00136 TAO_PG_ObjectGroupManager & object_group_manager_; 00137 00138 /// Default properties. 00139 PortableGroup::Properties default_properties_; 00140 00141 /// Table of type-specific object group properties. 00142 Type_Prop_Table type_properties_; 00143 00144 /// Lock used to synchronize access to the default properties and 00145 /// the type-specific properties. 00146 TAO_SYNCH_MUTEX lock_; 00147 00148 /// The property validator. 00149 /** 00150 * @todo Strategize the validator, or use template policies. 00151 */ 00152 TAO_PG_Default_Property_Validator property_validator_; 00153 00154 }; 00155 00156 TAO_END_VERSIONED_NAMESPACE_DECL 00157 00158 #include /**/ "ace/post.h" 00159 00160 #endif /* TAO_PG_PROPERTY_MANAGER_H */