#include <Trader_Interfaces.h>
Inheritance diagram for TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >:
Public Member Functions | |
TAO_Register (TAO_Trader< TRADER_LOCK_TYPE, MAP_LOCK_TYPE > &trader) | |
virtual | ~TAO_Register (void) |
virtual CosTrading::OfferId | _cxx_export (CORBA::Object_ptr reference, const char *type, const CosTrading::PropertySeq &properties) throw (CORBA::SystemException, CosTrading::Register::InvalidObjectRef, CosTrading::IllegalServiceType, CosTrading::UnknownServiceType, CosTrading::Register::InterfaceTypeMismatch, CosTrading::IllegalPropertyName, CosTrading::PropertyTypeMismatch, CosTrading::ReadonlyDynamicProperty, CosTrading::MissingMandatoryProperty, CosTrading::DuplicatePropertyName) |
virtual void | withdraw (const char *id) throw (CORBA::SystemException, CosTrading::IllegalOfferId, CosTrading::UnknownOfferId, CosTrading::Register::ProxyOfferId) |
virtual CosTrading::Register::OfferInfo * | describe (const char *id) throw (CORBA::SystemException, CosTrading::IllegalOfferId, CosTrading::UnknownOfferId, CosTrading::Register::ProxyOfferId) |
virtual void | modify (const char *id, const CosTrading::PropertyNameSeq &del_list, const CosTrading::PropertySeq &modify_list) throw (CORBA::SystemException, CosTrading::NotImplemented, CosTrading::IllegalOfferId, CosTrading::UnknownOfferId, CosTrading::Register::ProxyOfferId, CosTrading::IllegalPropertyName, CosTrading::Register::UnknownPropertyName, CosTrading::PropertyTypeMismatch, CosTrading::ReadonlyDynamicProperty, CosTrading::Register::MandatoryProperty, CosTrading::Register::ReadonlyProperty, CosTrading::DuplicatePropertyName) |
virtual void | withdraw_using_constraint (const char *type, const char *constr) throw (CORBA::SystemException, CosTrading::IllegalServiceType, CosTrading::UnknownServiceType, CosTrading::IllegalConstraint, CosTrading::Register::NoMatchingOffers) |
virtual CosTrading::Register_ptr | resolve (const CosTrading::TraderName &name) throw (CORBA::SystemException, CosTrading::Register::IllegalTraderName, CosTrading::Register::UnknownTraderName, CosTrading::Register::RegisterNotSupported) |
Protected Member Functions | |
void | validate_properties (const char *type, const CosTradingRepos::ServiceTypeRepository::TypeStruct *type_struct, const CosTrading::PropertySeq &properties) throw (CosTrading::IllegalPropertyName, CosTrading::PropertyTypeMismatch, CosTrading::ReadonlyDynamicProperty, CosTrading::MissingMandatoryProperty, CosTrading::DuplicatePropertyName) |
void | operator= (const TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE > &) |
TAO_Register (const TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE > &) | |
Private Attributes | |
TAO_Trader< TRADER_LOCK_TYPE, MAP_LOCK_TYPE > & | trader_ |
Definition at line 314 of file Trader_Interfaces.h.
|
Definition at line 888 of file Trader_Interfaces.cpp.
00889 : TAO_Trader_Components<POA_CosTrading::Register> (trader.trading_components ()), 00890 TAO_Support_Attributes<POA_CosTrading::Register> (trader.support_attributes ()), 00891 trader_ (trader) 00892 { 00893 } |
|
Definition at line 896 of file Trader_Interfaces.cpp.
00897 { 00898 } |
|
|
|
Definition at line 903 of file Trader_Interfaces.cpp. References ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, ACE_NEW_THROW_EX, ACE_THROW_RETURN, TAO_Offer_Database< LOCK_TYPE >::insert_offer(), CORBA::is_nil(), CosTrading::OfferId, CosTrading::Offer::properties, CosTrading::PropertySeq, CosTrading::Offer::reference, and TAO_Support_Attributes_i::service_type_repos().
00917 { 00918 // For robustness purposes -- 00919 if (CORBA::is_nil (reference)) 00920 ACE_THROW_RETURN (CosTrading::Register::InvalidObjectRef (), 0); 00921 00922 // Get service type map 00923 TAO_Offer_Database<MAP_LOCK_TYPE> &offer_database = this->trader_.offer_database (); 00924 00925 CosTrading::Offer* offer = 0; 00926 TAO_Support_Attributes_i& support_attrs = 00927 this->trader_.support_attributes (); 00928 CosTradingRepos::ServiceTypeRepository_ptr rep = 00929 support_attrs.service_type_repos (); 00930 00931 // Yank our friend, the type struct, and confirm that the given 00932 // properties match the type definition. 00933 CosTradingRepos::ServiceTypeRepository::TypeStruct_var type_struct = 00934 rep->fully_describe_type (type ACE_ENV_ARG_PARAMETER); 00935 ACE_CHECK_RETURN (0); 00936 00937 // Oops the type is masked, we shouldn't let exporters know the type 00938 // exists. 00939 if (type_struct->masked) 00940 ACE_THROW_RETURN (CosTrading::UnknownServiceType (type), 0); 00941 00942 // TAO-specific way to determine if an object is derived from or is 00943 // an interface type. 00944 int check = (! reference->_is_a (type_struct->if_name ACE_ENV_ARG_PARAMETER)); 00945 ACE_CHECK_RETURN (0); 00946 if (check) 00947 ACE_THROW_RETURN (CosTrading::Register:: 00948 InterfaceTypeMismatch (type, reference), 0); 00949 00950 // Validate that the properties defined for this offer are correct 00951 // to their types and strength. 00952 this->validate_properties (type, type_struct.ptr (), properties ACE_ENV_ARG_PARAMETER); 00953 ACE_CHECK_RETURN (0); 00954 00955 // CORBA::ULong plength = properties.length (); 00956 ACE_NEW_THROW_EX (offer, CosTrading::Offer, CORBA::NO_MEMORY ()); 00957 ACE_CHECK_RETURN (0); 00958 00959 // No copying, no memory leaks. Violates the "in" parameter semantics 00960 // when this object is colocated with the client, however. 00961 // CosTrading::PropertySeq* hack_seq = 00962 // const_cast<CosTrading::PropertySeq*> (&properties); 00963 // CosTrading::Property* pbuf = hack_seq->get_buffer (1); 00964 00965 // CosTrading::PropertySeq* hack_seq = 00966 // const_cast<CosTrading::PropertySeq*> (&properties); 00967 // CosTrading::Property* pbuf = hack_seq->get_buffer (0); 00968 // offer->properties.replace (plength, plength, pbuf, 0); 00969 // offer->properties._allocate_buffer (plength); 00970 offer->properties = properties; 00971 offer->reference = reference->_duplicate (reference); 00972 00973 // Insert the offer into the underlying type map. 00974 CosTrading::OfferId id = offer_database.insert_offer (type, offer); 00975 00976 return id; 00977 } |
|
Definition at line 997 of file Trader_Interfaces.cpp. References CORBA::Object::_duplicate(), ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, ACE_NEW_THROW_EX, TAO_Offer_Database< LOCK_TYPE >::lookup_offer(), CosTrading::OfferId, CosTrading::Offer::properties, CosTrading::Register::OfferInfo::properties, CosTrading::Offer::reference, CosTrading::Register::OfferInfo::reference, CORBA::string_dup(), and CosTrading::Register::OfferInfo::type.
01003 { 01004 // Get service type map. 01005 char* type = 0; 01006 TAO_Offer_Database<MAP_LOCK_TYPE> &offer_database = this->trader_.offer_database (); 01007 01008 // Perform a lookup to find the offer. 01009 CosTrading::Offer* offer = 01010 offer_database.lookup_offer ((CosTrading::OfferId) id, type ACE_ENV_ARG_PARAMETER); 01011 ACE_CHECK_RETURN (0); 01012 01013 CosTrading::Register::OfferInfo *offer_info = 0; 01014 ACE_NEW_THROW_EX (offer_info, CosTrading::Register::OfferInfo, CORBA::NO_MEMORY ()); 01015 ACE_CHECK_RETURN (0); 01016 01017 offer_info->reference = CORBA::Object::_duplicate (offer->reference.in ()); 01018 offer_info->type = CORBA::string_dup (type); 01019 01020 // Let the offer_info prop_seq "borrow" the sequence of properties. 01021 //CORBA::ULong length = offer->properties.length (); 01022 // CosTrading::Property* prop_buf = offer->properties.get_buffer (); 01023 offer_info->properties = offer->properties; 01024 01025 return offer_info; 01026 } |
|
Definition at line 1031 of file Trader_Interfaces.cpp. References ACE_CHECK, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_THROW, TAO_Offer_Modifier::affect_change(), TAO_Offer_Modifier::delete_properties(), TAO_Offer_Modifier::merge_properties(), CosTrading::PropertyNameSeq, CosTrading::PropertySeq, and TAO_Support_Attributes_i::service_type_repos().
01047 { 01048 // Throw an exception if the trader is not configured 01049 // to support properties modification. 01050 int check = (! this->supports_modifiable_properties (ACE_ENV_SINGLE_ARG_PARAMETER)); 01051 ACE_CHECK; 01052 01053 if (check) 01054 ACE_THROW (CosTrading::NotImplemented ()); 01055 01056 char* type = 0; 01057 TAO_Support_Attributes_i& support_attrs = 01058 this->trader_.support_attributes (); 01059 CosTradingRepos::ServiceTypeRepository_ptr rep = 01060 support_attrs.service_type_repos (); 01061 TAO_Offer_Database<MAP_LOCK_TYPE> &offer_database = this->trader_.offer_database (); 01062 01063 CosTrading::Offer* offer = offer_database. 01064 lookup_offer (const_cast<CosTrading::OfferId> (id), type ACE_ENV_ARG_PARAMETER); 01065 ACE_CHECK; 01066 01067 if (offer != 0) 01068 { 01069 // Yank our friend, the type struct. 01070 CosTradingRepos::ServiceTypeRepository::TypeStruct_var type_struct = 01071 rep->fully_describe_type (type ACE_ENV_ARG_PARAMETER); 01072 ACE_CHECK; 01073 TAO_Offer_Modifier offer_mod (type, type_struct.in (), offer); 01074 01075 // Delete, add, and change properties of the offer. 01076 offer_mod.delete_properties (del_list ACE_ENV_ARG_PARAMETER); 01077 ACE_CHECK; 01078 01079 offer_mod.merge_properties (modify_list ACE_ENV_ARG_PARAMETER); 01080 ACE_CHECK; 01081 01082 // Alter our reference to the offer. We do this last, since the 01083 // spec says: modify either suceeds completely or fails 01084 // completely. 01085 offer_mod.affect_change (modify_list); 01086 } 01087 } |
|
|
|
Definition at line 1165 of file Trader_Interfaces.cpp. References ACE_CATCHANY, ACE_CHECK_RETURN, ACE_ENDTRY, ACE_ENV_ARG_PARAMETER, ACE_THROW_RETURN, ACE_TRY, ACE_TRY_CHECK, ACE_TRY_THROW, CORBA::is_nil(), TAO_Trader_Base::is_valid_link_name(), and CosTrading::TraderName.
01171 { 01172 // Determine if the first link is a legal link name. 01173 if (! TAO_Trader_Base::is_valid_link_name (name[0])) 01174 ACE_THROW_RETURN (CosTrading::Register::IllegalTraderName (name), 01175 CosTrading::Register::_nil ()); 01176 01177 // Grab a reference to the link interface, and get a link description. 01178 CosTrading::Link_ptr link_if = 01179 this->trader_.trading_components ().link_if (); 01180 01181 // Ensure that the link interface is supported. 01182 if (! CORBA::is_nil (link_if)) 01183 return CosTrading::Register::_nil (); 01184 01185 CosTrading::Link::LinkInfo_var link_info; 01186 CosTrading::Register_var remote_reg; 01187 01188 ACE_TRY 01189 { 01190 // Ensure that the link to the next trader exists. 01191 link_info = link_if->describe_link (name[0] ACE_ENV_ARG_PARAMETER); 01192 ACE_TRY_CHECK; 01193 01194 remote_reg = 01195 CosTrading::Register::_narrow (link_info->target_reg.in () ACE_ENV_ARG_PARAMETER); 01196 ACE_TRY_CHECK; 01197 } 01198 ACE_CATCHANY 01199 { 01200 ACE_TRY_THROW (CosTrading::Register::UnknownTraderName (name)); 01201 } 01202 ACE_ENDTRY; 01203 ACE_CHECK_RETURN (CosTrading::Register::_nil ()); 01204 01205 // Ensure that the register pointer isn't nil. 01206 if (! CORBA::is_nil (remote_reg.in ())) 01207 ACE_THROW_RETURN (CosTrading::Register::RegisterNotSupported (name), 01208 CosTrading::Register::_nil ()); 01209 01210 CosTrading::Register_ptr return_value = remote_reg.in (); 01211 01212 if (name.length () > 1) 01213 { 01214 // Create a new Trader Name with the first link removed. 01215 CosTrading::TraderName trader_name (name.length () - 1); 01216 for (int i = trader_name.length () - 1; i >= 0; i--) 01217 trader_name[i] = name[i + 1]; 01218 01219 return_value = remote_reg->resolve (trader_name ACE_ENV_ARG_PARAMETER); 01220 ACE_CHECK_RETURN (CosTrading::Register::_nil ()); 01221 } 01222 01223 return return_value; 01224 } |
|
Definition at line 1229 of file Trader_Interfaces.cpp. References ACE_CHECK, ACE_ENV_ARG_PARAMETER, ACE_THROW, TAO_Property_Evaluator_By_Name::get_property(), TAO_Property_Evaluator_By_Name::is_dynamic_property(), CORBA::is_nil(), CosTradingRepos::ServiceTypeRepository::PropStruct::mode, CosTradingRepos::ServiceTypeRepository::PropStruct::name, TAO_Property_Evaluator_By_Name::property_type(), CosTrading::PropertySeq, CosTradingRepos::ServiceTypeRepository::PropStructSeq, and CosTradingRepos::ServiceTypeRepository::PropStruct::value_type.
01238 { 01239 CORBA::ULong length = properties.length (); 01240 const CosTradingRepos::ServiceTypeRepository::PropStructSeq& 01241 prop_types = type_struct->props; 01242 TAO_Property_Evaluator_By_Name prop_eval (properties ACE_ENV_ARG_PARAMETER); 01243 ACE_CHECK; 01244 01245 // Perform property validation 01246 length = prop_types.length (); 01247 01248 for (CORBA::ULong i = 0; i < length; i++) 01249 { 01250 const CosTradingRepos::ServiceTypeRepository::PropStruct& 01251 prop_struct = prop_types[i]; 01252 const char* prop_name = prop_struct.name; 01253 01254 // Obtain the type of the exported property. 01255 CORBA::TypeCode_var prop_type = prop_eval.property_type (prop_name); 01256 01257 if (CORBA::is_nil (prop_type.in ())) 01258 { 01259 // Offer cannot have a missing mandatory property. 01260 if (prop_types[i].mode == 01261 CosTradingRepos::ServiceTypeRepository::PROP_MANDATORY) 01262 ACE_THROW (CosTrading::MissingMandatoryProperty (type, prop_name)); 01263 } 01264 else 01265 { 01266 int check = 01267 (! prop_type->equal (prop_struct.value_type.in () 01268 ACE_ENV_ARG_PARAMETER)); 01269 ACE_CHECK; 01270 if (check) 01271 { 01272 // Offer cannot redefine the type of an property. 01273 const CosTrading::Property* prop = 01274 prop_eval.get_property (prop_name); 01275 ACE_THROW (CosTrading::PropertyTypeMismatch (type, *prop)); 01276 } 01277 else if (prop_struct.mode == 01278 CosTradingRepos::ServiceTypeRepository::PROP_READONLY && 01279 prop_eval.is_dynamic_property (prop_name)) 01280 ACE_THROW (CosTrading::ReadonlyDynamicProperty (type, prop_name)); 01281 } 01282 } 01283 } |
|
Definition at line 982 of file Trader_Interfaces.cpp. References ACE_ENV_ARG_PARAMETER, CosTrading::OfferId, and TAO_Offer_Database< LOCK_TYPE >::remove_offer().
00988 { 00989 // Get service type map. 00990 TAO_Offer_Database<MAP_LOCK_TYPE> &offer_database = this->trader_.offer_database (); 00991 offer_database.remove_offer ((CosTrading::OfferId) id ACE_ENV_ARG_PARAMETER); 00992 } |
|
Definition at line 1092 of file Trader_Interfaces.cpp. References ACE_CHECK, ACE_ENV_ARG_PARAMETER, ACE_THROW, ACE_Unbounded_Queue< T >::dequeue_head(), ACE_Unbounded_Queue< T >::enqueue_tail(), TAO_Constraint_Interpreter::evaluate(), ACE_Unbounded_Queue< T >::is_empty(), TAO_Offer_Database< LOCK_TYPE >::remove_offer(), TAO_Support_Attributes_i::service_type_repos(), ACE_Unbounded_Queue< T >::size(), CORBA::string_free(), TAO_Support_Attributes_i::supports_dynamic_properties(), and TAO_String_Queue.
01100 { 01101 TAO_Support_Attributes_i& 01102 support_attrs = this->trader_.support_attributes (); 01103 CosTradingRepos::ServiceTypeRepository_ptr rep = 01104 support_attrs.service_type_repos (); 01105 TAO_Offer_Database<MAP_LOCK_TYPE> &offer_database = this->trader_.offer_database (); 01106 CORBA::Boolean dp_support = support_attrs.supports_dynamic_properties (); 01107 TAO_String_Queue ids; 01108 01109 // Retrieve the type struct 01110 CosTradingRepos::ServiceTypeRepository::TypeStruct_var type_struct = 01111 rep->fully_describe_type (type ACE_ENV_ARG_PARAMETER); 01112 ACE_CHECK; 01113 01114 // Try to find the map of offers of desired service type. 01115 // @@ Again, should be Offer_Database::offer_iterator 01116 { 01117 #if defined (_MSC_VER) 01118 TAO_Offer_Database<MAP_LOCK_TYPE>::offer_iterator 01119 offer_iter (type, offer_database); 01120 #else 01121 // MSVC won't grok this for some reason, but it's necessary for 01122 // the HP compiler, which seriously requires the typename keyword 01123 // here. I apologize if this ifdef offends some ACE users' 01124 // sensibilities --- it certainly offends mine. 01125 ACE_TYPENAME TAO_Offer_Database<MAP_LOCK_TYPE>::offer_iterator 01126 offer_iter (type, offer_database); 01127 #endif /* _MSC_VER */ 01128 01129 TAO_Trader_Constraint_Validator validator (type_struct.in ()); 01130 TAO_Constraint_Interpreter constr_inter (validator, constr ACE_ENV_ARG_PARAMETER); 01131 ACE_CHECK; 01132 01133 while (offer_iter.has_more_offers ()) 01134 { 01135 CosTrading::Offer* offer = offer_iter.get_offer (); 01136 // Add offer if it matches the constraints 01137 01138 TAO_Trader_Constraint_Evaluator evaluator (offer, dp_support); 01139 if (constr_inter.evaluate (evaluator)) 01140 ids.enqueue_tail (offer_iter.get_id ()); 01141 01142 offer_iter.next_offer (); 01143 } 01144 } 01145 01146 if (ids.size () != 0) 01147 { 01148 while (! ids.is_empty ()) 01149 { 01150 char* offer_id = 0; 01151 01152 ids.dequeue_head (offer_id); 01153 offer_database.remove_offer (offer_id ACE_ENV_ARG_PARAMETER); 01154 ACE_CHECK; 01155 CORBA::string_free (offer_id); 01156 } 01157 } 01158 else 01159 ACE_THROW (CosTrading::Register::NoMatchingOffers (constr)); 01160 } |
|
Definition at line 585 of file Trader_Interfaces.h. |