From feeb55065482588f1023deee8bb5b3421a96c38e Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 16 Oct 2014 17:44:06 +0200 Subject: [PATCH] Rename AExpression to Expression --- lib/config/CMakeLists.txt | 4 +- lib/config/applyrule.cpp | 10 +- lib/config/applyrule.hpp | 18 +- lib/config/config_lexer.ll | 48 +++--- lib/config/config_parser.yy | 143 ++++++++-------- lib/config/configitem.cpp | 4 +- lib/config/configitem.hpp | 8 +- lib/config/configitembuilder.cpp | 12 +- lib/config/configitembuilder.hpp | 4 +- .../{aexpression.cpp => expression.cpp} | 156 +++++++++--------- .../{aexpression.hpp => expression.hpp} | 90 +++++----- lib/config/objectrule.cpp | 10 +- lib/config/objectrule.hpp | 18 +- lib/icinga/dependency-apply.cpp | 24 +-- lib/icinga/notification-apply.cpp | 18 +- lib/icinga/scheduleddowntime-apply.cpp | 18 +- lib/icinga/service-apply.cpp | 18 +- 17 files changed, 301 insertions(+), 302 deletions(-) rename lib/config/{aexpression.cpp => expression.cpp} (73%) rename lib/config/{aexpression.hpp => expression.hpp} (51%) diff --git a/lib/config/CMakeLists.txt b/lib/config/CMakeLists.txt index 300df7527..596c70ccc 100644 --- a/lib/config/CMakeLists.txt +++ b/lib/config/CMakeLists.txt @@ -31,10 +31,10 @@ mkembedconfig_target(base-type.conf base-type.cpp) include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) set(config_SOURCES - aexpression.cpp applyrule.cpp base-type.conf base-type.cpp + applyrule.cpp base-type.conf base-type.cpp configcompilercontext.cpp configcompiler.cpp configitembuilder.cpp configitem.cpp ${FLEX_config_lexer_OUTPUTS} ${BISON_config_parser_OUTPUTS} - configtype.cpp objectrule.cpp typerule.cpp typerulelist.cpp + configtype.cpp expression.cpp objectrule.cpp typerule.cpp typerulelist.cpp ) if(ICINGA2_UNITY_BUILD) diff --git a/lib/config/applyrule.cpp b/lib/config/applyrule.cpp index aa58963b8..b21995af8 100644 --- a/lib/config/applyrule.cpp +++ b/lib/config/applyrule.cpp @@ -27,8 +27,8 @@ using namespace icinga; ApplyRule::RuleMap ApplyRule::m_Rules; ApplyRule::CallbackMap ApplyRule::m_Callbacks; -ApplyRule::ApplyRule(const String& targetType, const String& name, const AExpression::Ptr& expression, - const AExpression::Ptr& filter, const DebugInfo& di, const Dictionary::Ptr& scope) +ApplyRule::ApplyRule(const String& targetType, const String& name, const Expression::Ptr& expression, + const Expression::Ptr& filter, const DebugInfo& di, const Dictionary::Ptr& scope) : m_TargetType(targetType), m_Name(name), m_Expression(expression), m_Filter(filter), m_DebugInfo(di), m_Scope(scope) { } @@ -42,12 +42,12 @@ String ApplyRule::GetName(void) const return m_Name; } -AExpression::Ptr ApplyRule::GetExpression(void) const +Expression::Ptr ApplyRule::GetExpression(void) const { return m_Expression; } -AExpression::Ptr ApplyRule::GetFilter(void) const +Expression::Ptr ApplyRule::GetFilter(void) const { return m_Filter; } @@ -63,7 +63,7 @@ Dictionary::Ptr ApplyRule::GetScope(void) const } void ApplyRule::AddRule(const String& sourceType, const String& targetType, const String& name, - const AExpression::Ptr& expression, const AExpression::Ptr& filter, + const Expression::Ptr& expression, const Expression::Ptr& filter, const DebugInfo& di, const Dictionary::Ptr& scope) { m_Rules[sourceType].push_back(ApplyRule(targetType, name, expression, filter, di, scope)); diff --git a/lib/config/applyrule.hpp b/lib/config/applyrule.hpp index 147298c9f..b7590f180 100644 --- a/lib/config/applyrule.hpp +++ b/lib/config/applyrule.hpp @@ -21,7 +21,7 @@ #define APPLYRULE_H #include "config/i2-config.hpp" -#include "config/aexpression.hpp" +#include "config/expression.hpp" #include "base/debuginfo.hpp" #include @@ -40,15 +40,15 @@ public: String GetTargetType(void) const; String GetName(void) const; - AExpression::Ptr GetExpression(void) const; - AExpression::Ptr GetFilter(void) const; + Expression::Ptr GetExpression(void) const; + Expression::Ptr GetFilter(void) const; DebugInfo GetDebugInfo(void) const; Dictionary::Ptr GetScope(void) const; bool EvaluateFilter(const Dictionary::Ptr& scope) const; - static void AddRule(const String& sourceType, const String& targetType, const String& name, const AExpression::Ptr& expression, - const AExpression::Ptr& filter, const DebugInfo& di, const Dictionary::Ptr& scope); + static void AddRule(const String& sourceType, const String& targetType, const String& name, const Expression::Ptr& expression, + const Expression::Ptr& filter, const DebugInfo& di, const Dictionary::Ptr& scope); static void EvaluateRules(bool clear); static void RegisterType(const String& sourceType, const std::vector& targetTypes, const ApplyRule::Callback& callback); @@ -59,16 +59,16 @@ public: private: String m_TargetType; String m_Name; - AExpression::Ptr m_Expression; - AExpression::Ptr m_Filter; + Expression::Ptr m_Expression; + Expression::Ptr m_Filter; DebugInfo m_DebugInfo; Dictionary::Ptr m_Scope; static CallbackMap m_Callbacks; static RuleMap m_Rules; - ApplyRule(const String& targetType, const String& name, const AExpression::Ptr& expression, - const AExpression::Ptr& filter, const DebugInfo& di, const Dictionary::Ptr& scope); + ApplyRule(const String& targetType, const String& name, const Expression::Ptr& expression, + const Expression::Ptr& filter, const DebugInfo& di, const Dictionary::Ptr& scope); }; } diff --git a/lib/config/config_lexer.ll b/lib/config/config_lexer.ll index cebb7a89a..133eab028 100644 --- a/lib/config/config_lexer.ll +++ b/lib/config/config_lexer.ll @@ -21,7 +21,7 @@ #include "config/configcompiler.hpp" #include "config/typerule.hpp" #include "config/configcompilercontext.hpp" -#include "config/aexpression.hpp" +#include "config/expression.hpp" using namespace icinga; @@ -233,16 +233,16 @@ __function return T_FUNCTION; __return return T_RETURN; zone return T_ZONE; __for return T_FOR; -\<\< { yylval->op = &AExpression::OpShiftLeft; return T_SHIFT_LEFT; } -\>\> { yylval->op = &AExpression::OpShiftRight; return T_SHIFT_RIGHT; } -\<= { yylval->op = &AExpression::OpLessThanOrEqual; return T_LESS_THAN_OR_EQUAL; } -\>= { yylval->op = &AExpression::OpGreaterThanOrEqual; return T_GREATER_THAN_OR_EQUAL; } -== { yylval->op = &AExpression::OpEqual; return T_EQUAL; } -!= { yylval->op = &AExpression::OpNotEqual; return T_NOT_EQUAL; } -!in { yylval->op = &AExpression::OpNotIn; return T_NOT_IN; } -in { yylval->op = &AExpression::OpIn; return T_IN; } -&& { yylval->op = &AExpression::OpLogicalAnd; return T_LOGICAL_AND; } -\|\| { yylval->op = &AExpression::OpLogicalOr; return T_LOGICAL_OR; } +\<\< { yylval->op = &Expression::OpShiftLeft; return T_SHIFT_LEFT; } +\>\> { yylval->op = &Expression::OpShiftRight; return T_SHIFT_RIGHT; } +\<= { yylval->op = &Expression::OpLessThanOrEqual; return T_LESS_THAN_OR_EQUAL; } +\>= { yylval->op = &Expression::OpGreaterThanOrEqual; return T_GREATER_THAN_OR_EQUAL; } +== { yylval->op = &Expression::OpEqual; return T_EQUAL; } +!= { yylval->op = &Expression::OpNotEqual; return T_NOT_EQUAL; } +!in { yylval->op = &Expression::OpNotIn; return T_NOT_IN; } +in { yylval->op = &Expression::OpIn; return T_IN; } +&& { yylval->op = &Expression::OpLogicalAnd; return T_LOGICAL_AND; } +\|\| { yylval->op = &Expression::OpLogicalOr; return T_LOGICAL_OR; } [a-zA-Z_][a-zA-Z0-9\-_]* { yylval->text = strdup(yytext); return T_IDENTIFIER; } @[a-zA-Z_][a-zA-Z0-9\-_]* { yylval->text = strdup(yytext + 1); return T_IDENTIFIER; } \<[^\>]*\> { yytext[yyleng-1] = '\0'; yylval->text = strdup(yytext + 1); return T_STRING_ANGLE; } @@ -252,19 +252,19 @@ in { yylval->op = &AExpression::OpIn; return T_IN; } -?[0-9]+(\.[0-9]+)?m { yylval->num = strtod(yytext, NULL) * 60; return T_NUMBER; } -?[0-9]+(\.[0-9]+)?s { yylval->num = strtod(yytext, NULL); return T_NUMBER; } -?[0-9]+(\.[0-9]+)? { yylval->num = strtod(yytext, NULL); return T_NUMBER; } -= { yylval->op = &AExpression::OpSet; return T_SET; } -\+= { yylval->op = &AExpression::OpSetPlus; return T_SET_PLUS; } --= { yylval->op = &AExpression::OpSetMinus; return T_SET_MINUS; } -\*= { yylval->op = &AExpression::OpSetMultiply; return T_SET_MULTIPLY; } -\/= { yylval->op = &AExpression::OpSetDivide; return T_SET_DIVIDE; } -\+ { yylval->op = &AExpression::OpAdd; return T_PLUS; } -\- { yylval->op = &AExpression::OpSubtract; return T_MINUS; } -\* { yylval->op = &AExpression::OpMultiply; return T_MULTIPLY; } -\/ { yylval->op = &AExpression::OpMultiply; return T_DIVIDE_OP; } -\& { yylval->op = &AExpression::OpBinaryAnd; return T_BINARY_AND; } -\| { yylval->op = &AExpression::OpBinaryOr; return T_BINARY_OR; } -\< { yylval->op = &AExpression::OpLessThan; return T_LESS_THAN; } -\> { yylval->op = &AExpression::OpLessThan; return T_GREATER_THAN; } += { yylval->op = &Expression::OpSet; return T_SET; } +\+= { yylval->op = &Expression::OpSetPlus; return T_SET_PLUS; } +-= { yylval->op = &Expression::OpSetMinus; return T_SET_MINUS; } +\*= { yylval->op = &Expression::OpSetMultiply; return T_SET_MULTIPLY; } +\/= { yylval->op = &Expression::OpSetDivide; return T_SET_DIVIDE; } +\+ { yylval->op = &Expression::OpAdd; return T_PLUS; } +\- { yylval->op = &Expression::OpSubtract; return T_MINUS; } +\* { yylval->op = &Expression::OpMultiply; return T_MULTIPLY; } +\/ { yylval->op = &Expression::OpMultiply; return T_DIVIDE_OP; } +\& { yylval->op = &Expression::OpBinaryAnd; return T_BINARY_AND; } +\| { yylval->op = &Expression::OpBinaryOr; return T_BINARY_OR; } +\< { yylval->op = &Expression::OpLessThan; return T_LESS_THAN; } +\> { yylval->op = &Expression::OpLessThan; return T_GREATER_THAN; } } [\r\n]+ { yycolumn -= strlen(yytext) - 1; if (!ignore_newlines) return T_NEWLINE; } diff --git a/lib/config/config_parser.yy b/lib/config/config_parser.yy index f62f915f9..b8d2fa549 100644 --- a/lib/config/config_parser.yy +++ b/lib/config/config_parser.yy @@ -27,10 +27,9 @@ #include "config/configcompilercontext.hpp" #include "config/typerule.hpp" #include "config/typerulelist.hpp" -#include "config/aexpression.hpp" +#include "config/expression.hpp" #include "config/applyrule.hpp" #include "config/objectrule.hpp" -#include "config/aexpression.hpp" #include "base/value.hpp" #include "base/utility.hpp" #include "base/array.hpp" @@ -74,9 +73,9 @@ using namespace icinga; int ignore_newlines = 0; -static void MakeRBinaryOp(Value** result, AExpression::OpCallback& op, Value *left, Value *right, DebugInfo& diLeft, DebugInfo& diRight) +static void MakeRBinaryOp(Value** result, Expression::OpCallback& op, Value *left, Value *right, DebugInfo& diLeft, DebugInfo& diRight) { - *result = new Value(make_shared(op, *left, *right, DebugInfoRange(diLeft, diRight))); + *result = new Value(make_shared(op, *left, *right, DebugInfoRange(diLeft, diRight))); delete left; delete right; } @@ -96,7 +95,7 @@ static void MakeRBinaryOp(Value** result, AExpression::OpCallback& op, Value *le char *text; double num; icinga::Value *variant; - icinga::AExpression::OpCallback op; + icinga::Expression::OpCallback op; icinga::TypeSpecifier type; std::vector *slist; Array *array; @@ -221,8 +220,8 @@ static int m_StatementNum; static bool m_Apply; static bool m_ObjectAssign; static bool m_SeenAssign; -static AExpression::Ptr m_Assign; -static AExpression::Ptr m_Ignore; +static Expression::Ptr m_Assign; +static Expression::Ptr m_Ignore; void ConfigCompiler::Compile(void) { @@ -260,7 +259,7 @@ statement: type | zone | include | include_recursive | library | constant { } | lterm { - AExpression::Ptr aexpr = *$1; + Expression::Ptr aexpr = *$1; aexpr->Evaluate(m_ModuleScope); delete $1; @@ -270,7 +269,7 @@ statement: type | zone | include | include_recursive | library | constant zone: T_ZONE rterm sep { - AExpression::Ptr aexpr = *$2; + Expression::Ptr aexpr = *$2; delete $2; if (!context->GetZone().IsEmpty()) @@ -283,7 +282,7 @@ zone: T_ZONE rterm sep } | T_ZONE rterm { - AExpression::Ptr aexpr = *$2; + Expression::Ptr aexpr = *$2; delete $2; if (!context->GetZone().IsEmpty()) @@ -293,7 +292,7 @@ zone: T_ZONE rterm sep } rterm_scope sep { - AExpression::Ptr ascope = *$4; + Expression::Ptr ascope = *$4; delete $4; try { @@ -307,7 +306,7 @@ zone: T_ZONE rterm sep include: T_INCLUDE rterm sep { - AExpression::Ptr aexpr = *$2; + Expression::Ptr aexpr = *$2; delete $2; context->HandleInclude(aexpr->Evaluate(m_ModuleScope), false, DebugInfoRange(@1, @2)); @@ -321,17 +320,17 @@ include: T_INCLUDE rterm sep include_recursive: T_INCLUDE_RECURSIVE rterm { - AExpression::Ptr aexpr = *$2; + Expression::Ptr aexpr = *$2; delete $2; context->HandleIncludeRecursive(aexpr->Evaluate(m_ModuleScope), "*.conf", DebugInfoRange(@1, @2)); } | T_INCLUDE_RECURSIVE rterm ',' rterm { - AExpression::Ptr aexpr1 = *$2; + Expression::Ptr aexpr1 = *$2; delete $2; - AExpression::Ptr aexpr2 = *$4; + Expression::Ptr aexpr2 = *$4; delete $4; context->HandleIncludeRecursive(aexpr1->Evaluate(m_ModuleScope), aexpr2->Evaluate(m_ModuleScope), DebugInfoRange(@1, @4)); @@ -347,7 +346,7 @@ library: T_LIBRARY T_STRING sep constant: T_CONST identifier T_SET rterm sep { - AExpression::Ptr aexpr = *$4; + Expression::Ptr aexpr = *$4; delete $4; ScriptVariable::Ptr sv = ScriptVariable::Set($2, aexpr->Evaluate(m_ModuleScope)); @@ -482,8 +481,8 @@ object: m_Abstract = false; m_ObjectAssign = true; m_SeenAssign = false; - m_Assign = make_shared(&AExpression::OpLiteral, false, DebugInfo()); - m_Ignore = make_shared(&AExpression::OpLiteral, false, DebugInfo()); + m_Assign = make_shared(&Expression::OpLiteral, false, DebugInfo()); + m_Ignore = make_shared(&Expression::OpLiteral, false, DebugInfo()); } object_declaration identifier rterm rterm_scope { @@ -500,21 +499,21 @@ object: args->Add(*$4); delete $4; - AExpression::Ptr exprl = *$5; + Expression::Ptr exprl = *$5; delete $5; exprl->MakeInline(); if (m_SeenAssign && !ObjectRule::IsValidSourceType(type)) BOOST_THROW_EXCEPTION(ConfigError("object rule 'assign' cannot be used for type '" + type + "'") << errinfo_debuginfo(DebugInfoRange(@2, @3))); - AExpression::Ptr rex = make_shared(&AExpression::OpLogicalNegate, m_Ignore, DebugInfoRange(@2, @5)); - AExpression::Ptr filter = make_shared(&AExpression::OpLogicalAnd, m_Assign, rex, DebugInfoRange(@2, @5)); + Expression::Ptr rex = make_shared(&Expression::OpLogicalNegate, m_Ignore, DebugInfoRange(@2, @5)); + Expression::Ptr filter = make_shared(&Expression::OpLogicalAnd, m_Assign, rex, DebugInfoRange(@2, @5)); args->Add(filter); args->Add(context->GetZone()); - $$ = new Value(make_shared(&AExpression::OpObject, args, exprl, DebugInfoRange(@2, @5))); + $$ = new Value(make_shared(&Expression::OpObject, args, exprl, DebugInfoRange(@2, @5))); m_Assign.reset(); m_Ignore.reset(); @@ -602,47 +601,47 @@ lterm_items_inner: lterm lterm: identifier lbinary_op rterm { - AExpression::Ptr aindex = make_shared(&AExpression::OpLiteral, $1, @1); + Expression::Ptr aindex = make_shared(&Expression::OpLiteral, $1, @1); free($1); - $$ = new Value(make_shared($2, aindex, *$3, DebugInfoRange(@1, @3))); + $$ = new Value(make_shared($2, aindex, *$3, DebugInfoRange(@1, @3))); delete $3; } | identifier '[' rterm ']' lbinary_op rterm { - AExpression::Ptr subexpr = make_shared($5, *$3, *$6, DebugInfoRange(@1, @6)); + Expression::Ptr subexpr = make_shared($5, *$3, *$6, DebugInfoRange(@1, @6)); delete $3; delete $6; Array::Ptr subexprl = make_shared(); subexprl->Add(subexpr); - AExpression::Ptr aindex = make_shared(&AExpression::OpLiteral, $1, @1); + Expression::Ptr aindex = make_shared(&Expression::OpLiteral, $1, @1); free($1); - AExpression::Ptr expr = make_shared(&AExpression::OpDict, subexprl, DebugInfoRange(@1, @6)); - $$ = new Value(make_shared(&AExpression::OpSetPlus, aindex, expr, DebugInfoRange(@1, @6))); + Expression::Ptr expr = make_shared(&Expression::OpDict, subexprl, DebugInfoRange(@1, @6)); + $$ = new Value(make_shared(&Expression::OpSetPlus, aindex, expr, DebugInfoRange(@1, @6))); } | identifier '.' T_IDENTIFIER lbinary_op rterm { - AExpression::Ptr aindex = make_shared(&AExpression::OpLiteral, $3, @3); - AExpression::Ptr subexpr = make_shared($4, aindex, *$5, DebugInfoRange(@1, @5)); + Expression::Ptr aindex = make_shared(&Expression::OpLiteral, $3, @3); + Expression::Ptr subexpr = make_shared($4, aindex, *$5, DebugInfoRange(@1, @5)); free($3); delete $5; Array::Ptr subexprl = make_shared(); subexprl->Add(subexpr); - AExpression::Ptr aindexl = make_shared(&AExpression::OpLiteral, $1, @1); + Expression::Ptr aindexl = make_shared(&Expression::OpLiteral, $1, @1); free($1); - AExpression::Ptr expr = make_shared(&AExpression::OpDict, subexprl, DebugInfoRange(@1, @5)); - $$ = new Value(make_shared(&AExpression::OpSetPlus, aindexl, expr, DebugInfoRange(@1, @5))); + Expression::Ptr expr = make_shared(&Expression::OpDict, subexprl, DebugInfoRange(@1, @5)); + $$ = new Value(make_shared(&Expression::OpSetPlus, aindexl, expr, DebugInfoRange(@1, @5))); } | T_IMPORT rterm { - AExpression::Ptr avar = make_shared(&AExpression::OpVariable, "type", DebugInfoRange(@1, @2)); - $$ = new Value(make_shared(&AExpression::OpImport, avar, *$2, DebugInfoRange(@1, @2))); + Expression::Ptr avar = make_shared(&Expression::OpVariable, "type", DebugInfoRange(@1, @2)); + $$ = new Value(make_shared(&Expression::OpImport, avar, *$2, DebugInfoRange(@1, @2))); delete $2; } | T_ASSIGN T_WHERE rterm @@ -652,26 +651,26 @@ lterm: identifier lbinary_op rterm m_SeenAssign = true; - m_Assign = make_shared(&AExpression::OpLogicalOr, m_Assign, *$3, DebugInfoRange(@1, @3)); + m_Assign = make_shared(&Expression::OpLogicalOr, m_Assign, *$3, DebugInfoRange(@1, @3)); delete $3; - $$ = new Value(make_shared(&AExpression::OpLiteral, Empty, DebugInfoRange(@1, @3))); + $$ = new Value(make_shared(&Expression::OpLiteral, Empty, DebugInfoRange(@1, @3))); } | T_IGNORE T_WHERE rterm { if (!(m_Apply || m_ObjectAssign)) BOOST_THROW_EXCEPTION(ConfigError("'ignore' keyword not valid in this context.")); - m_Ignore = make_shared(&AExpression::OpLogicalOr, m_Ignore, *$3, DebugInfoRange(@1, @3)); + m_Ignore = make_shared(&Expression::OpLogicalOr, m_Ignore, *$3, DebugInfoRange(@1, @3)); delete $3; - $$ = new Value(make_shared(&AExpression::OpLiteral, Empty, DebugInfoRange(@1, @3))); + $$ = new Value(make_shared(&Expression::OpLiteral, Empty, DebugInfoRange(@1, @3))); } | T_RETURN rterm { - AExpression::Ptr aname = make_shared(&AExpression::OpLiteral, "__result", @1); - $$ = new Value(make_shared(&AExpression::OpSet, aname, *$2, DebugInfoRange(@1, @2))); + Expression::Ptr aname = make_shared(&Expression::OpLiteral, "__result", @1); + $$ = new Value(make_shared(&Expression::OpSet, aname, *$2, DebugInfoRange(@1, @2))); delete $2; } @@ -719,83 +718,83 @@ rterm_items_inner: rterm rterm_array: '[' newlines rterm_items newlines ']' { - $$ = new Value(make_shared(&AExpression::OpArray, Array::Ptr($3), DebugInfoRange(@1, @5))); + $$ = new Value(make_shared(&Expression::OpArray, Array::Ptr($3), DebugInfoRange(@1, @5))); } | '[' newlines rterm_items ']' { - $$ = new Value(make_shared(&AExpression::OpArray, Array::Ptr($3), DebugInfoRange(@1, @4))); + $$ = new Value(make_shared(&Expression::OpArray, Array::Ptr($3), DebugInfoRange(@1, @4))); } | '[' rterm_items newlines ']' { - $$ = new Value(make_shared(&AExpression::OpArray, Array::Ptr($2), DebugInfoRange(@1, @4))); + $$ = new Value(make_shared(&Expression::OpArray, Array::Ptr($2), DebugInfoRange(@1, @4))); } | '[' rterm_items ']' { - $$ = new Value(make_shared(&AExpression::OpArray, Array::Ptr($2), DebugInfoRange(@1, @3))); + $$ = new Value(make_shared(&Expression::OpArray, Array::Ptr($2), DebugInfoRange(@1, @3))); } ; rterm_scope: '{' newlines lterm_items newlines '}' { - $$ = new Value(make_shared(&AExpression::OpDict, Array::Ptr($3), DebugInfoRange(@1, @5))); + $$ = new Value(make_shared(&Expression::OpDict, Array::Ptr($3), DebugInfoRange(@1, @5))); } | '{' newlines lterm_items '}' { - $$ = new Value(make_shared(&AExpression::OpDict, Array::Ptr($3), DebugInfoRange(@1, @4))); + $$ = new Value(make_shared(&Expression::OpDict, Array::Ptr($3), DebugInfoRange(@1, @4))); } | '{' lterm_items newlines '}' { - $$ = new Value(make_shared(&AExpression::OpDict, Array::Ptr($2), DebugInfoRange(@1, @4))); + $$ = new Value(make_shared(&Expression::OpDict, Array::Ptr($2), DebugInfoRange(@1, @4))); } | '{' lterm_items '}' { - $$ = new Value(make_shared(&AExpression::OpDict, Array::Ptr($2), DebugInfoRange(@1, @3))); + $$ = new Value(make_shared(&Expression::OpDict, Array::Ptr($2), DebugInfoRange(@1, @3))); } ; rterm: T_STRING { - $$ = new Value(make_shared(&AExpression::OpLiteral, $1, @1)); + $$ = new Value(make_shared(&Expression::OpLiteral, $1, @1)); free($1); } | T_NUMBER { - $$ = new Value(make_shared(&AExpression::OpLiteral, $1, @1)); + $$ = new Value(make_shared(&Expression::OpLiteral, $1, @1)); } | T_NULL { - $$ = new Value(make_shared(&AExpression::OpLiteral, Empty, @1)); + $$ = new Value(make_shared(&Expression::OpLiteral, Empty, @1)); } | rterm '.' T_IDENTIFIER { - $$ = new Value(make_shared(&AExpression::OpIndexer, *$1, make_shared(&AExpression::OpLiteral, $3, @3), DebugInfoRange(@1, @3))); + $$ = new Value(make_shared(&Expression::OpIndexer, *$1, make_shared(&Expression::OpLiteral, $3, @3), DebugInfoRange(@1, @3))); delete $1; free($3); } | rterm '(' rterm_items ')' { Array::Ptr arguments = Array::Ptr($3); - $$ = new Value(make_shared(&AExpression::OpFunctionCall, *$1, make_shared(&AExpression::OpLiteral, arguments, @3), DebugInfoRange(@1, @4))); + $$ = new Value(make_shared(&Expression::OpFunctionCall, *$1, make_shared(&Expression::OpLiteral, arguments, @3), DebugInfoRange(@1, @4))); delete $1; } | T_IDENTIFIER { - $$ = new Value(make_shared(&AExpression::OpVariable, $1, @1)); + $$ = new Value(make_shared(&Expression::OpVariable, $1, @1)); free($1); } | '!' rterm { - $$ = new Value(make_shared(&AExpression::OpLogicalNegate, *$2, DebugInfoRange(@1, @2))); + $$ = new Value(make_shared(&Expression::OpLogicalNegate, *$2, DebugInfoRange(@1, @2))); delete $2; } | '~' rterm { - $$ = new Value(make_shared(&AExpression::OpNegate, *$2, DebugInfoRange(@1, @2))); + $$ = new Value(make_shared(&Expression::OpNegate, *$2, DebugInfoRange(@1, @2))); delete $2; } | rterm '[' rterm ']' { - $$ = new Value(make_shared(&AExpression::OpIndexer, *$1, *$3, DebugInfoRange(@1, @4))); + $$ = new Value(make_shared(&Expression::OpIndexer, *$1, *$3, DebugInfoRange(@1, @4))); delete $1; delete $3; } @@ -841,12 +840,12 @@ rterm: T_STRING arr->Add($2); free($2); - AExpression::Ptr aexpr = *$6; + Expression::Ptr aexpr = *$6; delete $6; aexpr->MakeInline(); arr->Add(aexpr); - $$ = new Value(make_shared(&AExpression::OpFunction, arr, Array::Ptr($4), DebugInfoRange(@1, @6))); + $$ = new Value(make_shared(&Expression::OpFunction, arr, Array::Ptr($4), DebugInfoRange(@1, @6))); } | T_FUNCTION '(' identifier_items ')' rterm_scope { @@ -854,12 +853,12 @@ rterm: T_STRING arr->Add(Empty); - AExpression::Ptr aexpr = *$5; + Expression::Ptr aexpr = *$5; delete $5; aexpr->MakeInline(); arr->Add(aexpr); - $$ = new Value(make_shared(&AExpression::OpFunction, arr, Array::Ptr($3), DebugInfoRange(@1, @5))); + $$ = new Value(make_shared(&Expression::OpFunction, arr, Array::Ptr($3), DebugInfoRange(@1, @5))); } | T_FOR '(' identifier T_IN rterm ')' rterm_scope { @@ -868,14 +867,14 @@ rterm: T_STRING arr->Add($3); free($3); - AExpression::Ptr aexpr = *$5; + Expression::Ptr aexpr = *$5; delete $5; arr->Add(aexpr); - AExpression::Ptr ascope = *$7; + Expression::Ptr ascope = *$7; delete $7; - $$ = new Value(make_shared(&AExpression::OpFor, arr, ascope, DebugInfoRange(@1, @7))); + $$ = new Value(make_shared(&Expression::OpFor, arr, ascope, DebugInfoRange(@1, @7))); } ; @@ -893,8 +892,8 @@ apply: { m_Apply = true; m_SeenAssign = false; - m_Assign = make_shared(&AExpression::OpLiteral, false, DebugInfo()); - m_Ignore = make_shared(&AExpression::OpLiteral, false, DebugInfo()); + m_Assign = make_shared(&Expression::OpLiteral, false, DebugInfo()); + m_Ignore = make_shared(&Expression::OpLiteral, false, DebugInfo()); } T_APPLY identifier rterm target_type_specifier rterm { @@ -902,7 +901,7 @@ apply: String type = $3; free($3); - AExpression::Ptr aname = *$4; + Expression::Ptr aname = *$4; delete $4; String target = $5; free($5); @@ -931,7 +930,7 @@ apply: BOOST_THROW_EXCEPTION(ConfigError("'apply' target type '" + target + "' is invalid") << errinfo_debuginfo(DebugInfoRange(@2, @5))); } - AExpression::Ptr exprl = *$6; + Expression::Ptr exprl = *$6; delete $6; exprl->MakeInline(); @@ -940,8 +939,8 @@ apply: if (!m_SeenAssign) BOOST_THROW_EXCEPTION(ConfigError("'apply' is missing 'assign'") << errinfo_debuginfo(DebugInfoRange(@2, @3))); - AExpression::Ptr rex = make_shared(&AExpression::OpLogicalNegate, m_Ignore, DebugInfoRange(@2, @5)); - AExpression::Ptr filter = make_shared(&AExpression::OpLogicalAnd, m_Assign, rex, DebugInfoRange(@2, @5)); + Expression::Ptr rex = make_shared(&Expression::OpLogicalNegate, m_Ignore, DebugInfoRange(@2, @5)); + Expression::Ptr filter = make_shared(&Expression::OpLogicalAnd, m_Assign, rex, DebugInfoRange(@2, @5)); Array::Ptr args = make_shared(); args->Add(type); @@ -949,7 +948,7 @@ apply: args->Add(aname); args->Add(filter); - $$ = new Value(make_shared(&AExpression::OpApply, args, exprl, DebugInfoRange(@2, @5))); + $$ = new Value(make_shared(&Expression::OpApply, args, exprl, DebugInfoRange(@2, @5))); m_Assign.reset(); m_Ignore.reset(); diff --git a/lib/config/configitem.cpp b/lib/config/configitem.cpp index c786c9d82..7122452fa 100644 --- a/lib/config/configitem.cpp +++ b/lib/config/configitem.cpp @@ -53,7 +53,7 @@ ConfigItem::ItemMap ConfigItem::m_Items; * @param debuginfo Debug information. */ ConfigItem::ConfigItem(const String& type, const String& name, - bool abstract, const AExpression::Ptr& exprl, + bool abstract, const Expression::Ptr& exprl, const DebugInfo& debuginfo, const Dictionary::Ptr& scope, const String& zone) : m_Type(type), m_Name(name), m_Abstract(abstract), m_Validated(false), @@ -112,7 +112,7 @@ Dictionary::Ptr ConfigItem::GetScope(void) const * * @returns The expression list. */ -AExpression::Ptr ConfigItem::GetExpressionList(void) const +Expression::Ptr ConfigItem::GetExpressionList(void) const { return m_ExpressionList; } diff --git a/lib/config/configitem.hpp b/lib/config/configitem.hpp index 96dd7b0d7..1c7d23820 100644 --- a/lib/config/configitem.hpp +++ b/lib/config/configitem.hpp @@ -21,7 +21,7 @@ #define CONFIGITEM_H #include "config/i2-config.hpp" -#include "config/aexpression.hpp" +#include "config/expression.hpp" #include "base/dynamicobject.hpp" namespace icinga @@ -38,7 +38,7 @@ public: DECLARE_PTR_TYPEDEFS(ConfigItem); ConfigItem(const String& type, const String& name, bool abstract, - const AExpression::Ptr& exprl, const DebugInfo& debuginfo, + const Expression::Ptr& exprl, const DebugInfo& debuginfo, const Dictionary::Ptr& scope, const String& zone); String GetType(void) const; @@ -47,7 +47,7 @@ public: std::vector GetParents(void) const; - AExpression::Ptr GetExpressionList(void) const; + Expression::Ptr GetExpressionList(void) const; Dictionary::Ptr GetProperties(void); Dictionary::Ptr GetDebugHints(void) const; @@ -77,7 +77,7 @@ private: bool m_Abstract; /**< Whether this is a template. */ bool m_Validated; /** Whether this object has been validated. */ - AExpression::Ptr m_ExpressionList; + Expression::Ptr m_ExpressionList; Dictionary::Ptr m_Properties; Dictionary::Ptr m_DebugHints; std::vector m_ParentNames; /**< The names of parent configuration diff --git a/lib/config/configitembuilder.cpp b/lib/config/configitembuilder.cpp index 6de15f19f..8f14f0c00 100644 --- a/lib/config/configitembuilder.cpp +++ b/lib/config/configitembuilder.cpp @@ -64,7 +64,7 @@ void ConfigItemBuilder::SetZone(const String& zone) m_Zone = zone; } -void ConfigItemBuilder::AddExpression(const AExpression::Ptr& expr) +void ConfigItemBuilder::AddExpression(const Expression::Ptr& expr) { m_Expressions->Add(expr); } @@ -93,14 +93,14 @@ ConfigItem::Ptr ConfigItemBuilder::Compile(void) Array::Ptr templateArray = make_shared(); templateArray->Add(m_Name); - exprs->Add(make_shared(&AExpression::OpSetPlus, - make_shared(&AExpression::OpLiteral, "templates", m_DebugInfo), - make_shared(&AExpression::OpLiteral, templateArray, m_DebugInfo), + exprs->Add(make_shared(&Expression::OpSetPlus, + make_shared(&Expression::OpLiteral, "templates", m_DebugInfo), + make_shared(&Expression::OpLiteral, templateArray, m_DebugInfo), m_DebugInfo)); - exprs->Add(make_shared(&AExpression::OpDict, m_Expressions, true, m_DebugInfo)); + exprs->Add(make_shared(&Expression::OpDict, m_Expressions, true, m_DebugInfo)); - AExpression::Ptr exprl = make_shared(&AExpression::OpDict, exprs, true, m_DebugInfo); + Expression::Ptr exprl = make_shared(&Expression::OpDict, exprs, true, m_DebugInfo); return make_shared(m_Type, m_Name, m_Abstract, exprl, m_DebugInfo, m_Scope, m_Zone); diff --git a/lib/config/configitembuilder.hpp b/lib/config/configitembuilder.hpp index f53fb7b7c..30b16f0c9 100644 --- a/lib/config/configitembuilder.hpp +++ b/lib/config/configitembuilder.hpp @@ -20,7 +20,7 @@ #ifndef CONFIGITEMBUILDER_H #define CONFIGITEMBUILDER_H -#include "config/aexpression.hpp" +#include "config/expression.hpp" #include "config/configitem.hpp" #include "base/debuginfo.hpp" #include "base/object.hpp" @@ -48,7 +48,7 @@ public: void SetScope(const Dictionary::Ptr& scope); void SetZone(const String& zone); - void AddExpression(const AExpression::Ptr& expr); + void AddExpression(const Expression::Ptr& expr); ConfigItem::Ptr Compile(void); diff --git a/lib/config/aexpression.cpp b/lib/config/expression.cpp similarity index 73% rename from lib/config/aexpression.cpp rename to lib/config/expression.cpp index 8e3f34625..78f354a54 100644 --- a/lib/config/aexpression.cpp +++ b/lib/config/expression.cpp @@ -17,7 +17,7 @@ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * ******************************************************************************/ -#include "config/aexpression.hpp" +#include "config/expression.hpp" #include "config/configitem.hpp" #include "config/configitembuilder.hpp" #include "config/applyrule.hpp" @@ -37,22 +37,22 @@ using namespace icinga; -AExpression::AExpression(OpCallback op, const Value& operand1, const DebugInfo& di) +Expression::Expression(OpCallback op, const Value& operand1, const DebugInfo& di) : m_Operator(op), m_Operand1(operand1), m_Operand2(), m_DebugInfo(di) { } -AExpression::AExpression(OpCallback op, const Value& operand1, const Value& operand2, const DebugInfo& di) +Expression::Expression(OpCallback op, const Value& operand1, const Value& operand2, const DebugInfo& di) : m_Operator(op), m_Operand1(operand1), m_Operand2(operand2), m_DebugInfo(di) { } -Value AExpression::Evaluate(const Dictionary::Ptr& locals, DebugHint *dhint) const +Value Expression::Evaluate(const Dictionary::Ptr& locals, DebugHint *dhint) const { try { #ifdef _DEBUG - if (m_Operator != &AExpression::OpLiteral) { + if (m_Operator != &Expression::OpLiteral) { std::ostringstream msgbuf; ShowCodeFragment(msgbuf, m_DebugInfo, false); - Log(LogDebug, "AExpression", "Executing:\n" + msgbuf.str()); + Log(LogDebug, "Expression", "Executing:\n" + msgbuf.str()); } #endif /* _DEBUG */ @@ -65,13 +65,13 @@ Value AExpression::Evaluate(const Dictionary::Ptr& locals, DebugHint *dhint) con } } -void AExpression::MakeInline(void) +void Expression::MakeInline(void) { - if (m_Operator == &AExpression::OpDict) + if (m_Operator == &Expression::OpDict) m_Operand2 = true; } -void AExpression::DumpOperand(std::ostream& stream, const Value& operand, int indent) { +void Expression::DumpOperand(std::ostream& stream, const Value& operand, int indent) { if (operand.IsObjectType()) { Array::Ptr arr = operand; stream << String(indent, ' ') << "Array:\n"; @@ -79,15 +79,15 @@ void AExpression::DumpOperand(std::ostream& stream, const Value& operand, int in BOOST_FOREACH(const Value& elem, arr) { DumpOperand(stream, elem, indent + 1); } - } else if (operand.IsObjectType()) { - AExpression::Ptr left = operand; + } else if (operand.IsObjectType()) { + Expression::Ptr left = operand; left->Dump(stream, indent); } else { stream << String(indent, ' ') << JsonSerialize(operand) << "\n"; } } -void AExpression::Dump(std::ostream& stream, int indent) const +void Expression::Dump(std::ostream& stream, int indent) const { String sym = Utility::GetSymbolName(reinterpret_cast(m_Operator)); stream << String(indent, ' ') << "op: " << Utility::DemangleSymbolName(sym) << "\n"; @@ -98,22 +98,22 @@ void AExpression::Dump(std::ostream& stream, int indent) const DumpOperand(stream, m_Operand2, indent + 1); } -Value AExpression::EvaluateOperand1(const Dictionary::Ptr& locals, DebugHint *dhint) const +Value Expression::EvaluateOperand1(const Dictionary::Ptr& locals, DebugHint *dhint) const { - return static_cast(m_Operand1)->Evaluate(locals, dhint); + return static_cast(m_Operand1)->Evaluate(locals, dhint); } -Value AExpression::EvaluateOperand2(const Dictionary::Ptr& locals, DebugHint *dhint) const +Value Expression::EvaluateOperand2(const Dictionary::Ptr& locals, DebugHint *dhint) const { - return static_cast(m_Operand2)->Evaluate(locals, dhint); + return static_cast(m_Operand2)->Evaluate(locals, dhint); } -Value AExpression::OpLiteral(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpLiteral(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { return expr->m_Operand1; } -Value AExpression::OpVariable(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpVariable(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { Dictionary::Ptr scope = locals; @@ -127,87 +127,87 @@ Value AExpression::OpVariable(const AExpression *expr, const Dictionary::Ptr& lo return ScriptVariable::Get(expr->m_Operand1); } -Value AExpression::OpNegate(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpNegate(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { return ~(long)expr->EvaluateOperand1(locals); } -Value AExpression::OpLogicalNegate(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpLogicalNegate(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { return !expr->EvaluateOperand1(locals).ToBool(); } -Value AExpression::OpAdd(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpAdd(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { return expr->EvaluateOperand1(locals) + expr->EvaluateOperand2(locals); } -Value AExpression::OpSubtract(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpSubtract(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { return expr->EvaluateOperand1(locals) - expr->EvaluateOperand2(locals); } -Value AExpression::OpMultiply(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpMultiply(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { return expr->EvaluateOperand1(locals) * expr->EvaluateOperand2(locals); } -Value AExpression::OpDivide(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpDivide(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { return expr->EvaluateOperand1(locals) / expr->EvaluateOperand2(locals); } -Value AExpression::OpBinaryAnd(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpBinaryAnd(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { return expr->EvaluateOperand1(locals) & expr->EvaluateOperand2(locals); } -Value AExpression::OpBinaryOr(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpBinaryOr(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { return expr->EvaluateOperand1(locals) | expr->EvaluateOperand2(locals); } -Value AExpression::OpShiftLeft(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpShiftLeft(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { return expr->EvaluateOperand1(locals) << expr->EvaluateOperand2(locals); } -Value AExpression::OpShiftRight(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpShiftRight(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { return expr->EvaluateOperand1(locals) >> expr->EvaluateOperand2(locals); } -Value AExpression::OpEqual(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpEqual(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { return expr->EvaluateOperand1(locals) == expr->EvaluateOperand2(locals); } -Value AExpression::OpNotEqual(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpNotEqual(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { return expr->EvaluateOperand1(locals) != expr->EvaluateOperand2(locals); } -Value AExpression::OpLessThan(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpLessThan(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { return expr->EvaluateOperand1(locals) < expr->EvaluateOperand2(locals); } -Value AExpression::OpGreaterThan(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpGreaterThan(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { return expr->EvaluateOperand1(locals) > expr->EvaluateOperand2(locals); } -Value AExpression::OpLessThanOrEqual(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpLessThanOrEqual(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { return expr->EvaluateOperand1(locals) <= expr->EvaluateOperand2(locals); } -Value AExpression::OpGreaterThanOrEqual(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpGreaterThanOrEqual(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { return expr->EvaluateOperand1(locals) >= expr->EvaluateOperand2(locals); } -Value AExpression::OpIn(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpIn(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { Value right = expr->EvaluateOperand2(locals); @@ -231,22 +231,22 @@ Value AExpression::OpIn(const AExpression *expr, const Dictionary::Ptr& locals, return found; } -Value AExpression::OpNotIn(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpNotIn(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { return !OpIn(expr, locals, dhint); } -Value AExpression::OpLogicalAnd(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpLogicalAnd(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { return expr->EvaluateOperand1(locals).ToBool() && expr->EvaluateOperand2(locals).ToBool(); } -Value AExpression::OpLogicalOr(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpLogicalOr(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { return expr->EvaluateOperand1(locals).ToBool() || expr->EvaluateOperand2(locals).ToBool(); } -Value AExpression::OpFunctionCall(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpFunctionCall(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { Value funcName = expr->EvaluateOperand1(locals); @@ -263,21 +263,21 @@ Value AExpression::OpFunctionCall(const AExpression *expr, const Dictionary::Ptr Array::Ptr arr = expr->EvaluateOperand2(locals); std::vector arguments; for (Array::SizeType index = 0; index < arr->GetLength(); index++) { - const AExpression::Ptr& aexpr = arr->Get(index); + const Expression::Ptr& aexpr = arr->Get(index); arguments.push_back(aexpr->Evaluate(locals)); } return func->Invoke(arguments); } -Value AExpression::OpArray(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpArray(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { Array::Ptr arr = expr->m_Operand1; Array::Ptr result = make_shared(); if (arr) { for (Array::SizeType index = 0; index < arr->GetLength(); index++) { - const AExpression::Ptr& aexpr = arr->Get(index); + const Expression::Ptr& aexpr = arr->Get(index); result->Add(aexpr->Evaluate(locals)); } } @@ -285,7 +285,7 @@ Value AExpression::OpArray(const AExpression *expr, const Dictionary::Ptr& local return result; } -Value AExpression::OpDict(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpDict(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { Array::Ptr arr = expr->m_Operand1; bool in_place = expr->m_Operand2; @@ -295,7 +295,7 @@ Value AExpression::OpDict(const AExpression *expr, const Dictionary::Ptr& locals if (arr) { for (Array::SizeType index = 0; index < arr->GetLength(); index++) { - const AExpression::Ptr& aexpr = arr->Get(index); + const Expression::Ptr& aexpr = arr->Get(index); Dictionary::Ptr alocals = in_place ? locals : result; aexpr->Evaluate(alocals, dhint); @@ -309,7 +309,7 @@ Value AExpression::OpDict(const AExpression *expr, const Dictionary::Ptr& locals return xresult; } -Value AExpression::OpSet(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpSet(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { Value index = expr->EvaluateOperand1(locals); @@ -326,14 +326,14 @@ Value AExpression::OpSet(const AExpression *expr, const Dictionary::Ptr& locals, return right; } -Value AExpression::OpSetPlus(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpSetPlus(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { Value index = expr->EvaluateOperand1(locals); Value left = locals->Get(index); - AExpression::Ptr exp_right = expr->m_Operand2; + Expression::Ptr exp_right = expr->m_Operand2; Dictionary::Ptr xlocals = locals; - if (exp_right->m_Operator == &AExpression::OpDict) { + if (exp_right->m_Operator == &Expression::OpDict) { xlocals = left; if (!xlocals) @@ -348,7 +348,7 @@ Value AExpression::OpSetPlus(const AExpression *expr, const Dictionary::Ptr& loc Value result = left + expr->EvaluateOperand2(xlocals, sdhint); - if (exp_right->m_Operator == &AExpression::OpDict) { + if (exp_right->m_Operator == &Expression::OpDict) { Dictionary::Ptr dict = result; dict->Remove("__parent"); } @@ -361,14 +361,14 @@ Value AExpression::OpSetPlus(const AExpression *expr, const Dictionary::Ptr& loc return result; } -Value AExpression::OpSetMinus(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpSetMinus(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { Value index = expr->EvaluateOperand1(locals); Value left = locals->Get(index); - AExpression::Ptr exp_right = expr->m_Operand2; + Expression::Ptr exp_right = expr->m_Operand2; Dictionary::Ptr xlocals = locals; - if (exp_right->m_Operator == &AExpression::OpDict) { + if (exp_right->m_Operator == &Expression::OpDict) { xlocals = left; if (!xlocals) @@ -383,7 +383,7 @@ Value AExpression::OpSetMinus(const AExpression *expr, const Dictionary::Ptr& lo Value result = left - expr->EvaluateOperand2(xlocals, sdhint); - if (exp_right->m_Operator == &AExpression::OpDict) { + if (exp_right->m_Operator == &Expression::OpDict) { Dictionary::Ptr dict = result; dict->Remove("__parent"); } @@ -396,14 +396,14 @@ Value AExpression::OpSetMinus(const AExpression *expr, const Dictionary::Ptr& lo return result; } -Value AExpression::OpSetMultiply(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpSetMultiply(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { Value index = expr->EvaluateOperand1(locals); Value left = locals->Get(index); - AExpression::Ptr exp_right = expr->m_Operand2; + Expression::Ptr exp_right = expr->m_Operand2; Dictionary::Ptr xlocals = locals; - if (exp_right->m_Operator == &AExpression::OpDict) { + if (exp_right->m_Operator == &Expression::OpDict) { xlocals = left; if (!xlocals) @@ -418,7 +418,7 @@ Value AExpression::OpSetMultiply(const AExpression *expr, const Dictionary::Ptr& Value result = left * expr->EvaluateOperand2(xlocals, sdhint); - if (exp_right->m_Operator == &AExpression::OpDict) { + if (exp_right->m_Operator == &Expression::OpDict) { Dictionary::Ptr dict = result; dict->Remove("__parent"); } @@ -431,14 +431,14 @@ Value AExpression::OpSetMultiply(const AExpression *expr, const Dictionary::Ptr& return result; } -Value AExpression::OpSetDivide(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpSetDivide(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { Value index = expr->EvaluateOperand1(locals); Value left = locals->Get(index); - AExpression::Ptr exp_right = expr->m_Operand2; + Expression::Ptr exp_right = expr->m_Operand2; Dictionary::Ptr xlocals = locals; - if (exp_right->m_Operator == &AExpression::OpDict) { + if (exp_right->m_Operator == &Expression::OpDict) { xlocals = left; if (!xlocals) @@ -453,7 +453,7 @@ Value AExpression::OpSetDivide(const AExpression *expr, const Dictionary::Ptr& l Value result = left / expr->EvaluateOperand2(xlocals, sdhint); - if (exp_right->m_Operator == &AExpression::OpDict) { + if (exp_right->m_Operator == &Expression::OpDict) { Dictionary::Ptr dict = result; dict->Remove("__parent"); } @@ -466,7 +466,7 @@ Value AExpression::OpSetDivide(const AExpression *expr, const Dictionary::Ptr& l return result; } -Value AExpression::OpIndexer(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpIndexer(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { Value value = expr->EvaluateOperand1(locals); Value index = expr->EvaluateOperand2(locals); @@ -497,7 +497,7 @@ Value AExpression::OpIndexer(const AExpression *expr, const Dictionary::Ptr& loc } } -Value AExpression::OpImport(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpImport(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint) { Value type = expr->EvaluateOperand1(locals); Value name = expr->EvaluateOperand2(locals); @@ -512,7 +512,7 @@ Value AExpression::OpImport(const AExpression *expr, const Dictionary::Ptr& loca return Empty; } -Value AExpression::FunctionWrapper(const std::vector& arguments, const Array::Ptr& funcargs, const AExpression::Ptr& expr, const Dictionary::Ptr& scope) +Value Expression::FunctionWrapper(const std::vector& arguments, const Array::Ptr& funcargs, const Expression::Ptr& expr, const Dictionary::Ptr& scope) { if (arguments.size() < funcargs->GetLength()) BOOST_THROW_EXCEPTION(ConfigError("Too few arguments for function")); @@ -527,14 +527,14 @@ Value AExpression::FunctionWrapper(const std::vector& arguments, const Ar return locals->Get("__result"); } -Value AExpression::OpFunction(const AExpression* expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpFunction(const Expression* expr, const Dictionary::Ptr& locals, DebugHint *dhint) { Array::Ptr left = expr->m_Operand1; - AExpression::Ptr aexpr = left->Get(1); + Expression::Ptr aexpr = left->Get(1); String name = left->Get(0); Array::Ptr funcargs = expr->m_Operand2; - ScriptFunction::Ptr func = make_shared(boost::bind(&AExpression::FunctionWrapper, _1, funcargs, aexpr, locals)); + ScriptFunction::Ptr func = make_shared(boost::bind(&Expression::FunctionWrapper, _1, funcargs, aexpr, locals)); if (!name.IsEmpty()) ScriptFunction::Register(name, func); @@ -542,14 +542,14 @@ Value AExpression::OpFunction(const AExpression* expr, const Dictionary::Ptr& lo return func; } -Value AExpression::OpApply(const AExpression* expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpApply(const Expression* expr, const Dictionary::Ptr& locals, DebugHint *dhint) { Array::Ptr left = expr->m_Operand1; - AExpression::Ptr exprl = expr->m_Operand2; + Expression::Ptr exprl = expr->m_Operand2; String type = left->Get(0); String target = left->Get(1); - AExpression::Ptr aname = left->Get(2); - AExpression::Ptr filter = left->Get(3); + Expression::Ptr aname = left->Get(2); + Expression::Ptr filter = left->Get(3); String name = aname->Evaluate(locals, dhint); @@ -558,14 +558,14 @@ Value AExpression::OpApply(const AExpression* expr, const Dictionary::Ptr& local return Empty; } -Value AExpression::OpObject(const AExpression* expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpObject(const Expression* expr, const Dictionary::Ptr& locals, DebugHint *dhint) { Array::Ptr left = expr->m_Operand1; - AExpression::Ptr exprl = expr->m_Operand2; + Expression::Ptr exprl = expr->m_Operand2; bool abstract = left->Get(0); String type = left->Get(1); - AExpression::Ptr aname = left->Get(2); - AExpression::Ptr filter = left->Get(3); + Expression::Ptr aname = left->Get(2); + Expression::Ptr filter = left->Get(3); String zone = left->Get(4); String name = aname->Evaluate(locals, dhint); @@ -612,12 +612,12 @@ Value AExpression::OpObject(const AExpression* expr, const Dictionary::Ptr& loca return Empty; } -Value AExpression::OpFor(const AExpression* expr, const Dictionary::Ptr& locals, DebugHint *dhint) +Value Expression::OpFor(const Expression* expr, const Dictionary::Ptr& locals, DebugHint *dhint) { Array::Ptr left = expr->m_Operand1; String varname = left->Get(0); - AExpression::Ptr aexpr = left->Get(1); - AExpression::Ptr ascope = expr->m_Operand2; + Expression::Ptr aexpr = left->Get(1); + Expression::Ptr ascope = expr->m_Operand2; Array::Ptr arr = aexpr->Evaluate(locals, dhint); diff --git a/lib/config/aexpression.hpp b/lib/config/expression.hpp similarity index 51% rename from lib/config/aexpression.hpp rename to lib/config/expression.hpp index 0e2f97c22..430c75f0c 100644 --- a/lib/config/aexpression.hpp +++ b/lib/config/expression.hpp @@ -17,8 +17,8 @@ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * ******************************************************************************/ -#ifndef AEXPRESSION_H -#define AEXPRESSION_H +#ifndef EXPRESSION_H +#define EXPRESSION_H #include "config/i2-config.hpp" #include "base/debuginfo.hpp" @@ -49,15 +49,15 @@ struct DebugHint /** * @ingroup config */ -class I2_CONFIG_API AExpression : public Object +class I2_CONFIG_API Expression : public Object { public: - DECLARE_PTR_TYPEDEFS(AExpression); + DECLARE_PTR_TYPEDEFS(Expression); - typedef Value (*OpCallback)(const AExpression *, const Dictionary::Ptr&, DebugHint *dhint); + typedef Value (*OpCallback)(const Expression *, const Dictionary::Ptr&, DebugHint *dhint); - AExpression(OpCallback op, const Value& operand1, const DebugInfo& di); - AExpression(OpCallback op, const Value& operand1, const Value& operand2, const DebugInfo& di); + Expression(OpCallback op, const Value& operand1, const DebugInfo& di); + Expression(OpCallback op, const Value& operand1, const Value& operand2, const DebugInfo& di); Value Evaluate(const Dictionary::Ptr& locals, DebugHint *dhint = NULL) const; @@ -65,42 +65,42 @@ public: void Dump(std::ostream& stream, int indent = 0) const; - static Value OpLiteral(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpVariable(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpNegate(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpLogicalNegate(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpAdd(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpSubtract(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpMultiply(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpDivide(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpBinaryAnd(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpBinaryOr(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpShiftLeft(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpShiftRight(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpEqual(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpNotEqual(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpLessThan(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpGreaterThan(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpLessThanOrEqual(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpGreaterThanOrEqual(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpIn(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpNotIn(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpLogicalAnd(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpLogicalOr(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpFunctionCall(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpArray(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpDict(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpSet(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpSetPlus(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpSetMinus(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpSetMultiply(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpSetDivide(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpIndexer(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpImport(const AExpression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpFunction(const AExpression* expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpApply(const AExpression* expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpObject(const AExpression* expr, const Dictionary::Ptr& locals, DebugHint *dhint); - static Value OpFor(const AExpression* expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpLiteral(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpVariable(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpNegate(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpLogicalNegate(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpAdd(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpSubtract(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpMultiply(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpDivide(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpBinaryAnd(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpBinaryOr(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpShiftLeft(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpShiftRight(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpEqual(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpNotEqual(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpLessThan(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpGreaterThan(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpLessThanOrEqual(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpGreaterThanOrEqual(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpIn(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpNotIn(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpLogicalAnd(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpLogicalOr(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpFunctionCall(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpArray(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpDict(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpSet(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpSetPlus(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpSetMinus(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpSetMultiply(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpSetDivide(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpIndexer(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpImport(const Expression *expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpFunction(const Expression* expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpApply(const Expression* expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpObject(const Expression* expr, const Dictionary::Ptr& locals, DebugHint *dhint); + static Value OpFor(const Expression* expr, const Dictionary::Ptr& locals, DebugHint *dhint); private: OpCallback m_Operator; @@ -114,9 +114,9 @@ private: static void DumpOperand(std::ostream& stream, const Value& operand, int indent); static Value FunctionWrapper(const std::vector& arguments, const Array::Ptr& funcargs, - const AExpression::Ptr& expr, const Dictionary::Ptr& scope); + const Expression::Ptr& expr, const Dictionary::Ptr& scope); }; } -#endif /* TYPERULE_H */ +#endif /* EXPRESSION_H */ diff --git a/lib/config/objectrule.cpp b/lib/config/objectrule.cpp index ace1ca8b7..36525ff0b 100644 --- a/lib/config/objectrule.cpp +++ b/lib/config/objectrule.cpp @@ -26,8 +26,8 @@ using namespace icinga; ObjectRule::RuleMap ObjectRule::m_Rules; ObjectRule::CallbackMap ObjectRule::m_Callbacks; -ObjectRule::ObjectRule(const String& name, const AExpression::Ptr& expression, - const AExpression::Ptr& filter, const DebugInfo& di, const Dictionary::Ptr& scope) +ObjectRule::ObjectRule(const String& name, const Expression::Ptr& expression, + const Expression::Ptr& filter, const DebugInfo& di, const Dictionary::Ptr& scope) : m_Name(name), m_Expression(expression), m_Filter(filter), m_DebugInfo(di), m_Scope(scope) { } @@ -36,12 +36,12 @@ String ObjectRule::GetName(void) const return m_Name; } -AExpression::Ptr ObjectRule::GetExpression(void) const +Expression::Ptr ObjectRule::GetExpression(void) const { return m_Expression; } -AExpression::Ptr ObjectRule::GetFilter(void) const +Expression::Ptr ObjectRule::GetFilter(void) const { return m_Filter; } @@ -57,7 +57,7 @@ Dictionary::Ptr ObjectRule::GetScope(void) const } void ObjectRule::AddRule(const String& sourceType, const String& name, - const AExpression::Ptr& expression, const AExpression::Ptr& filter, + const Expression::Ptr& expression, const Expression::Ptr& filter, const DebugInfo& di, const Dictionary::Ptr& scope) { m_Rules[sourceType].push_back(ObjectRule(name, expression, filter, di, scope)); diff --git a/lib/config/objectrule.hpp b/lib/config/objectrule.hpp index f3ed2505c..079a38983 100644 --- a/lib/config/objectrule.hpp +++ b/lib/config/objectrule.hpp @@ -21,7 +21,7 @@ #define OBJECTRULE_H #include "config/i2-config.hpp" -#include "config/aexpression.hpp" +#include "config/expression.hpp" #include "base/debuginfo.hpp" #include "base/dynamictype.hpp" @@ -39,15 +39,15 @@ public: typedef std::map > RuleMap; String GetName(void) const; - AExpression::Ptr GetExpression(void) const; - AExpression::Ptr GetFilter(void) const; + Expression::Ptr GetExpression(void) const; + Expression::Ptr GetFilter(void) const; DebugInfo GetDebugInfo(void) const; Dictionary::Ptr GetScope(void) const; bool EvaluateFilter(const Dictionary::Ptr& scope) const; - static void AddRule(const String& sourceType, const String& name, const AExpression::Ptr& expression, - const AExpression::Ptr& filter, const DebugInfo& di, const Dictionary::Ptr& scope); + static void AddRule(const String& sourceType, const String& name, const Expression::Ptr& expression, + const Expression::Ptr& filter, const DebugInfo& di, const Dictionary::Ptr& scope); static void EvaluateRules(bool clear); static void RegisterType(const String& sourceType, const ObjectRule::Callback& callback); @@ -55,16 +55,16 @@ public: private: String m_Name; - AExpression::Ptr m_Expression; - AExpression::Ptr m_Filter; + Expression::Ptr m_Expression; + Expression::Ptr m_Filter; DebugInfo m_DebugInfo; Dictionary::Ptr m_Scope; static CallbackMap m_Callbacks; static RuleMap m_Rules; - ObjectRule(const String& name, const AExpression::Ptr& expression, - const AExpression::Ptr& filter, const DebugInfo& di, const Dictionary::Ptr& scope); + ObjectRule(const String& name, const Expression::Ptr& expression, + const Expression::Ptr& filter, const DebugInfo& di, const Dictionary::Ptr& scope); }; } diff --git a/lib/icinga/dependency-apply.cpp b/lib/icinga/dependency-apply.cpp index f577f94eb..c546de0cc 100644 --- a/lib/icinga/dependency-apply.cpp +++ b/lib/icinga/dependency-apply.cpp @@ -71,29 +71,29 @@ bool Dependency::EvaluateApplyRuleOne(const Checkable::Ptr& checkable, const App builder->SetName(rule.GetName()); builder->SetScope(rule.GetScope()); - builder->AddExpression(make_shared(&AExpression::OpSet, - make_shared(&AExpression::OpLiteral, "parent_host_name", di), - make_shared(&AExpression::OpLiteral, host->GetName(), di), + builder->AddExpression(make_shared(&Expression::OpSet, + make_shared(&Expression::OpLiteral, "parent_host_name", di), + make_shared(&Expression::OpLiteral, host->GetName(), di), di)); - builder->AddExpression(make_shared(&AExpression::OpSet, - make_shared(&AExpression::OpLiteral, "child_host_name", di), - make_shared(&AExpression::OpLiteral, host->GetName(), di), + builder->AddExpression(make_shared(&Expression::OpSet, + make_shared(&Expression::OpLiteral, "child_host_name", di), + make_shared(&Expression::OpLiteral, host->GetName(), di), di)); if (service) { - builder->AddExpression(make_shared(&AExpression::OpSet, - make_shared(&AExpression::OpLiteral, "child_service_name", di), - make_shared(&AExpression::OpLiteral, service->GetShortName(), di), + builder->AddExpression(make_shared(&Expression::OpSet, + make_shared(&Expression::OpLiteral, "child_service_name", di), + make_shared(&Expression::OpLiteral, service->GetShortName(), di), di)); } String zone = checkable->GetZone(); if (!zone.IsEmpty()) { - builder->AddExpression(make_shared(&AExpression::OpSet, - make_shared(&AExpression::OpLiteral, "zone", di), - make_shared(&AExpression::OpLiteral, zone, di), + builder->AddExpression(make_shared(&Expression::OpSet, + make_shared(&Expression::OpLiteral, "zone", di), + make_shared(&Expression::OpLiteral, zone, di), di)); } diff --git a/lib/icinga/notification-apply.cpp b/lib/icinga/notification-apply.cpp index 9798c355d..961abbc5b 100644 --- a/lib/icinga/notification-apply.cpp +++ b/lib/icinga/notification-apply.cpp @@ -71,24 +71,24 @@ bool Notification::EvaluateApplyRuleOne(const Checkable::Ptr& checkable, const A builder->SetName(rule.GetName()); builder->SetScope(rule.GetScope()); - builder->AddExpression(make_shared(&AExpression::OpSet, - make_shared(&AExpression::OpLiteral, "host_name", di), - make_shared(&AExpression::OpLiteral, host->GetName(), di), + builder->AddExpression(make_shared(&Expression::OpSet, + make_shared(&Expression::OpLiteral, "host_name", di), + make_shared(&Expression::OpLiteral, host->GetName(), di), di)); if (service) { - builder->AddExpression(make_shared(&AExpression::OpSet, - make_shared(&AExpression::OpLiteral, "service_name", di), - make_shared(&AExpression::OpLiteral, service->GetShortName(), di), + builder->AddExpression(make_shared(&Expression::OpSet, + make_shared(&Expression::OpLiteral, "service_name", di), + make_shared(&Expression::OpLiteral, service->GetShortName(), di), di)); } String zone = checkable->GetZone(); if (!zone.IsEmpty()) { - builder->AddExpression(make_shared(&AExpression::OpSet, - make_shared(&AExpression::OpLiteral, "zone", di), - make_shared(&AExpression::OpLiteral, zone, di), + builder->AddExpression(make_shared(&Expression::OpSet, + make_shared(&Expression::OpLiteral, "zone", di), + make_shared(&Expression::OpLiteral, zone, di), di)); } diff --git a/lib/icinga/scheduleddowntime-apply.cpp b/lib/icinga/scheduleddowntime-apply.cpp index bcb61e4aa..d6a8edbfb 100644 --- a/lib/icinga/scheduleddowntime-apply.cpp +++ b/lib/icinga/scheduleddowntime-apply.cpp @@ -70,24 +70,24 @@ bool ScheduledDowntime::EvaluateApplyRule(const Checkable::Ptr& checkable, const builder->SetName(rule.GetName()); builder->SetScope(rule.GetScope()); - builder->AddExpression(make_shared(&AExpression::OpSet, - make_shared(&AExpression::OpLiteral, "host_name", di), - make_shared(&AExpression::OpLiteral, host->GetName(), di), + builder->AddExpression(make_shared(&Expression::OpSet, + make_shared(&Expression::OpLiteral, "host_name", di), + make_shared(&Expression::OpLiteral, host->GetName(), di), di)); if (service) { - builder->AddExpression(make_shared(&AExpression::OpSet, - make_shared(&AExpression::OpLiteral, "service_name", di), - make_shared(&AExpression::OpLiteral, service->GetShortName(), di), + builder->AddExpression(make_shared(&Expression::OpSet, + make_shared(&Expression::OpLiteral, "service_name", di), + make_shared(&Expression::OpLiteral, service->GetShortName(), di), di)); } String zone = checkable->GetZone(); if (!zone.IsEmpty()) { - builder->AddExpression(make_shared(&AExpression::OpSet, - make_shared(&AExpression::OpLiteral, "zone", di), - make_shared(&AExpression::OpLiteral, zone, di), + builder->AddExpression(make_shared(&Expression::OpSet, + make_shared(&Expression::OpLiteral, "zone", di), + make_shared(&Expression::OpLiteral, zone, di), di)); } diff --git a/lib/icinga/service-apply.cpp b/lib/icinga/service-apply.cpp index c3c367c38..86b72e9a3 100644 --- a/lib/icinga/service-apply.cpp +++ b/lib/icinga/service-apply.cpp @@ -63,22 +63,22 @@ bool Service::EvaluateApplyRuleOne(const Host::Ptr& host, const ApplyRule& rule) builder->SetName(rule.GetName()); builder->SetScope(rule.GetScope()); - builder->AddExpression(make_shared(&AExpression::OpSet, - make_shared(&AExpression::OpLiteral, "host_name", di), - make_shared(&AExpression::OpLiteral, host->GetName(), di), + builder->AddExpression(make_shared(&Expression::OpSet, + make_shared(&Expression::OpLiteral, "host_name", di), + make_shared(&Expression::OpLiteral, host->GetName(), di), di)); - builder->AddExpression(make_shared(&AExpression::OpSet, - make_shared(&AExpression::OpLiteral, "name", di), - make_shared(&AExpression::OpLiteral, rule.GetName(), di), + builder->AddExpression(make_shared(&Expression::OpSet, + make_shared(&Expression::OpLiteral, "name", di), + make_shared(&Expression::OpLiteral, rule.GetName(), di), di)); String zone = host->GetZone(); if (!zone.IsEmpty()) { - builder->AddExpression(make_shared(&AExpression::OpSet, - make_shared(&AExpression::OpLiteral, "zone", di), - make_shared(&AExpression::OpLiteral, zone, di), + builder->AddExpression(make_shared(&Expression::OpSet, + make_shared(&Expression::OpLiteral, "zone", di), + make_shared(&Expression::OpLiteral, zone, di), di)); } -- 2.40.0