Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tao / PortableServer / POA_Policy_Set.cpp
blob8f155ed5ebcccb9fe1c6404f1db58dbcd08ee706
1 #include "tao/PortableServer/POA_Policy_Set.h"
2 #include "tao/PortableServer/POA_Cached_Policies.h"
3 #include "tao/PortableServer/PortableServer.h"
5 #include "tao/Policy_Validator.h"
6 #include "tao/ORB_Core.h"
8 #if !defined (__ACE_INLINE__)
9 # include "tao/PortableServer/POA_Policy_Set.inl"
10 #endif /* ! __ACE_INLINE__ */
12 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
14 TAO_POA_Policy_Set::TAO_POA_Policy_Set ()
15 : impl_ (TAO_POLICY_POA_SCOPE)
19 TAO_POA_Policy_Set::TAO_POA_Policy_Set (const TAO_POA_Policy_Set &rhs)
21 impl_ (rhs.impl_)
25 TAO_POA_Policy_Set::~TAO_POA_Policy_Set ()
29 void
30 TAO_POA_Policy_Set::add_client_exposed_fixed_policies (
31 CORBA::PolicyList *client_exposed_policies)
33 CORBA::ULong cep_index = client_exposed_policies->length ();
35 for (CORBA::ULong i = 0;
36 i < this->num_policies ();
37 ++i)
39 CORBA::Policy_var policy = this->get_policy_by_index (i);
41 // If this policy is client exposed, add it to the list.
42 if (policy->_tao_scope () & TAO_POLICY_CLIENT_EXPOSED)
44 client_exposed_policies->length (cep_index + 1);
45 (*client_exposed_policies)[cep_index] = policy->copy ();
46 ++cep_index;
51 void
52 TAO_POA_Policy_Set::validate_policies (TAO_Policy_Validator &validator,
53 TAO_ORB_Core &orb_core)
55 // Just give a last chance for all the unloaded validators in other
56 // libraries to be registered
57 orb_core.load_policy_validators (validator);
59 // Validate that all of the specified policies make sense.
60 validator.validate (this->impl_ );
62 // Verify that all policies are legal for the currently loaded
63 // POA extensions.
64 for (CORBA::ULong i = 0;
65 i < this->impl_.num_policies ();
66 i++)
68 CORBA::Policy_var policy = this->impl_.get_policy_by_index (i);
70 CORBA::PolicyType type = policy->policy_type ();
72 if (!(validator.legal_policy (type)))
74 #if !defined (CORBA_E_MICRO)
75 // An invalid policy was specified. Let the user know about
76 // it.
77 throw PortableServer::POA::InvalidPolicy ();
78 #else
79 TAOLIB_ERROR ((LM_ERROR, "Invalid policy\n"));
80 #endif
85 TAO_END_VERSIONED_NAMESPACE_DECL