00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Service_Type_Repository.h 00006 * 00007 * $Id: Service_Type_Repository.h 77067 2007-02-12 19:27:49Z johnnyw $ 00008 * 00009 * @author Marina Spivak <marina@cs.wustl.edu> 00010 * @author Seth Widoff <sbw1@cs.wustl.edu> 00011 */ 00012 //============================================================================= 00013 00014 00015 #ifndef TAO_SERVICE_TYPE_REPOSITORY_H 00016 #define TAO_SERVICE_TYPE_REPOSITORY_H 00017 #include /**/ "ace/pre.h" 00018 00019 #include "orbsvcs/Trader/Trader.h" 00020 #include "ace/Hash_Map_Manager.h" 00021 #include "ace/Null_Mutex.h" 00022 00023 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00024 00025 /** 00026 * @class TAO_Service_Type_Repository 00027 * 00028 * @brief This class implements CosTradingRepos::ServiceTypeRepository 00029 * IDL interface. 00030 */ 00031 class TAO_Trading_Serv_Export TAO_Service_Type_Repository 00032 : public POA_CosTradingRepos::ServiceTypeRepository 00033 { 00034 public: 00035 /** 00036 * Parameterize the Service_Type_Repository with a lock to serialize 00037 * access to the type repository map. A reader/writer lock is 00038 * probably best. The Service_Type_Repository assumes control of the 00039 * lock. 00040 */ 00041 TAO_Service_Type_Repository (ACE_Lock *lock = 0); 00042 00043 ~TAO_Service_Type_Repository (void); 00044 00045 virtual CosTradingRepos::ServiceTypeRepository::IncarnationNumber 00046 incarnation (void); 00047 00048 /** 00049 * BEGIN SPEC 00050 * The add_type operation enables the creation of new service types 00051 * in the service type repository. The caller supplies the "name" 00052 * for the new type, the identifier for the interface associated 00053 * with instances of this service type, the properties definitions 00054 * for this service type, and the service type names of the 00055 * immediate super-types to this service type. 00056 */ 00057 virtual CosTradingRepos::ServiceTypeRepository::IncarnationNumber 00058 add_type (const char *name, 00059 const char *if_name, 00060 const CosTradingRepos::ServiceTypeRepository::PropStructSeq &props, 00061 const CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq &super_types); 00062 00063 // If the type creation is successful, an incarnation number is 00064 // returned as the value of the operation. Incarnation numbers are 00065 // opaque values that are assigned to each modification to the 00066 // repository's state. An incarnation number can be quoted when 00067 // invoking the list_types operation to retrieve all changes to the 00068 // service repository since a particular logical time. (Note: 00069 // IncarnationNumber is currently declared as a struct consisting of 00070 // two unsigned longs; what we really want here is an unsigned hyper 00071 // [64-bit integer]. A future revision task force should modify this 00072 // when CORBA systems support IDL 64-bit integers.) 00073 00074 // If the "name" parameter is malformed, then the 00075 // CosTrading::IllegalServiceType exception is raised. If the type 00076 // already exists, then the ServiceTypeExists exception is raised. ° 00077 // If the "if_name" parameter is not a sub-type of the interface 00078 // associated with a service type from which this service type is 00079 // derived, such that substitutability would be violated, then the 00080 // InterfaceTypeMismatch exception is raised. If a property name 00081 // supplied in the "props" parameter is malformed, the 00082 // CosTrading::IllegalPropertyName exception is raised. If the 00083 // same property name appears two or more times in the "props" 00084 // parameter, the CosTrading::DuplicatePropertyName exception is 00085 // raised. If a property value type associated with this service 00086 // type illegally modifies the value type of a super-type's 00087 // property, or if two super-types incompatibly declare value types 00088 // for the same property name, then the ValueTypeRedefinition 00089 // exception is raised. If one of the ServiceTypeNames in 00090 // "super_types" is malformed, then the 00091 // CosTrading::IllegalServiceType exception is raised. If one of the 00092 // ServiceTypeNames in "super_types" does not exist, then the 00093 // CosTrading::UnknownServiceType exception is raised. If the same 00094 // service type name is included two or more times in this 00095 // parameter, the DuplicateServiceTypeName exception is raised. 00096 // END SPEC 00097 00098 /** 00099 * BEGIN SPEC 00100 * The remove_type operation removes the named type from the service 00101 * type repository. If "name" is malformed, then the 00102 * CosTrading::IllegalServiceType exception is raised. If 00103 * "name" does not exist within the repository, then the 00104 * CosTrading::UnknownServiceType exception is raised. If 00105 * "name" has a service type which has been derived from it, then 00106 * the HasSubTypes exception is raised. END SPEC 00107 */ 00108 virtual void remove_type (const char *name); 00109 00110 virtual CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq * 00111 list_types (const CosTradingRepos::ServiceTypeRepository::SpecifiedServiceTypes &which_types); 00112 00113 // BEGIN SPEC 00114 // The list_types operation permits a client to obtain the names of 00115 // service types which are in the repository. The "which_types" 00116 // parameter permits the client to specify one of two possible 00117 // values: all types known to the repository all types 00118 // added/modified since a particular incarnation number The names of 00119 // the requested types are returned by the operation for subsequent 00120 // querying via the describe_type or the fully_describe_type 00121 // operation. 00122 // END SPEC 00123 00124 /** 00125 * BEGIN SPEC 00126 * The describe_type operation permits a client to obtain the 00127 * details for a particular service type. If "name" is malformed, 00128 * then the CosTrading::IllegalServiceType exception is raised. If 00129 * "name" does not exist within the repository, then the 00130 * CosTrading::UnknownServiceType exception is raised. 00131 * END SPEC 00132 */ 00133 virtual CosTradingRepos::ServiceTypeRepository::TypeStruct * 00134 describe_type (const char *name); 00135 00136 /** 00137 * BEGIN SPEC 00138 * The fully_describe_type operation permits a client to obtain the 00139 * details for a particular service type. The property sequence 00140 * returned in the TypeStruct includes all properties inherited from 00141 * the transitive closure of its super types; the sequence of super 00142 * types in the TypeStruct contains the names of the types in the 00143 * transitive closure of the super type relation. If "name" is 00144 * malformed, then the CosTrading::IllegalServiceType exception is 00145 * raised. If "name" does not exist within the repository, then 00146 * the CosTrading::UnknownServiceType exception is raised. 00147 * END SPEC 00148 */ 00149 virtual CosTradingRepos::ServiceTypeRepository::TypeStruct * 00150 fully_describe_type (const char *name); 00151 00152 /** 00153 * BEGIN SPEC 00154 * The mask_type operation permits the deprecation of a particular 00155 * type (i.e., after being masked, exporters will no longer be able 00156 * to advertise offers of that particular type). The type continues 00157 * to exist in the service repository due to other service types 00158 * being derived from it. If "name" is malformed, then the 00159 * CosTrading::IllegalServiceType exception is raised. If "name" 00160 * does not exist within the repository, then the 00161 * CosTrading::UnknownServiceType exception is raised. If the type 00162 * is currently in the masked state, then the AlreadyMasked 00163 * exception is raised. 00164 * END SPEC 00165 */ 00166 virtual void mask_type (const char *name); 00167 00168 /** 00169 * BEGIN SPEC 00170 * The unmask_type undeprecates a type (i.e., after being unmasked, 00171 * exporters will be able to resume advertisement of offers of that 00172 * particular type). If "name" is malformed, then the 00173 * CosTrading::IllegalServiceType exception is raised. If "name" 00174 * does not exist within the repository, then the 00175 * CosTrading::UnknownServiceType exception is raised. If the type 00176 * is not currently in the masked state, then the NotMasked 00177 * exception is raised. 00178 * END SPEC 00179 */ 00180 virtual void unmask_type (const char *name); 00181 00182 private: 00183 00184 /** 00185 * @class Type_Info 00186 * 00187 * @brief Storage structure for information pertinent to the type. 00188 */ 00189 class Type_Info 00190 { 00191 public: 00192 /// Standard type info. 00193 CosTradingRepos::ServiceTypeRepository::TypeStruct type_struct_; 00194 00195 /// Names of subtypes. 00196 CORBA::Boolean has_subtypes_; 00197 }; 00198 00199 typedef ACE_Hash_Map_Manager_Ex <CORBA::String_var, 00200 CosTradingRepos::ServiceTypeRepository::PropStruct *, 00201 ACE_Hash<CORBA::String_var>, 00202 ACE_Equal_To<CORBA::String_var>, 00203 ACE_Null_Mutex> 00204 Prop_Map; 00205 00206 typedef ACE_Hash_Map_Manager_Ex <CORBA::String_var, 00207 Type_Info *, 00208 ACE_Hash<CORBA::String_var>, 00209 ACE_Equal_To<CORBA::String_var>, 00210 ACE_Null_Mutex> 00211 Service_Type_Map; 00212 00213 typedef ACE_Hash_Map_Iterator_Ex<CORBA::String_var, 00214 Type_Info *, 00215 ACE_Hash<CORBA::String_var>, 00216 ACE_Equal_To<CORBA::String_var>, 00217 ACE_Null_Mutex> 00218 Service_Type_Map_Iterator; 00219 00220 /** 00221 * Build a sequence aggregating the property names from all 00222 * supertypes of the type, and a sequence representing the 00223 * transitive closure of the super type relation. 00224 */ 00225 void fully_describe_type_i (const CosTradingRepos::ServiceTypeRepository::TypeStruct &type_struct, 00226 CosTradingRepos::ServiceTypeRepository::PropStructSeq &props, 00227 CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq &super_types); 00228 00229 void collect_inheritance_hierarchy (const CosTradingRepos::ServiceTypeRepository::TypeStruct &type_struct, 00230 TAO_String_Queue &target); 00231 00232 /// Confirm that the properties in props have valid names, and aren't 00233 /// duplicated. Cram those properties into the prop_map. 00234 void validate_properties (Prop_Map &prop_map, 00235 const CosTradingRepos::ServiceTypeRepository::PropStructSeq &props); 00236 00237 /// Confirm that the each super type exists, and cram them into super_map. 00238 void validate_supertypes (Service_Type_Map &super_map, 00239 const CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq &super_types); 00240 00241 /// Ensure that properties of a super_type aren't having their types 00242 /// or retstrictions redefined. 00243 void validate_inheritance (Prop_Map &prop_map, 00244 const CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq &super_types); 00245 00246 /// Update the type map with the information contained in the 00247 /// TypeStruct, prop_map, and super_map. 00248 void update_type_map (const char *name, 00249 const char *if_name, 00250 const CosTradingRepos::ServiceTypeRepository::PropStructSeq &props, 00251 const CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq &super_types, 00252 Prop_Map &prop_map, 00253 Service_Type_Map &super_map); 00254 00255 TAO_Service_Type_Repository (const TAO_Service_Type_Repository &); 00256 TAO_Service_Type_Repository &operator= (const TAO_Service_Type_Repository &); 00257 00258 /// Lock with which to serialize access to the service type map. 00259 ACE_Lock *lock_; 00260 00261 /** 00262 * Stores information for each service type in the repository. This 00263 * is a mapping from service type name to a Type_Info struct which 00264 * serves as a storage for various information for the given type. 00265 */ 00266 Service_Type_Map type_map_; 00267 00268 /// Incarnation number to be used for the next modification to the 00269 /// repository. 00270 CosTradingRepos::ServiceTypeRepository::IncarnationNumber incarnation_; 00271 }; 00272 00273 TAO_END_VERSIONED_NAMESPACE_DECL 00274 00275 #include /**/ "ace/post.h" 00276 #endif /* TAO_SERVICE_TYPE_REPOSITORY_H */