#include <PG_Default_Property_Validator.h>
Public Member Functions | |
TAO_PG_Default_Property_Validator (void) | |
Constructor. | |
virtual | ~TAO_PG_Default_Property_Validator (void) |
Destructor. | |
virtual void | validate_property (const PortableGroup::Properties &props) |
virtual void | validate_criteria (const PortableGroup::Properties &criteria) |
Private Attributes | |
Pre-initialize property Names. | |
These properties are pre-initialized once to reduce property validation overhead. Note that the InitialNumberReplicas and MinimumNumberReplicas properties are not validated since there are no restrictions imposed by TAO's PortableGroup implementation regarding the number of such members. | |
PortableGroup::Name | membership_ |
PortableGroup::Name | factories_ |
This Property_Validator verifies that all properties defined in the PortableGroup IDL module are valid. This property validator can be subclassed to validate a different property set.
Definition at line 36 of file PG_Default_Property_Validator.h.
|
Constructor.
Definition at line 12 of file PG_Default_Property_Validator.cpp. References factories_, membership_, and CORBA::string_dup().
00013 : membership_ (1), 00014 factories_ (1) 00015 { 00016 this->membership_.length (1); 00017 this->membership_[0].id = CORBA::string_dup ("org.omg.PortableGroup.MembershipStyle"); 00018 00019 this->factories_.length (1); 00020 this->factories_[0].id = CORBA::string_dup ("org.omg.PortableGroup.Factories"); 00021 } |
|
Destructor.
Definition at line 23 of file PG_Default_Property_Validator.cpp.
00024 { 00025 } |
|
Validate the given properties/criteria. All criteria will be validated regardless of whether or not an invalid property was encountered. Definition at line 76 of file PG_Default_Property_Validator.cpp. References PortableGroup::Criteria, factories_, PortableGroup::FactoriesValue, CORBA::is_nil(), membership_, PortableGroup::MembershipStyleValue, PortableGroup::Property::nam, PortableGroup::Properties, PortableGroup::FactoryInfo::the_factory, PortableGroup::FactoryInfo::the_location, and PortableGroup::Property::val.
00078 { 00079 const CORBA::ULong len = props.length (); 00080 PortableGroup::Criteria invalid_criteria; 00081 00082 // Optimize for the worst case scenario where all properties are 00083 // invalid. 00084 invalid_criteria.length (len); 00085 00086 /// The invalid criteria index. 00087 CORBA::ULong p = 0; 00088 00089 for (CORBA::ULong i = 0; i < len; ++i) 00090 { 00091 const PortableGroup::Property & property = props[i]; 00092 00093 if (property.nam == this->membership_) 00094 { 00095 PortableGroup::MembershipStyleValue membership; 00096 if (!(property.val >>= membership) 00097 || (membership != PortableGroup::MEMB_APP_CTRL 00098 && membership != PortableGroup::MEMB_INF_CTRL)) 00099 invalid_criteria[p++] = property; 00100 } 00101 else if (property.nam == this->factories_) 00102 { 00103 PortableGroup::FactoriesValue * factories; 00104 if (!(property.val >>= factories)) 00105 invalid_criteria[p++] = property; 00106 else 00107 { 00108 const CORBA::ULong flen = factories->length (); 00109 00110 if (flen == 0) 00111 invalid_criteria[p++] = property; 00112 else 00113 { 00114 for (CORBA::ULong j = 0; j < flen; ++j) 00115 { 00116 const PortableGroup::FactoryInfo & factory_info = 00117 (*factories)[j]; 00118 00119 if (CORBA::is_nil (factory_info.the_factory.in ()) 00120 || factory_info.the_location.length () == 0) 00121 { 00122 invalid_criteria[p++] = property; 00123 break; 00124 } 00125 } 00126 } 00127 } 00128 } 00129 } 00130 00131 if (p > 0) 00132 { 00133 // Reduce the length of the invalid criteria sequence in an 00134 // effort to optimize the copying that will occur when the below 00135 // exception is thrown. Reducing the length is fast since no 00136 // deallocations should occur. 00137 invalid_criteria.length (p); 00138 00139 throw PortableGroup::InvalidCriteria (invalid_criteria); 00140 } 00141 } |
|
Validate the given properties. Throw an exception when the first invalid property is encountered. The remaining properties will not be validated. Definition at line 28 of file PG_Default_Property_Validator.cpp. References factories_, PortableGroup::FactoriesValue, CORBA::is_nil(), membership_, PortableGroup::MembershipStyleValue, PortableGroup::Property::nam, PortableGroup::Properties, PortableGroup::FactoryInfo::the_factory, PortableGroup::FactoryInfo::the_location, and PortableGroup::Property::val. Referenced by TAO_PG_PropertyManager::set_default_properties(), TAO_PG_PropertyManager::set_properties_dynamically(), and TAO_PG_PropertyManager::set_type_properties().
00030 { 00031 const CORBA::ULong len = props.length (); 00032 00033 for (CORBA::ULong i = 0; i < len; ++i) 00034 { 00035 const PortableGroup::Property & property = props[i]; 00036 00037 if (property.nam == this->membership_) 00038 { 00039 PortableGroup::MembershipStyleValue membership; 00040 if (!(property.val >>= membership) 00041 || (membership != PortableGroup::MEMB_APP_CTRL 00042 && membership != PortableGroup::MEMB_INF_CTRL)) 00043 throw PortableGroup::InvalidProperty (property.nam, property.val); 00044 } 00045 else if (property.nam == this->factories_) 00046 { 00047 const PortableGroup::FactoriesValue * factories; 00048 if (!(property.val >>= factories)) 00049 throw PortableGroup::InvalidProperty (property.nam, property.val); 00050 else 00051 { 00052 const CORBA::ULong flen = factories->length (); 00053 00054 if (flen == 0) 00055 throw PortableGroup::InvalidProperty ( 00056 property.nam, 00057 property.val); 00058 00059 for (CORBA::ULong j = 0; j < flen; ++j) 00060 { 00061 const PortableGroup::FactoryInfo & factory_info = 00062 (*factories)[j]; 00063 00064 if (CORBA::is_nil (factory_info.the_factory.in ()) 00065 || factory_info.the_location.length () == 0) 00066 throw PortableGroup::InvalidProperty ( 00067 property.nam, 00068 property.val); 00069 } 00070 } 00071 } 00072 } 00073 } |
|
Definition at line 69 of file PG_Default_Property_Validator.h. Referenced by TAO_PG_Default_Property_Validator(), validate_criteria(), and validate_property(). |
|
Definition at line 68 of file PG_Default_Property_Validator.h. Referenced by TAO_PG_Default_Property_Validator(), validate_criteria(), and validate_property(). |