summaryrefslogtreecommitdiff
path: root/TAO/tao/PortableServer/POA_Policy_Set.cpp
blob: e0ee81f34e247e59e502d00a6c4804f65535fdeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// @(#) $Id$

#include "POA_Policy_Set.h"
#include "POA_Cached_Policies.h"
#include "PortableServer.h"

#include "tao/Policy_Validator.h"
#include "tao/ORB_Core.h"

#if !defined (__ACE_INLINE__)
# include "POA_Policy_Set.i"
#endif /* ! __ACE_INLINE__ */

ACE_RCSID (PortableServer,
           POA_Policy_Set,
           "$Id$")

TAO_POA_Policy_Set::TAO_POA_Policy_Set ()
  :
    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)
        {
          // An invalid policy was specified.  Let the user know about
          // it.
          ACE_THROW (PortableServer::POA::InvalidPolicy ());
        }
    }
}