diff options
Diffstat (limited to 'TAO/tao/PortableServer/POA_Policy_Set.cpp')
-rw-r--r-- | TAO/tao/PortableServer/POA_Policy_Set.cpp | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/TAO/tao/PortableServer/POA_Policy_Set.cpp b/TAO/tao/PortableServer/POA_Policy_Set.cpp new file mode 100644 index 00000000000..af860e75a75 --- /dev/null +++ b/TAO/tao/PortableServer/POA_Policy_Set.cpp @@ -0,0 +1,98 @@ +// @(#) $Id$ + +#include "tao/PortableServer/POA_Policy_Set.h" +#include "tao/PortableServer/POA_Cached_Policies.h" +#include "tao/PortableServer/PortableServer.h" + +#include "tao/Policy_Validator.h" +#include "tao/ORB_Core.h" + +#if !defined (__ACE_INLINE__) +# include "tao/PortableServer/POA_Policy_Set.inl" +#endif /* ! __ACE_INLINE__ */ + +ACE_RCSID (PortableServer, + POA_Policy_Set, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +TAO_POA_Policy_Set::TAO_POA_Policy_Set (void) + : impl_ (TAO_POLICY_POA_SCOPE) +{ +} + +TAO_POA_Policy_Set::TAO_POA_Policy_Set (const TAO_POA_Policy_Set &rhs) + : + impl_ (rhs.impl_) +{ +} + +TAO_POA_Policy_Set::~TAO_POA_Policy_Set (void) +{ +} + +void +TAO_POA_Policy_Set::add_client_exposed_fixed_policies (CORBA::PolicyList *client_exposed_policies + ACE_ENV_ARG_DECL) +{ + CORBA::ULong cep_index = client_exposed_policies->length (); + + for (CORBA::ULong i = 0; + i < this->num_policies (); + ++i) + { + CORBA::Policy_var policy = this->get_policy_by_index (i); + + // If this policy is client exposed, add it to the list. + if (policy->_tao_scope () & TAO_POLICY_CLIENT_EXPOSED) + { + client_exposed_policies->length (cep_index + 1); + (*client_exposed_policies)[cep_index] = + policy->copy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + cep_index++; + } + } +} + +void +TAO_POA_Policy_Set::validate_policies (TAO_Policy_Validator &validator, + TAO_ORB_Core &orb_core + ACE_ENV_ARG_DECL) +{ + // Just give a last chance for all the unloaded validators in other + // libraries to be registered + orb_core.load_policy_validators (validator ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Validate that all of the specified policies make sense. + validator.validate (this->impl_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Verify that all policies are legal for the currently loaded + // POA extensions. + for (CORBA::ULong i = 0; + i < this->impl_.num_policies (); + i++) + { + CORBA::Policy_var policy = this->impl_.get_policy_by_index (i); + + CORBA::PolicyType type = policy->policy_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (validator.legal_policy (type) == 0) + { +#if ! defined (CORBA_E_MICRO) + // An invalid policy was specified. Let the user know about + // it. + ACE_THROW (PortableServer::POA::InvalidPolicy ()); +#else + ACE_ERROR ((LM_ERROR, "Invalid policy\n")); +#endif + } + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL |