#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) |
virtual void | withdraw (const char *id) |
virtual CosTrading::Register::OfferInfo * | describe (const char *id) |
virtual void | modify (const char *id, const CosTrading::PropertyNameSeq &del_list, const CosTrading::PropertySeq &modify_list) |
virtual void | withdraw_using_constraint (const char *type, const char *constr) |
virtual CosTrading::Register_ptr | resolve (const CosTrading::TraderName &name) |
Protected Member Functions | |
void | validate_properties (const char *type, const CosTradingRepos::ServiceTypeRepository::TypeStruct *type_struct, const CosTrading::PropertySeq &properties) |
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 268 of file Trader_Interfaces.h.
TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::TAO_Register | ( | TAO_Trader< TRADER_LOCK_TYPE, MAP_LOCK_TYPE > & | trader | ) |
Definition at line 787 of file Trader_Interfaces.cpp.
00788 : TAO_Trader_Components<POA_CosTrading::Register> (trader.trading_components ()), 00789 TAO_Support_Attributes<POA_CosTrading::Register> (trader.support_attributes ()), 00790 trader_ (trader) 00791 { 00792 }
TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::~TAO_Register | ( | void | ) | [virtual] |
TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::TAO_Register | ( | const TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE > & | ) | [protected] |
CosTrading::OfferId TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::_cxx_export | ( | CORBA::Object_ptr | reference, | |
const char * | type, | |||
const CosTrading::PropertySeq & | properties | |||
) | [virtual] |
Definition at line 802 of file Trader_Interfaces.cpp.
References ACE_NEW_THROW_EX, TAO_Offer_Database< LOCK_TYPE >::insert_offer(), CORBA::is_nil(), CosTrading::Offer::properties, CosTrading::Offer::reference, TAO_Support_Attributes_i::service_type_repos(), TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::trader_, and TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::validate_properties().
00805 { 00806 // For robustness purposes -- 00807 if (CORBA::is_nil (reference)) 00808 throw CosTrading::Register::InvalidObjectRef (); 00809 00810 // Get service type map 00811 TAO_Offer_Database<MAP_LOCK_TYPE> &offer_database = this->trader_.offer_database (); 00812 00813 CosTrading::Offer* offer = 0; 00814 TAO_Support_Attributes_i& support_attrs = 00815 this->trader_.support_attributes (); 00816 CosTradingRepos::ServiceTypeRepository_ptr rep = 00817 support_attrs.service_type_repos (); 00818 00819 // Yank our friend, the type struct, and confirm that the given 00820 // properties match the type definition. 00821 CosTradingRepos::ServiceTypeRepository::TypeStruct_var type_struct = 00822 rep->fully_describe_type (type); 00823 00824 // Oops the type is masked, we shouldn't let exporters know the type 00825 // exists. 00826 if (type_struct->masked) 00827 throw CosTrading::UnknownServiceType (type); 00828 00829 // TAO-specific way to determine if an object is derived from or is 00830 // an interface type. 00831 int check = (! reference->_is_a (type_struct->if_name)); 00832 if (check) 00833 throw CosTrading::Register::InterfaceTypeMismatch (type, reference); 00834 00835 // Validate that the properties defined for this offer are correct 00836 // to their types and strength. 00837 this->validate_properties (type, type_struct.ptr (), properties); 00838 00839 // CORBA::ULong plength = properties.length (); 00840 ACE_NEW_THROW_EX (offer, CosTrading::Offer, CORBA::NO_MEMORY ()); 00841 00842 // No copying, no memory leaks. Violates the "in" parameter semantics 00843 // when this object is colocated with the client, however. 00844 // CosTrading::PropertySeq* hack_seq = 00845 // const_cast<CosTrading::PropertySeq*> (&properties); 00846 // CosTrading::Property* pbuf = hack_seq->get_buffer (1); 00847 00848 // CosTrading::PropertySeq* hack_seq = 00849 // const_cast<CosTrading::PropertySeq*> (&properties); 00850 // CosTrading::Property* pbuf = hack_seq->get_buffer (0); 00851 // offer->properties.replace (plength, plength, pbuf, 0); 00852 // offer->properties._allocate_buffer (plength); 00853 offer->properties = properties; 00854 offer->reference = reference->_duplicate (reference); 00855 00856 // Insert the offer into the underlying type map. 00857 CosTrading::OfferId id = offer_database.insert_offer (type, offer); 00858 00859 return id; 00860 }
CosTrading::Register::OfferInfo * TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::describe | ( | const char * | id | ) | [virtual] |
Definition at line 875 of file Trader_Interfaces.cpp.
References CORBA::Object::_duplicate(), ACE_NEW_THROW_EX, TAO_Offer_Database< LOCK_TYPE >::lookup_offer(), CosTrading::Offer::properties, CosTrading::Register::OfferInfo::properties, CosTrading::Offer::reference, CosTrading::Register::OfferInfo::reference, CORBA::string_dup(), TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::trader_, and CosTrading::Register::OfferInfo::type.
00876 { 00877 // Get service type map. 00878 char* type = 0; 00879 TAO_Offer_Database<MAP_LOCK_TYPE> &offer_database = this->trader_.offer_database (); 00880 00881 // Perform a lookup to find the offer. 00882 CosTrading::Offer* offer = 00883 offer_database.lookup_offer ((CosTrading::OfferId) id, type); 00884 00885 CosTrading::Register::OfferInfo *offer_info = 0; 00886 ACE_NEW_THROW_EX (offer_info, CosTrading::Register::OfferInfo, CORBA::NO_MEMORY ()); 00887 00888 offer_info->reference = CORBA::Object::_duplicate (offer->reference.in ()); 00889 offer_info->type = CORBA::string_dup (type); 00890 00891 // Let the offer_info prop_seq "borrow" the sequence of properties. 00892 //CORBA::ULong length = offer->properties.length (); 00893 // CosTrading::Property* prop_buf = offer->properties.get_buffer (); 00894 offer_info->properties = offer->properties; 00895 00896 return offer_info; 00897 }
void TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::modify | ( | const char * | id, | |
const CosTrading::PropertyNameSeq & | del_list, | |||
const CosTrading::PropertySeq & | modify_list | |||
) | [virtual] |
Definition at line 902 of file Trader_Interfaces.cpp.
References TAO_Support_Attributes_i::service_type_repos(), TAO_Support_Attributes< POA_CosTrading::Register >::supports_modifiable_properties(), and TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::trader_.
00905 { 00906 // Throw an exception if the trader is not configured 00907 // to support properties modification. 00908 int check = (! this->supports_modifiable_properties ()); 00909 00910 if (check) 00911 throw CosTrading::NotImplemented (); 00912 00913 char* type = 0; 00914 TAO_Support_Attributes_i& support_attrs = 00915 this->trader_.support_attributes (); 00916 CosTradingRepos::ServiceTypeRepository_ptr rep = 00917 support_attrs.service_type_repos (); 00918 TAO_Offer_Database<MAP_LOCK_TYPE> &offer_database = this->trader_.offer_database (); 00919 00920 CosTrading::Offer* offer = offer_database. 00921 lookup_offer (const_cast<CosTrading::OfferId> (id), type); 00922 00923 if (offer != 0) 00924 { 00925 // Yank our friend, the type struct. 00926 CosTradingRepos::ServiceTypeRepository::TypeStruct_var type_struct = 00927 rep->fully_describe_type (type); 00928 TAO_Offer_Modifier offer_mod (type, type_struct.in (), offer); 00929 00930 // Delete, add, and change properties of the offer. 00931 offer_mod.delete_properties (del_list); 00932 00933 offer_mod.merge_properties (modify_list); 00934 00935 // Alter our reference to the offer. We do this last, since the 00936 // spec says: modify either suceeds completely or fails 00937 // completely. 00938 offer_mod.affect_change (modify_list); 00939 } 00940 }
void TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::operator= | ( | const TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE > & | ) | [protected] |
CosTrading::Register_ptr TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::resolve | ( | const CosTrading::TraderName & | name | ) | [virtual] |
Definition at line 1009 of file Trader_Interfaces.cpp.
References CORBA::is_nil(), TAO_Trader_Base::is_valid_link_name(), TAO_Trader_Components< POA_CosTrading::Register >::link_if(), and TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::trader_.
01010 { 01011 // Determine if the first link is a legal link name. 01012 if (! TAO_Trader_Base::is_valid_link_name (name[0])) 01013 throw CosTrading::Register::IllegalTraderName (name); 01014 01015 // Grab a reference to the link interface, and get a link description. 01016 CosTrading::Link_ptr link_if = 01017 this->trader_.trading_components ().link_if (); 01018 01019 // Ensure that the link interface is supported. 01020 if (! CORBA::is_nil (link_if)) 01021 return CosTrading::Register::_nil (); 01022 01023 CosTrading::Link::LinkInfo_var link_info; 01024 CosTrading::Register_var remote_reg; 01025 01026 try 01027 { 01028 // Ensure that the link to the next trader exists. 01029 link_info = link_if->describe_link (name[0]); 01030 01031 remote_reg = 01032 CosTrading::Register::_narrow (link_info->target_reg.in ()); 01033 } 01034 catch (const CORBA::Exception&) 01035 { 01036 throw CosTrading::Register::UnknownTraderName (name); 01037 } 01038 01039 // Ensure that the register pointer isn't nil. 01040 if (! CORBA::is_nil (remote_reg.in ())) 01041 throw CosTrading::Register::RegisterNotSupported (name); 01042 01043 CosTrading::Register_ptr return_value = remote_reg.in (); 01044 01045 if (name.length () > 1) 01046 { 01047 // Create a new Trader Name with the first link removed. 01048 CosTrading::TraderName trader_name (name.length () - 1); 01049 for (int i = trader_name.length () - 1; i >= 0; i--) 01050 trader_name[i] = name[i + 1]; 01051 01052 return_value = remote_reg->resolve (trader_name); 01053 } 01054 01055 return return_value; 01056 }
void TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::validate_properties | ( | const char * | type, | |
const CosTradingRepos::ServiceTypeRepository::TypeStruct * | type_struct, | |||
const CosTrading::PropertySeq & | properties | |||
) | [protected] |
Definition at line 1061 of file Trader_Interfaces.cpp.
References TAO_Property_Evaluator_By_Name::get_property(), TAO_Pseudo_Var_T< T >::in(), TAO_Property_Evaluator_By_Name::is_dynamic_property(), CORBA::is_nil(), CosTradingRepos::ServiceTypeRepository::PROP_MANDATORY, CosTradingRepos::ServiceTypeRepository::PROP_READONLY, TAO_Property_Evaluator_By_Name::property_type(), and CosTradingRepos::ServiceTypeRepository::TypeStruct::props.
Referenced by TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::_cxx_export().
01064 { 01065 CORBA::ULong length = properties.length (); 01066 const CosTradingRepos::ServiceTypeRepository::PropStructSeq& 01067 prop_types = type_struct->props; 01068 TAO_Property_Evaluator_By_Name prop_eval (properties); 01069 01070 // Perform property validation 01071 length = prop_types.length (); 01072 01073 for (CORBA::ULong i = 0; i < length; i++) 01074 { 01075 const CosTradingRepos::ServiceTypeRepository::PropStruct& 01076 prop_struct = prop_types[i]; 01077 const char* prop_name = prop_struct.name; 01078 01079 // Obtain the type of the exported property. 01080 CORBA::TypeCode_var prop_type = prop_eval.property_type (prop_name); 01081 01082 if (CORBA::is_nil (prop_type.in ())) 01083 { 01084 // Offer cannot have a missing mandatory property. 01085 if (prop_types[i].mode == 01086 CosTradingRepos::ServiceTypeRepository::PROP_MANDATORY) 01087 throw CosTrading::MissingMandatoryProperty (type, prop_name); 01088 } 01089 else 01090 { 01091 int check = 01092 (! prop_type->equal (prop_struct.value_type.in ())); 01093 if (check) 01094 { 01095 // Offer cannot redefine the type of an property. 01096 const CosTrading::Property* prop = 01097 prop_eval.get_property (prop_name); 01098 throw CosTrading::PropertyTypeMismatch (type, *prop); 01099 } 01100 else if (prop_struct.mode == 01101 CosTradingRepos::ServiceTypeRepository::PROP_READONLY && 01102 prop_eval.is_dynamic_property (prop_name)) 01103 throw CosTrading::ReadonlyDynamicProperty (type, prop_name); 01104 } 01105 } 01106 }
void TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::withdraw | ( | const char * | id | ) | [virtual] |
Definition at line 865 of file Trader_Interfaces.cpp.
References TAO_Offer_Database< LOCK_TYPE >::remove_offer(), and TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::trader_.
00866 { 00867 // Get service type map. 00868 TAO_Offer_Database<MAP_LOCK_TYPE> &offer_database = this->trader_.offer_database (); 00869 offer_database.remove_offer ((CosTrading::OfferId) id); 00870 }
void TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::withdraw_using_constraint | ( | const char * | type, | |
const char * | constr | |||
) | [virtual] |
Definition at line 945 of file Trader_Interfaces.cpp.
References ACE_Unbounded_Queue< T >::dequeue_head(), ACE_Unbounded_Queue< T >::enqueue_tail(), 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_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::trader_.
00947 { 00948 TAO_Support_Attributes_i& 00949 support_attrs = this->trader_.support_attributes (); 00950 CosTradingRepos::ServiceTypeRepository_ptr rep = 00951 support_attrs.service_type_repos (); 00952 TAO_Offer_Database<MAP_LOCK_TYPE> &offer_database = this->trader_.offer_database (); 00953 CORBA::Boolean dp_support = support_attrs.supports_dynamic_properties (); 00954 TAO_String_Queue ids; 00955 00956 // Retrieve the type struct 00957 CosTradingRepos::ServiceTypeRepository::TypeStruct_var type_struct = 00958 rep->fully_describe_type (type); 00959 00960 // Try to find the map of offers of desired service type. 00961 // @@ Again, should be Offer_Database::offer_iterator 00962 { 00963 #if defined (_MSC_VER) 00964 TAO_Offer_Database<MAP_LOCK_TYPE>::offer_iterator 00965 offer_iter (type, offer_database); 00966 #else 00967 // MSVC won't grok this for some reason, but it's necessary for 00968 // the HP compiler, which seriously requires the typename keyword 00969 // here. I apologize if this ifdef offends some ACE users' 00970 // sensibilities --- it certainly offends mine. 00971 typename TAO_Offer_Database<MAP_LOCK_TYPE>::offer_iterator 00972 offer_iter (type, offer_database); 00973 #endif /* _MSC_VER */ 00974 00975 TAO_Trader_Constraint_Validator validator (type_struct.in ()); 00976 TAO_Constraint_Interpreter constr_inter (validator, constr); 00977 00978 while (offer_iter.has_more_offers ()) 00979 { 00980 CosTrading::Offer* offer = offer_iter.get_offer (); 00981 // Add offer if it matches the constraints 00982 00983 TAO_Trader_Constraint_Evaluator evaluator (offer, dp_support); 00984 if (constr_inter.evaluate (evaluator)) 00985 ids.enqueue_tail (offer_iter.get_id ()); 00986 00987 offer_iter.next_offer (); 00988 } 00989 } 00990 00991 if (ids.size () != 0) 00992 { 00993 while (! ids.is_empty ()) 00994 { 00995 char* offer_id = 0; 00996 00997 ids.dequeue_head (offer_id); 00998 offer_database.remove_offer (offer_id); 00999 CORBA::string_free (offer_id); 01000 } 01001 } 01002 else 01003 throw CosTrading::Register::NoMatchingOffers (constr); 01004 }
TAO_Trader<TRADER_LOCK_TYPE,MAP_LOCK_TYPE>& TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::trader_ [private] |
Definition at line 489 of file Trader_Interfaces.h.
Referenced by TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::_cxx_export(), TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::describe(), TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::modify(), TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::resolve(), TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::withdraw(), and TAO_Register< TRADER_LOCK_TYPE, MAP_LOCK_TYPE >::withdraw_using_constraint().