#include <Trader_Utils.h>
Inheritance diagram for TAO_Property_Evaluator:
Public Member Functions | |
TAO_Property_Evaluator (const CosTrading::PropertySeq &properties, CORBA::Boolean supports_dp=1) | |
TAO_Property_Evaluator (CosTrading::Offer &offer, CORBA::Boolean supports_dp=1) | |
virtual | ~TAO_Property_Evaluator (void) |
Clean up dynamic properties. | |
int | is_dynamic_property (int index) |
CORBA::Any * | property_value (int index) throw (CosTradingDynamic::DPEvalFailure) |
CORBA::TypeCode_ptr | property_type (int index) |
Protected Types | |
typedef CosTradingDynamic::DynamicProp | DP_Struct |
typedef CosTradingDynamic::DynamicPropEval | DP_Eval |
Protected Attributes | |
const CosTrading::PropertySeq & | props_ |
int | supports_dp_ |
CORBA::Any ** | dp_cache_ |
Private Member Functions | |
TAO_Property_Evaluator (const TAO_Property_Evaluator &) | |
TAO_Property_Evaluator & | operator= (const TAO_Property_Evaluator &) |
Definition at line 42 of file Trader_Utils.h.
|
Definition at line 90 of file Trader_Utils.h. |
|
Definition at line 89 of file Trader_Utils.h. |
|
Definition at line 193 of file Trader_Utils.cpp. References dp_cache_, and CosTrading::PropertySeq.
|
|
Construct an instance of TAO_Property_Evaluator that operates on an where the support for dynamic properties is dictated by . Definition at line 208 of file Trader_Utils.cpp. References dp_cache_.
00210 : props_ (offer.properties), 00211 supports_dp_ (supports_dp), 00212 dp_cache_ (new CORBA::Any*[offer.properties.length ()]) 00213 { 00214 if (this->dp_cache_ != 0) 00215 for (CORBA::ULong i = 0; i < this->props_.length (); i++) 00216 this->dp_cache_[i] = 0; 00217 } |
|
Clean up dynamic properties.
Definition at line 219 of file Trader_Utils.cpp. References dp_cache_.
|
|
|
|
Returns 1 if the property at index is dynamic. Returns a 0 when the index is out of bounds. Definition at line 230 of file Trader_Utils.cpp. References ACE_CHECK_RETURN, ACE_DECLARE_NEW_CORBA_ENV, and ACE_ENV_ARG_PARAMETER. Referenced by TAO_Property_Evaluator_By_Name::is_dynamic_property(), TAO_Offer_Modifier::merge_properties(), TAO_Offer_Filter::ok_to_consider(), and property_type().
00231 { 00232 int return_value = 0; 00233 int num_properties = this->props_.length(); 00234 00235 // Ensure index is in bounds. 00236 if (index >= 0 && index < num_properties) 00237 { 00238 // Obtain the value of the property at index <index>. 00239 const CORBA::Any& value = this->props_[index].value; 00240 CORBA::TypeCode_var type = value.type (); 00241 00242 // @@ Seth, this will not work on platforms using environment variable. 00243 ACE_DECLARE_NEW_CORBA_ENV; 00244 CORBA::Boolean equal = type->equal (CosTradingDynamic::_tc_DynamicProp 00245 ACE_ENV_ARG_PARAMETER); 00246 ACE_CHECK_RETURN (0); 00247 00248 if (equal) 00249 return_value = 1; 00250 } 00251 00252 return return_value; 00253 } |
|
|
|
Returns the type of the property whose index is . If the property is dynamic and the trader supports dynamic properties, then the method returns the field of the CosTradingDynamic::DynamicProp struct associated with the property name. If the index is out of bounds, the method returns a null pointer (that is, 0). Definition at line 319 of file Trader_Utils.cpp. References is_dynamic_property(). Referenced by TAO_Offer_Modifier::merge_properties(), and TAO_Property_Evaluator_By_Name::property_type().
00320 { 00321 CORBA::TypeCode_ptr prop_type = CORBA::TypeCode::_nil(); 00322 00323 // Determine if property is both defined and dynamic. 00324 if (this->is_dynamic_property (index)) 00325 { 00326 // Extract type information from the DP_Struct. 00327 const CORBA::Any& value = this->props_[index].value; 00328 CosTradingDynamic::DynamicProp* dp_struct = 0; 00329 value >>= dp_struct; 00330 00331 // Grab a pointer to the returned_type description 00332 prop_type = CORBA::TypeCode::_duplicate (dp_struct->returned_type.in ()); 00333 } 00334 else 00335 // TypeCode is self-evident at this point. 00336 prop_type = this->props_[index].value.type (); 00337 00338 return prop_type; 00339 } |
|
Returns value of the property whose index is . If the property at that index is dynamic and the trader supports dynamic properties, then the property_value method will obtain the value of the dynamic property using the evalDP method on the CosTradingDynamic::DynamicPropEval interface, passing on a CosTradingDynamic::DPEvalFailure exception on failure. If the property index is undefined, the method returns a null pointer. Definition at line 256 of file Trader_Utils.cpp. References ACE_CATCH, ACE_CHECK_RETURN, ACE_ENDTRY, ACE_ENV_ARG_PARAMETER, ACE_THROW_RETURN, ACE_TRY, ACE_TRY_CHECK, ACE_TRY_THROW, and CORBA::is_nil(). Referenced by TAO_Property_Evaluator_By_Name::property_value(), and TAO_Trader_Constraint_Evaluator::visit_property().
00259 { 00260 CORBA::Any* prop_val = 0; 00261 CORBA::Boolean in_cache = 00262 this->dp_cache_ != 0 && this->dp_cache_[index] != 0; 00263 00264 int dynamic = this->is_dynamic_property (index); 00265 00266 if (!dynamic) 00267 prop_val = (CORBA::Any *) &(this->props_[index].value); 00268 else if (this->supports_dp_ && in_cache) 00269 prop_val = this->dp_cache_[index]; 00270 else if (this->supports_dp_) 00271 { 00272 // Property is defined at this point. 00273 CosTradingDynamic::DynamicProp* dp_struct; 00274 const CORBA::String_var name = this->props_[index].name.in (); 00275 const CORBA::Any& value = this->props_[index].value; 00276 00277 // Extract the DP_Struct. 00278 value >>= dp_struct; 00279 00280 CosTradingDynamic::DynamicPropEval_var dp_eval = 00281 CosTradingDynamic::DynamicPropEval::_duplicate (dp_struct->eval_if.in ()); 00282 00283 if (CORBA::is_nil (dp_eval.in ())) 00284 { 00285 ACE_THROW_RETURN (CosTradingDynamic:: 00286 DPEvalFailure (name, 00287 CORBA::TypeCode::_nil (), 00288 CORBA::Any ()), 00289 prop_val); 00290 } 00291 else 00292 { 00293 CORBA::TypeCode* type = dp_struct->returned_type.in (); 00294 CORBA::Any& info = dp_struct->extra_info; 00295 00296 ACE_TRY 00297 { 00298 // Retrieve the value of the dynamic property. 00299 prop_val = dp_eval->evalDP(name, type, info ACE_ENV_ARG_PARAMETER); 00300 ACE_TRY_CHECK; 00301 00302 if (this->dp_cache_ != 0) 00303 this->dp_cache_[index] = prop_val; 00304 } 00305 ACE_CATCH (CORBA::SystemException, excp) 00306 { 00307 ACE_TRY_THROW 00308 (CosTradingDynamic::DPEvalFailure (name, type, info)); 00309 } 00310 ACE_ENDTRY; 00311 ACE_CHECK_RETURN (prop_val); 00312 } 00313 } 00314 00315 return prop_val; 00316 } |
|
In order for the client to treat the results of property_value uniformly, we need to collect the dynamically allocated anys retrieved from dynamic properties and free them upon deletion. If we didn't do this, then the property_value method would leak or cause seg faults, since the client wouldn't be able to tell whether or not the return value should be freed. Definition at line 106 of file Trader_Utils.h. Referenced by TAO_Property_Evaluator(), and ~TAO_Property_Evaluator(). |
|
The offer from which the TAO_Property_Evaluator extracts property information. Definition at line 94 of file Trader_Utils.h. |
|
Definition at line 96 of file Trader_Utils.h. |