summaryrefslogtreecommitdiff
path: root/ACE/ace/Monitor_Control/Constraint_Interpreter.cpp
blob: 297088b493e1618fc990a71a60c8d7782a0cc5a2 (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
// $Id$

#include "ace/Monitor_Control/Constraint_Interpreter.h"

#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)

#include "ace/Log_Msg.h"

#include "ace/ETCL/ETCL_Constraint.h"

#include "ace/Monitor_Control/Constraint_Visitor.h"

ACE_BEGIN_VERSIONED_NAMESPACE_DECL

namespace ACE
{
  namespace Monitor_Control
  {
    Constraint_Interpreter::Constraint_Interpreter (void)
    {
    }

    Constraint_Interpreter::~Constraint_Interpreter (void)
    {
    }

    int
    Constraint_Interpreter::build_tree (const char *constraints)
    {
      if (ETCL_Interpreter::is_empty_string (constraints))
        {
          /// Root is deleted in the interpreter's destructor.
          ACE_NEW_RETURN (this->root_,
                          ETCL_Literal_Constraint (true),
                          -1);
        }
      else
        {
          /// root_ is set in this base class call.
          if (ETCL_Interpreter::build_tree (constraints) != 0)
            {
              ACE_ERROR_RETURN ((LM_ERROR,
                                 "Constraint_Interpreter::build_tree() - "
                                 "ETCL_Interpreter::build_tree() failed\n"),
                                -1);
            }
        }

      return 0;
    }

    ACE_CDR::Boolean
    Constraint_Interpreter::evaluate (Constraint_Visitor &evaluator)
    {
      return evaluator.evaluate_constraint (this->root_);
    }
  }
}

ACE_END_VERSIONED_NAMESPACE_DECL

#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */