00001 // Policy_Validator.cpp,v 1.13 2006/03/10 07:19:06 jtc Exp 00002 00003 #include "tao/Policy_Validator.h" 00004 #include "tao/Environment.h" 00005 #include "tao/debug.h" 00006 00007 #include "ace/Log_Msg.h" 00008 00009 ACE_RCSID (tao, 00010 Policy_Validator, 00011 "Policy_Validator.cpp,v 1.13 2006/03/10 07:19:06 jtc Exp") 00012 00013 00014 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00015 00016 TAO_Policy_Validator::TAO_Policy_Validator (TAO_ORB_Core &orb_core) 00017 : orb_core_ (orb_core), 00018 next_ (0) 00019 { 00020 } 00021 00022 TAO_Policy_Validator::~TAO_Policy_Validator (void) 00023 { 00024 delete this->next_; 00025 } 00026 00027 TAO_ORB_Core & 00028 TAO_Policy_Validator::orb_core() const 00029 { 00030 return this->orb_core_; 00031 } 00032 00033 void 00034 TAO_Policy_Validator::add_validator (TAO_Policy_Validator *validator) 00035 { 00036 // The validator we're adding can't be part of another list 00037 ACE_ASSERT (validator->next_ == 0); 00038 00039 // Why would we want to add ourself to our list 00040 if (this != validator) 00041 { 00042 // Get to the end of the list and make sure that the 00043 // new validator isn't already part of our list 00044 TAO_Policy_Validator* current = this; 00045 while (current->next_ != 0) 00046 { 00047 if (current->next_ == validator) 00048 { 00049 if (TAO_debug_level > 3) 00050 { 00051 ACE_DEBUG ((LM_DEBUG, 00052 ACE_TEXT ("(%P|%t) Skipping validator [0x%x] ") 00053 ACE_TEXT ("since it would create a circular list\n"), 00054 validator)); 00055 } 00056 00057 return; 00058 } 00059 current = current->next_; 00060 } 00061 00062 // Add the new validator to the end of the list 00063 current->next_ = validator; 00064 } 00065 } 00066 00067 00068 void 00069 TAO_Policy_Validator::validate (TAO_Policy_Set &policies 00070 ACE_ENV_ARG_DECL) 00071 { 00072 this->validate_impl (policies ACE_ENV_ARG_PARAMETER); 00073 ACE_CHECK; 00074 00075 if (this->next_ != 0) 00076 { 00077 this->next_->validate (policies ACE_ENV_ARG_PARAMETER); 00078 ACE_CHECK; 00079 } 00080 } 00081 00082 void 00083 TAO_Policy_Validator::merge_policies (TAO_Policy_Set &policies 00084 ACE_ENV_ARG_DECL) 00085 { 00086 this->merge_policies_impl (policies ACE_ENV_ARG_PARAMETER); 00087 ACE_CHECK; 00088 00089 if (this->next_) 00090 { 00091 this->next_->merge_policies (policies ACE_ENV_ARG_PARAMETER); 00092 ACE_CHECK; 00093 } 00094 } 00095 00096 CORBA::Boolean 00097 TAO_Policy_Validator::legal_policy (CORBA::PolicyType type) 00098 { 00099 return (this->legal_policy_impl (type) 00100 || ((this->next_ != 0) 00101 && this->next_->legal_policy_impl (type))); 00102 } 00103 00104 TAO_END_VERSIONED_NAMESPACE_DECL