summaryrefslogtreecommitdiff
path: root/TAO/tao/Policy_Validator.cpp
blob: f9e7e6ca05a6166cb899c033372899b594cb56f4 (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
#include "tao/Policy_Validator.h"
#include "tao/debug.h"
#include "ace/Log_Msg.h"

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

TAO_Policy_Validator::TAO_Policy_Validator (TAO_ORB_Core &orb_core)
  : orb_core_ (orb_core),
    next_ (nullptr)
{
}

TAO_Policy_Validator::~TAO_Policy_Validator ()
{
  delete this->next_;
}

TAO_ORB_Core &
TAO_Policy_Validator::orb_core() const
{
  return this->orb_core_;
}

void
TAO_Policy_Validator::add_validator (TAO_Policy_Validator *validator)
{
  // The validator we're adding can't be part of another list
  ACE_ASSERT (validator->next_ == nullptr);

  // Why would we want to add ourself to our list
  if (this != validator)
    {
      // Get to the end of the list and make sure that the
      // new validator isn't already part of our list
      TAO_Policy_Validator* current = this;
      while (current->next_ != nullptr)
        {
          if (current->next_ == validator)
            {
              if (TAO_debug_level > 3)
                {
                  TAOLIB_DEBUG ((LM_DEBUG,
                              ACE_TEXT ("(%P|%t) Skipping validator [%@] ")
                              ACE_TEXT ("since it would create a circular list\n"),
                              validator));
                }

              return;
            }
          current = current->next_;
        }

      // Add the new validator to the end of the list
      current->next_ = validator;
    }
}

void
TAO_Policy_Validator::validate (TAO_Policy_Set &policies)
{
  this->validate_impl (policies);

  if (this->next_ != nullptr)
    {
      this->next_->validate (policies);
    }
}

void
TAO_Policy_Validator::merge_policies (TAO_Policy_Set &policies)
{
  this->merge_policies_impl (policies);

  if (this->next_)
    {
      this->next_->merge_policies (policies);
    }
}

CORBA::Boolean
TAO_Policy_Validator::legal_policy (CORBA::PolicyType type)
{
  return (this->legal_policy_impl (type)
          || ((this->next_ != nullptr)
              && this->next_->legal_policy_impl (type)));
}

TAO_END_VERSIONED_NAMESPACE_DECL