#include <Trader_Utils.h>
Collaboration diagram for TAO_Offer_Modifier:
Public Member Functions | |
TAO_Offer_Modifier (const char *type, const CosTradingRepos::ServiceTypeRepository::TypeStruct &type_struct, CosTrading::Offer *offer) | |
~TAO_Offer_Modifier (void) | |
void | delete_properties (const CosTrading::PropertyNameSeq &deletes) throw (CosTrading::Register::UnknownPropertyName, CosTrading::Register::MandatoryProperty, CosTrading::IllegalPropertyName, CosTrading::DuplicatePropertyName) |
void | merge_properties (const CosTrading::PropertySeq &modifies) throw (CosTrading::IllegalPropertyName, CosTrading::DuplicatePropertyName, CosTrading::PropertyTypeMismatch, CosTrading::ReadonlyDynamicProperty, CosTrading::Register::ReadonlyProperty) |
void | affect_change (const CosTrading::PropertySeq &modifies) |
Return a reference to the Offer with the changes affected. | |
Private Types | |
typedef ACE_Hash_Map_Manager_Ex< CORBA::String_var, CosTrading::Property *, ACE_Hash< CORBA::String_var >, ACE_Equal_To< CORBA::String_var >, ACE_Null_Mutex > | Property_Table |
Private Member Functions | |
TAO_Offer_Modifier (const TAO_Offer_Modifier &) | |
TAO_Offer_Modifier & | operator= (const TAO_Offer_Modifier &) |
Private Attributes | |
const char * | type_ |
The type of the offer. | |
Property_Table | props_ |
The map of properties in the offer. | |
TAO_Typecode_Table | prop_types_ |
Table of property types. | |
TAO_String_Set | readonly_ |
TAO_String_Set | mandatory_ |
CosTrading::Offer * | offer_ |
A reference to the offer undergoing change. |
Definition at line 581 of file Trader_Utils.h.
|
Definition at line 629 of file Trader_Utils.h. |
|
Modify an of type , whose properties are described by Definition at line 1044 of file Trader_Utils.cpp. References ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind(), ACE_Unbounded_Set< T >::insert(), mandatory_, prop_types_, CosTrading::Offer::properties, CosTrading::PropertySeq, CosTradingRepos::ServiceTypeRepository::TypeStruct::props, CosTradingRepos::ServiceTypeRepository::PropStructSeq, and readonly_.
01047 : type_ (type_name), 01048 offer_ (offer) 01049 { 01050 const CosTradingRepos::ServiceTypeRepository::PropStructSeq& 01051 pstructs = type_struct.props; 01052 CosTrading::PropertySeq& prop_seq = this->offer_->properties; 01053 CORBA::ULong pstructs_length = pstructs.length (), 01054 props_length = prop_seq.length (), 01055 i = 0; 01056 01057 // Create a mapping of property names to their types. 01058 for (i = 0; i < pstructs_length; i++) 01059 { 01060 CORBA::String_var prop_name = pstructs[i].name.in (); 01061 CORBA::TypeCode_ptr type_code = 01062 CORBA::TypeCode::_duplicate (pstructs[i].value_type.in ()); 01063 this->prop_types_.bind (prop_name, type_code); 01064 } 01065 01066 // Separate the type defined properties into mandatory and readonly 01067 for (i = 0; i < pstructs_length; i++) 01068 { 01069 const char* pname = pstructs[i].name; 01070 01071 if (pstructs[i].mode == 01072 CosTradingRepos::ServiceTypeRepository::PROP_MANDATORY) 01073 { 01074 CORBA::String_var prop_name (pname); 01075 this->mandatory_.insert (prop_name); 01076 } 01077 else if (pstructs[i].mode == 01078 CosTradingRepos::ServiceTypeRepository::PROP_READONLY) 01079 { 01080 CORBA::String_var prop_name (pname); 01081 this->readonly_.insert (prop_name); 01082 } 01083 } 01084 01085 // Insert the indices of the offer properties into a map. 01086 for (i = 0; i < props_length; i++) 01087 { 01088 CORBA::String_var prop_name = 01089 static_cast<const char*> (prop_seq[i].name); 01090 this->props_.bind (prop_name, &prop_seq[i]); 01091 } 01092 } |
|
Definition at line 1094 of file Trader_Utils.cpp. References CORBA::release().
01095 { 01096 for (TAO_Typecode_Table::iterator type_iter (this->prop_types_); 01097 ! type_iter.done (); 01098 type_iter++) 01099 { 01100 CORBA::TypeCode_ptr corba_type = (*type_iter).int_id_; 01101 CORBA::release (corba_type); 01102 } 01103 } |
|
|
|
Return a reference to the Offer with the changes affected.
Definition at line 1210 of file Trader_Utils.cpp. References ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::current_size(), CosTrading::Property::name, CosTrading::Offer::properties, CosTrading::PropertySeq, and ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind(). Referenced by TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::modify().
01211 { 01212 // Create a new property list reflecting the deletes, modifies, and 01213 // add operations performed, and place this property list in the 01214 // offer. 01215 01216 // Merge these properties with the original set. 01217 CORBA::ULong i = 0, 01218 merge_length = modifies.length (); 01219 01220 for (i = 0; i < merge_length; i++) 01221 { 01222 Property_Table::ENTRY* entry = 0; 01223 CORBA::String_var prop_name = modifies[i].name.in (); 01224 01225 CosTrading::Property* prop = 01226 const_cast<CosTrading::Property*> (&modifies[i]); 01227 if (this->props_.bind (prop_name, prop, entry) == 1) 01228 // We need to rebind here. 01229 entry->int_id_ = prop; 01230 } 01231 01232 CORBA::ULong num_modified = 0, 01233 original_length = this->offer_->properties.length (), 01234 total_length = static_cast<CORBA::ULong> (this->props_.current_size ()); 01235 01236 // Scrap the existing property sequence and begin a new one 01237 CosTrading::PropertySeq prop_seq (total_length); 01238 // this->offer_->properties.length (total_length); 01239 01240 // Copy in the unaffected and modified props into the offer, 01241 // excluding those that were deleted. Let's try and retain their 01242 // relative ordering. 01243 for (i = 0; i < original_length; i++) 01244 { 01245 CosTrading::Property* prop_value = 0; 01246 const char* name = this->offer_->properties[i].name; 01247 CORBA::String_var prop_name (name); 01248 if (this->props_.unbind (prop_name, prop_value) == 0) 01249 prop_seq[num_modified++] = *prop_value; 01250 } 01251 01252 for (i = 0; i < merge_length; i++) 01253 { 01254 CosTrading::Property* prop_value = 0; 01255 const char* name = modifies[i].name; 01256 CORBA::String_var prop_name (name); 01257 if (this->props_.unbind (prop_name, prop_value) == 0) 01258 prop_seq[num_modified++] = *prop_value; 01259 } 01260 01261 this->offer_->properties.length (total_length); 01262 for (i = 0; i < total_length; i++) 01263 this->offer_->properties[i] = prop_seq[i]; 01264 // Free the old, orphaned sequence. 01265 // CosTrading::PropertySeq::freebuf (prop_buf); 01266 } |
|
Delete the properties whose names were given to the constructor. Ensure we don't delete mandatory properties. Definition at line 1107 of file Trader_Utils.cpp. References ACE_THROW, ACE_Unbounded_Set< T >::insert(), TAO_Trader_Base::is_valid_property_name(), CosTrading::PropertyNameSeq, and TAO_String_Set. Referenced by TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::modify().
01113 { 01114 // Validate that the listed property names can be deleted 01115 CORBA::ULong i = 0, 01116 length = deletes.length (); 01117 TAO_String_Set delete_me; 01118 01119 for (i = 0; i < length; i++) 01120 { 01121 const char* dname = static_cast<const char*> (deletes[i]); 01122 if (! TAO_Trader_Base::is_valid_property_name (dname)) 01123 ACE_THROW (CosTrading::IllegalPropertyName (dname)); 01124 else 01125 { 01126 CORBA::String_var prop_name (dname); 01127 if (this->mandatory_.find (prop_name) == 0) 01128 ACE_THROW (CosTrading::Register::MandatoryProperty (this->type_, dname)); 01129 else if (delete_me.insert (prop_name) == 1) 01130 ACE_THROW (CosTrading::DuplicatePropertyName (dname)); 01131 else if (this->props_.find (prop_name) == -1) 01132 ACE_THROW (CosTrading::Register::UnknownPropertyName (dname)); 01133 } 01134 } 01135 01136 // Delete those properties from the offer. 01137 for (i = 0; i < length; i++) 01138 { 01139 CORBA::String_var prop_name = 01140 static_cast<const char *> (deletes[i]); 01141 this->props_.unbind (prop_name); 01142 } 01143 } |
|
Copy to the destination the union of the source and destination properties. In the case of duplicate properties, update the destination with the source's value. This class claims the memory in the modifies sequence. Definition at line 1147 of file Trader_Utils.cpp. References ACE_CHECK, ACE_ENV_ARG_PARAMETER, ACE_THROW, ACE_Unbounded_Set< T >::insert(), TAO_Property_Evaluator::is_dynamic_property(), TAO_Trader_Base::is_valid_property_name(), TAO_Property_Evaluator::property_type(), CosTrading::PropertySeq, and TAO_String_Set. Referenced by TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::modify().
01154 { 01155 int i = 0, length = 0; 01156 TAO_String_Set modify_me; 01157 01158 // Ensure that the proposed changes aren't to readonly properties or 01159 // otherwise invalid. 01160 TAO_Property_Evaluator prop_eval (modifies); 01161 for (i = 0, length = modifies.length (); i < length; i++) 01162 { 01163 const char* mname = modifies[i].name; 01164 if (TAO_Trader_Base::is_valid_property_name (mname)) 01165 { 01166 CORBA::String_var prop_name (mname); 01167 if (this->readonly_.find (prop_name) == 0) 01168 { 01169 // Can't assign a dynamic property to a property with 01170 // readonly mode, and can't reassign a readonly property. 01171 if (prop_eval.is_dynamic_property (i)) 01172 ACE_THROW (CosTrading::ReadonlyDynamicProperty (this->type_, mname)); 01173 else if (this->props_.find (prop_name) == 0) 01174 ACE_THROW (CosTrading::Register::ReadonlyProperty (this->type_, mname)); 01175 } 01176 01177 // Validate the property type if the property is defined in 01178 // the service type description. 01179 CORBA::TypeCode_ptr type_def = 0; 01180 if (this->prop_types_.find (prop_name, type_def) == 0) 01181 { 01182 CORBA::TypeCode_var prop_type = prop_eval.property_type (i); 01183 01184 // @@ Frank: This code used to have this comment and line 01185 // of code before I fixed the "ACE_TRY" fuzz warning here. 01186 // @@ Seth, are we trying to ignore the exception here? 01187 // CORBA::Environment ACE_TRY_ENV; 01188 // @@ Frank: It seems clear that this is not going to work as 01189 // expected. Is the purpose to ignore any exceptions from 01190 // equal ()? For now, exceptions are returned since this 01191 // seemed "safest". 01192 01193 CORBA::Boolean td_equal = 01194 type_def->equal (prop_type.in () ACE_ENV_ARG_PARAMETER); 01195 ACE_CHECK; 01196 01197 if (!td_equal) 01198 ACE_THROW (CosTrading::PropertyTypeMismatch (mname, modifies[i])); 01199 } 01200 01201 if (modify_me.insert (prop_name) == 1) 01202 ACE_THROW (CosTrading::DuplicatePropertyName (mname)); 01203 } 01204 else 01205 ACE_THROW (CosTrading::IllegalPropertyName (mname)); 01206 } 01207 } |
|
|
|
Definition at line 643 of file Trader_Utils.h. Referenced by TAO_Offer_Modifier(). |
|
A reference to the offer undergoing change.
Definition at line 646 of file Trader_Utils.h. |
|
Table of property types.
Definition at line 638 of file Trader_Utils.h. Referenced by TAO_Offer_Modifier(). |
|
The map of properties in the offer.
Definition at line 635 of file Trader_Utils.h. |
|
The set of readonly and mandatory property names in the offer's type. Definition at line 642 of file Trader_Utils.h. Referenced by TAO_Offer_Modifier(). |
|
The type of the offer.
Definition at line 632 of file Trader_Utils.h. |