#include <PG_Property_Set.h>
Collaboration diagram for TAO::PG_Property_Set:
It supports "chains" of property sets to implement default value semantics. If a requested property is not found in this set, the default set(s) are searched. Thus, any property found at this level overrides the defaults.
See: PG_Properties_Support for more details on use of this object.
A PG_Property_Set may also be used for it's original purpose as a stand-alone helper class for extracting values from PortableGroup::Properties.
Definition at line 51 of file PG_Property_Set.h.
|
Definition at line 56 of file PG_Property_Set.h. Referenced by export_properties(), and merge_properties(). |
|
Definition at line 60 of file PG_Property_Set.h. Referenced by clear(), export_properties(), and merge_properties(). |
|
constructor: empty set with no defaults. Definition at line 24 of file PG_Property_Set.cpp.
00025 : defaults_ (0) 00026 { 00027 } |
|
constructor
Definition at line 29 of file PG_Property_Set.cpp. References decode(), and PortableGroup::Properties.
|
|
constructor with defaults
Definition at line 36 of file PG_Property_Set.cpp. References decode(), and PortableGroup::Properties.
|
|
constructor with defaults, but no properties (yet) (note this is not a copy constructor)
Definition at line 45 of file PG_Property_Set.cpp.
00047 : defaults_ (defaults) 00048 { 00049 } |
|
Definition at line 51 of file PG_Property_Set.cpp. References clear().
00052 { 00053 this->clear (); 00054 } |
|
|
|
Clear properties Does not clear default properties. Definition at line 104 of file PG_Property_Set.cpp. References ACE_GUARD, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::begin(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::end(), TAO_SYNCH_MUTEX, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::unbind_all(), and ValueMapIterator. Referenced by TAO::PG_Properties_Support::set_type_properties(), and ~PG_Property_Set().
00105 { 00106 ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_); 00107 for (ValueMapIterator it = this->values_.begin (); 00108 it != this->values_.end (); 00109 ++it) 00110 { 00111 delete (*it).int_id_; 00112 } 00113 this->values_.unbind_all (); 00114 } |
|
Decode additional properties Duplicate values replace previous values.
Definition at line 57 of file PG_Property_Set.cpp. References ACE_CString, ACE_ERROR, ACE_GUARD, ACE_NEW_THROW_EX, LM_ERROR, PortableGroup::Property::nam, PortableGroup::Properties, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::rebind(), set_property(), TAO_debug_level, TAO_SYNCH_MUTEX, PortableGroup::Property::val, and PortableGroup::Value. Referenced by PG_Property_Set(), TAO::PG_Properties_Support::set_default_properties(), TAO::PG_Object_Group::set_properties_dynamically(), and TAO::PG_Properties_Support::set_type_properties().
00058 { 00059 ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_); 00060 00061 size_t count = property_set.length (); 00062 for (size_t nItem = 0; nItem < count; ++nItem) 00063 { 00064 const PortableGroup::Property & property = property_set[nItem]; 00065 const CosNaming::Name & nsName = property.nam; 00066 // note assumption one level name with no kind 00067 // @@ TODO: fix this 00068 const CosNaming::NameComponent & nc = nsName[0]; 00069 00070 this->set_property (static_cast<const char *> (nc.id), 00071 property.val); 00072 00073 #if 0 00074 ACE_CString name = static_cast<const char *> (nc.id); 00075 00076 const PortableGroup::Value * value_copy; 00077 ACE_NEW_THROW_EX (value_copy, 00078 PortableGroup::Value (property.val), 00079 CORBA::NO_MEMORY ()); 00080 00081 const PortableGroup::Value * replaced_value = 0; 00082 if (0 == this->values_.rebind (name, value_copy, replaced_value)) 00083 { 00084 if (0 != replaced_value) 00085 { 00086 delete replaced_value; 00087 } 00088 } 00089 else 00090 { 00091 if (TAO_debug_level > 3) 00092 { 00093 ACE_ERROR ( (LM_ERROR, 00094 "%n\n%T: Property_set: rebind failed.\n" 00095 )); 00096 } 00097 // @@ should throw something here 00098 throw CORBA::NO_MEMORY (); 00099 } 00100 #endif 00101 } 00102 } |
|
Export the properties to a PortableGroup::Properties This method is intended to be used to implement the PropertyManager::get_*_properties methods. If you want to access the properties for any purpose other than exporting them across a CORBA interface, it is much more efficient to use the find interface. Definition at line 174 of file PG_Property_Set.cpp. References ACE_ASSERT, ACE_CString, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::begin(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::current_size(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::end(), merge_properties(), PortableGroup::Property::nam, PortableGroup::Properties, CORBA::string_dup(), PortableGroup::Property::val, PortableGroup::Value, ValueMap, and ValueMapIterator. Referenced by TAO::PG_Properties_Support::get_default_properties(), TAO::PG_Object_Group::get_properties(), and TAO::PG_Properties_Support::get_type_properties().
00175 { 00176 ValueMap merged_values; 00177 this->merge_properties (merged_values); 00178 00179 property_set.length (merged_values.current_size ()); 00180 00181 size_t pos = 0; 00182 for (ValueMapIterator it = merged_values.begin (); 00183 it != merged_values.end (); 00184 ++it) 00185 { 00186 const ACE_CString & name = (*it).ext_id_; 00187 const PortableGroup::Value * value = (*it).int_id_; 00188 00189 PortableGroup::Property & property = property_set[pos]; 00190 CosNaming::Name & nsName = property.nam; 00191 //@@ note assumption: single level name, no kind 00192 nsName.length(1); 00193 CosNaming::NameComponent & nc = nsName[0]; 00194 nc.id = CORBA::string_dup (name.c_str ()); 00195 PortableGroup::Value & val = property.val; 00196 val = *value; // NOTE: Any assignment does a deep copy 00197 ++pos; 00198 } 00199 ACE_ASSERT (pos == property_set.length ()); 00200 } |
|
general purpose find. returns a pointer to an Any if templated methods were available: template int find (const ACE_CString & key, TYPE & value) const; instead, see global function below
Definition at line 221 of file PG_Property_Set.cpp. References ACE_GUARD_RETURN, defaults_, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::find(), TAO_SYNCH_MUTEX, and PortableGroup::Value.
00224 { 00225 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->internals_, 0); 00226 int found = (0 == this->values_.find (key, pValue)); 00227 if (! found) 00228 { 00229 if (0 != this->defaults_) 00230 { 00231 found = this->defaults_->find (key, pValue); 00232 } 00233 } 00234 return found; 00235 } |
|
populate a ValueMap with the properties known to this decoder including but overriding default values Definition at line 202 of file PG_Property_Set.cpp. References ACE_GUARD, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::begin(), defaults_, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::end(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::rebind(), TAO_SYNCH_MUTEX, ValueMap, and ValueMapIterator. Referenced by export_properties().
00203 { 00204 ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_); 00205 if (0 != this->defaults_) 00206 { 00207 this->defaults_->merge_properties (merged_values); 00208 } 00209 // note AFICT ACE_Hash_Map does not support const iterators, hence the const cast. 00210 ValueMap & mutable_values = const_cast<ValueMap &> (this->values_); 00211 for (ValueMapIterator it = mutable_values.begin (); 00212 it != mutable_values.end (); 00213 ++it) 00214 { 00215 merged_values.rebind ( (*it).ext_id_, (*it).int_id_); 00216 } 00217 } |
|
|
|
Definition at line 116 of file PG_Property_Set.cpp. References ACE_CString, ACE_GUARD, PortableGroup::Property::nam, PortableGroup::Properties, TAO_SYNCH_MUTEX, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::unbind(), and PortableGroup::Value. Referenced by TAO::PG_Properties_Support::remove_default_properties(), and TAO::PG_Properties_Support::remove_type_properties().
00117 { 00118 ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_); 00119 size_t count = property_set.length (); 00120 for (size_t nItem = 0; nItem < count; ++nItem) 00121 { 00122 const PortableGroup::Property & property = property_set[nItem]; 00123 const CosNaming::Name & nsName = property.nam; 00124 // note assumption one level name with no kind 00125 // @@ TODO: fix this 00126 const CosNaming::NameComponent & nc = nsName[0]; 00127 ACE_CString name = static_cast<const char *> (nc.id); 00128 00129 const PortableGroup::Value * deleted_value; 00130 if ( 0 == this->values_.unbind (name, deleted_value)) 00131 { 00132 delete deleted_value; 00133 } 00134 else 00135 { 00136 // don't worry about it. 00137 } 00138 } 00139 } |
|
set or replace a single property Definition at line 141 of file PG_Property_Set.cpp. References ACE_CString, ACE_ERROR, ACE_NEW_THROW_EX, LM_ERROR, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, ACE_Hash< EXT_ID >, ACE_Equal_To< EXT_ID >, ACE_LOCK >::rebind(), TAO_debug_level, and PortableGroup::Value. Referenced by decode(), and TAO::PG_Properties_Support::set_default_property().
00144 { 00145 ACE_CString key (name); 00146 PortableGroup::Value * value_copy; 00147 ACE_NEW_THROW_EX ( 00148 value_copy, PortableGroup::Value (value), 00149 CORBA::NO_MEMORY ()); 00150 00151 const PortableGroup::Value * replaced_value = 0; 00152 if (0 == this->values_.rebind (name, value_copy, replaced_value)) 00153 { 00154 if (0 != replaced_value) 00155 { 00156 delete replaced_value; 00157 } 00158 } 00159 else 00160 { 00161 if (TAO_debug_level > 3) 00162 { 00163 ACE_ERROR ( (LM_ERROR, 00164 "%n\n%T: Property_set: rebind failed.\n" 00165 )); 00166 } 00167 // @@ should throw something here 00168 throw CORBA::NO_MEMORY (); 00169 } 00170 } |
|
a parent to another property decoder that provides default values these can be chained indefinitely.
Definition at line 169 of file PG_Property_Set.h. Referenced by find(), and merge_properties(). |
|
Protect internal state. Definition at line 161 of file PG_Property_Set.h. |
|
Definition at line 163 of file PG_Property_Set.h. |