POA_Policy_Set.cpp

Go to the documentation of this file.
00001 // @(#) POA_Policy_Set.cpp,v 1.10 2006/06/20 06:26:43 jwillemsen Exp
00002 
00003 #include "tao/PortableServer/POA_Policy_Set.h"
00004 #include "tao/PortableServer/POA_Cached_Policies.h"
00005 #include "tao/PortableServer/PortableServer.h"
00006 
00007 #include "tao/Policy_Validator.h"
00008 #include "tao/ORB_Core.h"
00009 
00010 #if !defined (__ACE_INLINE__)
00011 # include "tao/PortableServer/POA_Policy_Set.i"
00012 #endif /* ! __ACE_INLINE__ */
00013 
00014 ACE_RCSID (PortableServer,
00015            POA_Policy_Set,
00016            "POA_Policy_Set.cpp,v 1.10 2006/06/20 06:26:43 jwillemsen Exp")
00017 
00018 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00019 
00020 TAO_POA_Policy_Set::TAO_POA_Policy_Set (void)
00021   : impl_ (TAO_POLICY_POA_SCOPE)
00022 {
00023 }
00024 
00025 TAO_POA_Policy_Set::TAO_POA_Policy_Set (const TAO_POA_Policy_Set &rhs)
00026   :
00027     impl_ (rhs.impl_)
00028 {
00029 }
00030 
00031 TAO_POA_Policy_Set::~TAO_POA_Policy_Set (void)
00032 {
00033 }
00034 
00035 void
00036 TAO_POA_Policy_Set::add_client_exposed_fixed_policies (CORBA::PolicyList *client_exposed_policies
00037                                                        ACE_ENV_ARG_DECL)
00038 {
00039   CORBA::ULong cep_index = client_exposed_policies->length ();
00040 
00041   for (CORBA::ULong i = 0;
00042        i < this->num_policies ();
00043        ++i)
00044     {
00045       CORBA::Policy_var policy = this->get_policy_by_index (i);
00046 
00047       // If this policy is client exposed, add it to the list.
00048       if (policy->_tao_scope () & TAO_POLICY_CLIENT_EXPOSED)
00049         {
00050           client_exposed_policies->length (cep_index + 1);
00051           (*client_exposed_policies)[cep_index] =
00052                                   policy->copy (ACE_ENV_SINGLE_ARG_PARAMETER);
00053           ACE_CHECK;
00054 
00055           cep_index++;
00056         }
00057     }
00058 }
00059 
00060 void
00061 TAO_POA_Policy_Set::validate_policies (TAO_Policy_Validator &validator,
00062                                        TAO_ORB_Core &orb_core
00063                                        ACE_ENV_ARG_DECL)
00064 {
00065   // Just give a last chance for all the unloaded validators in other
00066   // libraries to be registered
00067   orb_core.load_policy_validators (validator ACE_ENV_ARG_PARAMETER);
00068   ACE_CHECK;
00069 
00070   // Validate that all of the specified policies make sense.
00071   validator.validate (this->impl_  ACE_ENV_ARG_PARAMETER);
00072   ACE_CHECK;
00073 
00074   // Verify that all policies are legal for the currently loaded
00075   // POA extensions.
00076   for (CORBA::ULong i = 0;
00077        i < this->impl_.num_policies ();
00078        i++)
00079     {
00080       CORBA::Policy_var policy = this->impl_.get_policy_by_index (i);
00081 
00082       CORBA::PolicyType type = policy->policy_type (ACE_ENV_SINGLE_ARG_PARAMETER);
00083       ACE_CHECK;
00084 
00085       if (validator.legal_policy (type) == 0)
00086         {
00087 #if ! defined (CORBA_E_MICRO)
00088           // An invalid policy was specified.  Let the user know about
00089           // it.
00090           ACE_THROW (PortableServer::POA::InvalidPolicy ());
00091 #else
00092           ACE_ERROR ((LM_ERROR, "Invalid policy\n"));
00093 #endif
00094         }
00095     }
00096 }
00097 
00098 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 12:40:40 2006 for TAO_PortableServer by doxygen 1.3.6