]> granicus.if.org Git - icinga2/commitdiff
Replace std::shared_ptr<Expression> with Expression::Ptr
authorAlexander A. Klimov <alexander.klimov@icinga.com>
Fri, 26 Jul 2019 12:17:27 +0000 (14:17 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Mon, 21 Oct 2019 15:10:51 +0000 (17:10 +0200)
refs #7361

14 files changed:
lib/config/applyrule.cpp
lib/config/applyrule.hpp
lib/config/config_parser.yy
lib/config/configcompiler.cpp
lib/config/configcompiler.hpp
lib/config/configitem.cpp
lib/config/configitem.hpp
lib/config/configitembuilder.cpp
lib/config/configitembuilder.hpp
lib/config/expression.cpp
lib/config/expression.hpp
lib/config/vmops.hpp
lib/remote/eventqueue.cpp
lib/remote/eventqueue.hpp

index f7b7cbdd20b283956120baf77a0bd08677ecda75..5042eb6b6a952f51e662159a16410c50058a2c65 100644 (file)
@@ -9,8 +9,8 @@ using namespace icinga;
 ApplyRule::RuleMap ApplyRule::m_Rules;
 ApplyRule::TypeMap ApplyRule::m_Types;
 
-ApplyRule::ApplyRule(String targetType, String name, std::shared_ptr<Expression> expression,
-       std::shared_ptr<Expression> filter, String package, String fkvar, String fvvar, std::shared_ptr<Expression> fterm,
+ApplyRule::ApplyRule(String targetType, String name, Expression::Ptr expression,
+       Expression::Ptr filter, String package, String fkvar, String fvvar, Expression::Ptr fterm,
        bool ignoreOnError, DebugInfo di, Dictionary::Ptr scope)
        : m_TargetType(std::move(targetType)), m_Name(std::move(name)), m_Expression(std::move(expression)), m_Filter(std::move(filter)), m_Package(std::move(package)), m_FKVar(std::move(fkvar)),
        m_FVVar(std::move(fvvar)), m_FTerm(std::move(fterm)), m_IgnoreOnError(ignoreOnError), m_DebugInfo(std::move(di)), m_Scope(std::move(scope)), m_HasMatches(false)
@@ -26,12 +26,12 @@ String ApplyRule::GetName() const
        return m_Name;
 }
 
-std::shared_ptr<Expression> ApplyRule::GetExpression() const
+Expression::Ptr ApplyRule::GetExpression() const
 {
        return m_Expression;
 }
 
-std::shared_ptr<Expression> ApplyRule::GetFilter() const
+Expression::Ptr ApplyRule::GetFilter() const
 {
        return m_Filter;
 }
@@ -51,7 +51,7 @@ String ApplyRule::GetFVVar() const
        return m_FVVar;
 }
 
-std::shared_ptr<Expression> ApplyRule::GetFTerm() const
+Expression::Ptr ApplyRule::GetFTerm() const
 {
        return m_FTerm;
 }
@@ -72,8 +72,8 @@ Dictionary::Ptr ApplyRule::GetScope() const
 }
 
 void ApplyRule::AddRule(const String& sourceType, const String& targetType, const String& name,
-       const std::shared_ptr<Expression>& expression, const std::shared_ptr<Expression>& filter, const String& package, const String& fkvar,
-       const String& fvvar, const std::shared_ptr<Expression>& fterm, bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope)
+       const Expression::Ptr& expression, const Expression::Ptr& filter, const String& package, const String& fkvar,
+       const String& fvvar, const Expression::Ptr& fterm, bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope)
 {
        m_Rules[sourceType].push_back(ApplyRule(targetType, name, expression, filter, package, fkvar, fvvar, fterm, ignoreOnError, di, scope));
 }
index bc4868b9e750c3a4121e15f201b60f83536839b9..303b259e1d3ccfbf9f0d5a414a48775d44213f71 100644 (file)
@@ -21,12 +21,12 @@ public:
 
        String GetTargetType() const;
        String GetName() const;
-       std::shared_ptr<Expression> GetExpression() const;
-       std::shared_ptr<Expression> GetFilter() const;
+       Expression::Ptr GetExpression() const;
+       Expression::Ptr GetFilter() const;
        String GetPackage() const;
        String GetFKVar() const;
        String GetFVVar() const;
-       std::shared_ptr<Expression> GetFTerm() const;
+       Expression::Ptr GetFTerm() const;
        bool GetIgnoreOnError() const;
        DebugInfo GetDebugInfo() const;
        Dictionary::Ptr GetScope() const;
@@ -35,8 +35,8 @@ public:
 
        bool EvaluateFilter(ScriptFrame& frame) const;
 
-       static void AddRule(const String& sourceType, const String& targetType, const String& name, const std::shared_ptr<Expression>& expression,
-               const std::shared_ptr<Expression>& filter, const String& package, const String& fkvar, const String& fvvar, const std::shared_ptr<Expression>& fterm,
+       static void AddRule(const String& sourceType, const String& targetType, const String& name, const Expression::Ptr& expression,
+               const Expression::Ptr& filter, const String& package, const String& fkvar, const String& fvvar, const Expression::Ptr& fterm,
                bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope);
        static std::vector<ApplyRule>& GetRules(const String& type);
 
@@ -50,12 +50,12 @@ public:
 private:
        String m_TargetType;
        String m_Name;
-       std::shared_ptr<Expression> m_Expression;
-       std::shared_ptr<Expression> m_Filter;
+       Expression::Ptr m_Expression;
+       Expression::Ptr m_Filter;
        String m_Package;
        String m_FKVar;
        String m_FVVar;
-       std::shared_ptr<Expression> m_FTerm;
+       Expression::Ptr m_FTerm;
        bool m_IgnoreOnError;
        DebugInfo m_DebugInfo;
        Dictionary::Ptr m_Scope;
@@ -64,8 +64,8 @@ private:
        static TypeMap m_Types;
        static RuleMap m_Rules;
 
-       ApplyRule(String targetType, String name, std::shared_ptr<Expression> expression,
-               std::shared_ptr<Expression> filter, String package, String fkvar, String fvvar, std::shared_ptr<Expression> fterm,
+       ApplyRule(String targetType, String name, Expression::Ptr expression,
+               Expression::Ptr filter, String package, String fkvar, String fvvar, Expression::Ptr fterm,
                bool ignoreOnError, DebugInfo di, Dictionary::Ptr scope);
 };
 
index f1fcf4f7fd48ad1e285ca27869a47a4c65c02346..83a48758a558c2a3ee934525cc3de598449dc4e6 100644 (file)
@@ -596,7 +596,7 @@ lterm: T_LIBRARY rterm
        }
        | T_USING rterm
        {
-               std::shared_ptr<Expression> expr{$2};
+               Expression::Ptr expr{$2};
                context->AddImport(expr);
                $$ = MakeLiteralRaw();
        }
index 8f450994fd5db6dd7dc0b8531942c8747473253f..59285eac4349af8f0ff53f5e2c4eb9b62f77a960 100644 (file)
@@ -345,12 +345,12 @@ bool ConfigCompiler::IsAbsolutePath(const String& path)
 #endif /* _WIN32 */
 }
 
-void ConfigCompiler::AddImport(const std::shared_ptr<Expression>& import)
+void ConfigCompiler::AddImport(const Expression::Ptr& import)
 {
        m_Imports.push_back(import);
 }
 
-std::vector<std::shared_ptr<Expression> > ConfigCompiler::GetImports() const
+std::vector<Expression::Ptr> ConfigCompiler::GetImports() const
 {
        return m_Imports;
 }
index b89fdf05c5c6a6a95e2d5d36b4baddf37d817f3d..65acf8ea2e0426a09b56ac3aa091f28056a0dc0c 100644 (file)
@@ -92,8 +92,8 @@ public:
        void SetPackage(const String& package);
        String GetPackage() const;
 
-       void AddImport(const std::shared_ptr<Expression>& import);
-       std::vector<std::shared_ptr<Expression> > GetImports() const;
+       void AddImport(const Expression::Ptr& import);
+       std::vector<Expression::Ptr> GetImports() const;
 
        static void CollectIncludes(std::vector<std::unique_ptr<Expression> >& expressions,
                const String& file, const String& zone, const String& package);
@@ -114,13 +114,13 @@ public:
        static bool HasZoneConfigAuthority(const String& zoneName);
 
 private:
-       std::promise<std::shared_ptr<Expression> > m_Promise;
+       std::promise<Expression::Ptr> m_Promise;
 
        String m_Path;
        std::istream *m_Input;
        String m_Zone;
        String m_Package;
-       std::vector<std::shared_ptr<Expression> > m_Imports;
+       std::vector<Expression::Ptr> m_Imports;
 
        void *m_Scanner;
 
index 5c9f0dd5561818271b78bc8ee7d8ca067ac701a3..6dbb41f59a81b05f2a93455dfdedf3cdaab3e0d1 100644 (file)
@@ -47,8 +47,8 @@ REGISTER_FUNCTION(Internal, run_with_activation_context, &ConfigItem::RunWithAct
  * @param debuginfo Debug information.
  */
 ConfigItem::ConfigItem(Type::Ptr type, String name,
-       bool abstract, std::shared_ptr<Expression> exprl,
-       std::shared_ptr<Expression> filter, bool defaultTmpl, bool ignoreOnError,
+       bool abstract, Expression::Ptr exprl,
+       Expression::Ptr filter, bool defaultTmpl, bool ignoreOnError,
        DebugInfo debuginfo, Dictionary::Ptr scope,
        String zone, String package)
        : m_Type(std::move(type)), m_Name(std::move(name)), m_Abstract(abstract),
@@ -124,7 +124,7 @@ ConfigObject::Ptr ConfigItem::GetObject() const
  *
  * @returns The expression list.
  */
-std::shared_ptr<Expression> ConfigItem::GetExpression() const
+Expression::Ptr ConfigItem::GetExpression() const
 {
        return m_Expression;
 }
@@ -134,7 +134,7 @@ std::shared_ptr<Expression> ConfigItem::GetExpression() const
 *
 * @returns The filter expression.
 */
-std::shared_ptr<Expression> ConfigItem::GetFilter() const
+Expression::Ptr ConfigItem::GetFilter() const
 {
        return m_Filter;
 }
index 0b7ee86a3414ba094c72b768e00e794f6d6d08b1..7b765491d3524da131b33860d3931561fbc2ba9c 100644 (file)
@@ -24,8 +24,8 @@ public:
        DECLARE_PTR_TYPEDEFS(ConfigItem);
 
        ConfigItem(Type::Ptr type, String name, bool abstract,
-               std::shared_ptr<Expression> exprl,
-               std::shared_ptr<Expression> filter,
+               Expression::Ptr exprl,
+               Expression::Ptr filter,
                bool defaultTmpl, bool ignoreOnError, DebugInfo debuginfo,
                Dictionary::Ptr scope, String zone,
                String package);
@@ -38,8 +38,8 @@ public:
 
        std::vector<ConfigItem::Ptr> GetParents() const;
 
-       std::shared_ptr<Expression> GetExpression() const;
-       std::shared_ptr<Expression> GetFilter() const;
+       Expression::Ptr GetExpression() const;
+       Expression::Ptr GetFilter() const;
 
        void Register();
        void Unregister();
@@ -68,8 +68,8 @@ private:
        String m_Name; /**< The name. */
        bool m_Abstract; /**< Whether this is a template. */
 
-       std::shared_ptr<Expression> m_Expression;
-       std::shared_ptr<Expression> m_Filter;
+       Expression::Ptr m_Expression;
+       Expression::Ptr m_Filter;
        bool m_DefaultTmpl;
        bool m_IgnoreOnError;
        DebugInfo m_DebugInfo; /**< Debug information. */
index 6a64c76a8acada7a473d01757a3e0b17fc6f6e95..f7a3eadec75b16cf80c4ab27e752095ec6d50f52 100644 (file)
@@ -48,7 +48,7 @@ void ConfigItemBuilder::AddExpression(Expression *expr)
        m_Expressions.emplace_back(expr);
 }
 
-void ConfigItemBuilder::SetFilter(const std::shared_ptr<Expression>& filter)
+void ConfigItemBuilder::SetFilter(const Expression::Ptr& filter)
 {
        m_Filter = filter;
 }
@@ -111,7 +111,7 @@ ConfigItem::Ptr ConfigItemBuilder::Compile()
        dexpr->MakeInline();
        exprs.emplace_back(dexpr);
 
-       std::shared_ptr<DictExpression> exprl = std::make_shared<DictExpression>(std::move(exprs), m_DebugInfo);
+       auto exprl = new DictExpression(std::move(exprs), m_DebugInfo);
        exprl->MakeInline();
 
        return new ConfigItem(m_Type, m_Name, m_Abstract, exprl, m_Filter,
index 792e351b74407feb4df1142c425aa3547c296e48..9d2e3392f6b1a7be19ec23af3edec491cfedd8dc 100644 (file)
@@ -35,7 +35,7 @@ public:
        void SetIgnoreOnError(bool ignoreOnError);
 
        void AddExpression(Expression *expr);
-       void SetFilter(const std::shared_ptr<Expression>& filter);
+       void SetFilter(const Expression::Ptr& filter);
 
        ConfigItem::Ptr Compile();
 
@@ -44,7 +44,7 @@ private:
        String m_Name; /**< The name. */
        bool m_Abstract{false}; /**< Whether the item is abstract. */
        std::vector<std::unique_ptr<Expression> > m_Expressions; /**< Expressions for this item. */
-       std::shared_ptr<Expression> m_Filter; /**< Filter expression. */
+       Expression::Ptr m_Filter; /**< Filter expression. */
        DebugInfo m_DebugInfo; /**< Debug information. */
        Dictionary::Ptr m_Scope; /**< variable scope. */
        String m_Zone; /**< The zone. */
index 93d3dfa981bf9b9c5da111c734ec8c07d90d6ccc..1ae75fd3fba02c04704869af56e75acb6dd3e1ad 100644 (file)
@@ -100,13 +100,13 @@ const DebugInfo& DebuggableExpression::GetDebugInfo() const
        return m_DebugInfo;
 }
 
-VariableExpression::VariableExpression(String variable, std::vector<std::shared_ptr<Expression> > imports, const DebugInfo& debugInfo)
+VariableExpression::VariableExpression(String variable, std::vector<Expression::Ptr> imports, const DebugInfo& debugInfo)
        : DebuggableExpression(debugInfo), m_Variable(std::move(variable)), m_Imports(std::move(imports))
 {
-       m_Imports.push_back(MakeIndexer(ScopeGlobal, "System"));
-       m_Imports.push_back(std::unique_ptr<Expression>(new IndexerExpression(MakeIndexer(ScopeGlobal, "System"), MakeLiteral("Configuration"))));
-       m_Imports.push_back(MakeIndexer(ScopeGlobal, "Types"));
-       m_Imports.push_back(MakeIndexer(ScopeGlobal, "Icinga"));
+       m_Imports.push_back(MakeIndexer(ScopeGlobal, "System").release());
+       m_Imports.push_back(new IndexerExpression(MakeIndexer(ScopeGlobal, "System"), MakeLiteral("Configuration")));
+       m_Imports.push_back(MakeIndexer(ScopeGlobal, "Types").release());
+       m_Imports.push_back(MakeIndexer(ScopeGlobal, "Icinga").release());
 }
 
 ExpressionResult VariableExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
index 6c36f06e7419fd15eed409371a0d048a62fbb91f..21ab7a2e61ad0a40d0af1bb9e05e0c19d21af8dc 100644 (file)
@@ -10,6 +10,7 @@
 #include "base/function.hpp"
 #include "base/exception.hpp"
 #include "base/scriptframe.hpp"
+#include "base/shared-object.hpp"
 #include "base/convert.hpp"
 #include <map>
 
@@ -178,9 +179,11 @@ private:
 /**
  * @ingroup config
  */
-class Expression
+class Expression : public SharedObject
 {
 public:
+       DECLARE_PTR_TYPEDEFS(Expression);
+
        Expression() = default;
        Expression(const Expression&) = delete;
        virtual ~Expression();
@@ -203,7 +206,7 @@ std::unique_ptr<Expression> MakeIndexer(ScopeSpecifier scopeSpec, const String&
 class OwnedExpression final : public Expression
 {
 public:
-       OwnedExpression(std::shared_ptr<Expression> expression)
+       OwnedExpression(Expression::Ptr expression)
                : m_Expression(std::move(expression))
        { }
 
@@ -219,7 +222,7 @@ protected:
        }
 
 private:
-       std::shared_ptr<Expression> m_Expression;
+       Expression::Ptr m_Expression;
 };
 
 class LiteralExpression final : public Expression
@@ -288,7 +291,7 @@ protected:
 class VariableExpression final : public DebuggableExpression
 {
 public:
-       VariableExpression(String variable, std::vector<std::shared_ptr<Expression> > imports, const DebugInfo& debugInfo = DebugInfo());
+       VariableExpression(String variable, std::vector<Expression::Ptr> imports, const DebugInfo& debugInfo = DebugInfo());
 
        String GetVariable() const
        {
@@ -301,7 +304,7 @@ protected:
 
 private:
        String m_Variable;
-       std::vector<std::shared_ptr<Expression> > m_Imports;
+       std::vector<Expression::Ptr> m_Imports;
 
        friend void BindToScope(std::unique_ptr<Expression>& expr, ScopeSpecifier scopeSpec);
 };
@@ -795,7 +798,7 @@ class FunctionExpression final : public DebuggableExpression
 public:
        FunctionExpression(String name, std::vector<String> args,
                std::map<String, std::unique_ptr<Expression> >&& closedVars, std::unique_ptr<Expression> expression, const DebugInfo& debugInfo = DebugInfo())
-               : DebuggableExpression(debugInfo), m_Name(std::move(name)), m_Args(std::move(args)), m_ClosedVars(std::move(closedVars)), m_Expression(std::move(expression))
+               : DebuggableExpression(debugInfo), m_Name(std::move(name)), m_Args(std::move(args)), m_ClosedVars(std::move(closedVars)), m_Expression(expression.release())
        { }
 
 protected:
@@ -805,7 +808,7 @@ private:
        String m_Name;
        std::vector<String> m_Args;
        std::map<String, std::unique_ptr<Expression> > m_ClosedVars;
-       std::shared_ptr<Expression> m_Expression;
+       Expression::Ptr m_Expression;
 };
 
 class ApplyExpression final : public DebuggableExpression
@@ -816,9 +819,9 @@ public:
                std::unique_ptr<Expression> fterm, std::map<String, std::unique_ptr<Expression> >&& closedVars, bool ignoreOnError,
                std::unique_ptr<Expression> expression, const DebugInfo& debugInfo = DebugInfo())
                : DebuggableExpression(debugInfo), m_Type(std::move(type)), m_Target(std::move(target)),
-                       m_Name(std::move(name)), m_Filter(std::move(filter)), m_Package(std::move(package)), m_FKVar(std::move(fkvar)), m_FVVar(std::move(fvvar)),
-                       m_FTerm(std::move(fterm)), m_IgnoreOnError(ignoreOnError), m_ClosedVars(std::move(closedVars)),
-                       m_Expression(std::move(expression))
+                       m_Name(std::move(name)), m_Filter(filter.release()), m_Package(std::move(package)), m_FKVar(std::move(fkvar)), m_FVVar(std::move(fvvar)),
+                       m_FTerm(fterm.release()), m_IgnoreOnError(ignoreOnError), m_ClosedVars(std::move(closedVars)),
+                       m_Expression(expression.release())
        { }
 
 protected:
@@ -828,28 +831,28 @@ private:
        String m_Type;
        String m_Target;
        std::unique_ptr<Expression> m_Name;
-       std::shared_ptr<Expression> m_Filter;
+       Expression::Ptr m_Filter;
        String m_Package;
        String m_FKVar;
        String m_FVVar;
-       std::shared_ptr<Expression> m_FTerm;
+       Expression::Ptr m_FTerm;
        bool m_IgnoreOnError;
        std::map<String, std::unique_ptr<Expression> > m_ClosedVars;
-       std::shared_ptr<Expression> m_Expression;
+       Expression::Ptr m_Expression;
 };
 
 class NamespaceExpression final : public DebuggableExpression
 {
 public:
        NamespaceExpression(std::unique_ptr<Expression> expression, const DebugInfo& debugInfo = DebugInfo())
-               : DebuggableExpression(debugInfo), m_Expression(std::move(expression))
+               : DebuggableExpression(debugInfo), m_Expression(expression.release())
        { }
 
 protected:
        ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
 
 private:
-       std::shared_ptr<Expression> m_Expression;
+       Expression::Ptr m_Expression;
 };
 
 class ObjectExpression final : public DebuggableExpression
@@ -859,8 +862,8 @@ public:
                String zone, String package, std::map<String, std::unique_ptr<Expression> >&& closedVars,
                bool defaultTmpl, bool ignoreOnError, std::unique_ptr<Expression> expression, const DebugInfo& debugInfo = DebugInfo())
                : DebuggableExpression(debugInfo), m_Abstract(abstract), m_Type(std::move(type)),
-               m_Name(std::move(name)), m_Filter(std::move(filter)), m_Zone(std::move(zone)), m_Package(std::move(package)), m_DefaultTmpl(defaultTmpl),
-               m_IgnoreOnError(ignoreOnError), m_ClosedVars(std::move(closedVars)), m_Expression(std::move(expression))
+               m_Name(std::move(name)), m_Filter(filter.release()), m_Zone(std::move(zone)), m_Package(std::move(package)), m_DefaultTmpl(defaultTmpl),
+               m_IgnoreOnError(ignoreOnError), m_ClosedVars(std::move(closedVars)), m_Expression(expression.release())
        { }
 
 protected:
@@ -870,13 +873,13 @@ private:
        bool m_Abstract;
        std::unique_ptr<Expression> m_Type;
        std::unique_ptr<Expression> m_Name;
-       std::shared_ptr<Expression> m_Filter;
+       Expression::Ptr m_Filter;
        String m_Zone;
        String m_Package;
        bool m_DefaultTmpl;
        bool m_IgnoreOnError;
        std::map<String, std::unique_ptr<Expression> > m_ClosedVars;
-       std::shared_ptr<Expression> m_Expression;
+       Expression::Ptr m_Expression;
 };
 
 class ForExpression final : public DebuggableExpression
index 8bd456d405bdf8695ba384ba395e294d4af3a5a7..ea30983593366d2a17a8fabcd04242b4f650d893 100644 (file)
@@ -26,7 +26,7 @@ namespace icinga
 class VMOps
 {
 public:
-       static inline bool FindVarImportRef(ScriptFrame& frame, const std::vector<std::shared_ptr<Expression> >& imports, const String& name, Value *result, const DebugInfo& debugInfo = DebugInfo())
+       static inline bool FindVarImportRef(ScriptFrame& frame, const std::vector<Expression::Ptr>& imports, const String& name, Value *result, const DebugInfo& debugInfo = DebugInfo())
        {
                for (const auto& import : imports) {
                        ExpressionResult res = import->Evaluate(frame);
@@ -40,7 +40,7 @@ public:
                return false;
        }
 
-       static inline bool FindVarImport(ScriptFrame& frame, const std::vector<std::shared_ptr<Expression> >& imports, const String& name, Value *result, const DebugInfo& debugInfo = DebugInfo())
+       static inline bool FindVarImport(ScriptFrame& frame, const std::vector<Expression::Ptr>& imports, const String& name, Value *result, const DebugInfo& debugInfo = DebugInfo())
        {
                Value parent;
 
@@ -91,7 +91,7 @@ public:
        }
 
        static inline Value NewFunction(ScriptFrame& frame, const String& name, const std::vector<String>& argNames,
-               const std::map<String, std::unique_ptr<Expression> >& closedVars, const std::shared_ptr<Expression>& expression)
+               const std::map<String, std::unique_ptr<Expression> >& closedVars, const Expression::Ptr& expression)
        {
                auto evaluatedClosedVars = EvaluateClosedVars(frame, closedVars);
 
@@ -115,9 +115,9 @@ public:
                return new Function(name, wrapper, argNames);
        }
 
-       static inline Value NewApply(ScriptFrame& frame, const String& type, const String& target, const String& name, const std::shared_ptr<Expression>& filter,
-               const String& package, const String& fkvar, const String& fvvar, const std::shared_ptr<Expression>& fterm, const std::map<String, std::unique_ptr<Expression> >& closedVars,
-               bool ignoreOnError, const std::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
+       static inline Value NewApply(ScriptFrame& frame, const String& type, const String& target, const String& name, const Expression::Ptr& filter,
+               const String& package, const String& fkvar, const String& fvvar, const Expression::Ptr& fterm, const std::map<String, std::unique_ptr<Expression> >& closedVars,
+               bool ignoreOnError, const Expression::Ptr& expression, const DebugInfo& debugInfo = DebugInfo())
        {
                ApplyRule::AddRule(type, target, name, expression, filter, package, fkvar,
                        fvvar, fterm, ignoreOnError, debugInfo, EvaluateClosedVars(frame, closedVars));
@@ -125,8 +125,8 @@ public:
                return Empty;
        }
 
-       static inline Value NewObject(ScriptFrame& frame, bool abstract, const Type::Ptr& type, const String& name, const std::shared_ptr<Expression>& filter,
-               const String& zone, const String& package, bool defaultTmpl, bool ignoreOnError, const std::map<String, std::unique_ptr<Expression> >& closedVars, const std::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
+       static inline Value NewObject(ScriptFrame& frame, bool abstract, const Type::Ptr& type, const String& name, const Expression::Ptr& filter,
+               const String& zone, const String& package, bool defaultTmpl, bool ignoreOnError, const std::map<String, std::unique_ptr<Expression> >& closedVars, const Expression::Ptr& expression, const DebugInfo& debugInfo = DebugInfo())
        {
                ConfigItemBuilder item{debugInfo};
 
index 5b6219c1062354a46305decb5abe6063e8ea1087..1125a45434f6eade9389d033b48f838f4d847121 100644 (file)
@@ -126,7 +126,7 @@ EventQueueRegistry *EventQueueRegistry::GetInstance()
 }
 
 std::mutex EventsInbox::m_FiltersMutex;
-std::map<String, EventsInbox::Filter> EventsInbox::m_Filters ({{"", EventsInbox::Filter{1, nullptr}}});
+std::map<String, EventsInbox::Filter> EventsInbox::m_Filters ({{"", EventsInbox::Filter{1, Expression::Ptr()}}});
 
 EventsRouter EventsRouter::m_Instance;
 
@@ -146,7 +146,7 @@ EventsInbox::EventsInbox(String filter, const String& filterSource)
                m_Filter = m_Filters.find(filter);
 
                if (m_Filter == m_Filters.end()) {
-                       m_Filter = m_Filters.emplace(std::move(filter), Filter{1, std::shared_ptr<Expression>(expr.release())}).first;
+                       m_Filter = m_Filters.emplace(std::move(filter), Filter{1, Expression::Ptr(expr.release())}).first;
                } else {
                        ++m_Filter->second.Refs;
                }
@@ -164,7 +164,7 @@ EventsInbox::~EventsInbox()
        }
 }
 
-const std::shared_ptr<Expression>& EventsInbox::GetFilter()
+const Expression::Ptr& EventsInbox::GetFilter()
 {
        return m_Filter->second.Expr;
 }
@@ -230,7 +230,7 @@ const EventsInbox::Ptr& EventsSubscriber::GetInbox()
        return m_Inbox;
 }
 
-EventsFilter::EventsFilter(std::map<std::shared_ptr<Expression>, std::set<EventsInbox::Ptr>> inboxes)
+EventsFilter::EventsFilter(std::map<Expression::Ptr, std::set<EventsInbox::Ptr>> inboxes)
        : m_Inboxes(std::move(inboxes))
 {
 }
index ec389929a496f491d5b5b75abacc94b0d602d55a..c8317cb74539a7e8749a7f90f2ad40d564c8801e 100644 (file)
@@ -94,7 +94,7 @@ public:
        EventsInbox& operator=(EventsInbox&&) = delete;
        ~EventsInbox();
 
-       const std::shared_ptr<Expression>& GetFilter();
+       const Expression::Ptr& GetFilter();
 
        void Push(Dictionary::Ptr event);
        Dictionary::Ptr Shift(boost::asio::yield_context yc, double timeout = 5);
@@ -103,7 +103,7 @@ private:
        struct Filter
        {
                std::size_t Refs;
-               std::shared_ptr<Expression> Expr;
+               Expression::Ptr Expr;
        };
 
        static std::mutex m_FiltersMutex;
@@ -135,14 +135,14 @@ private:
 class EventsFilter
 {
 public:
-       EventsFilter(std::map<std::shared_ptr<Expression>, std::set<EventsInbox::Ptr>> inboxes);
+       EventsFilter(std::map<Expression::Ptr, std::set<EventsInbox::Ptr>> inboxes);
 
        operator bool();
 
        void Push(Dictionary::Ptr event);
 
 private:
-       std::map<std::shared_ptr<Expression>, std::set<EventsInbox::Ptr>> m_Inboxes;
+       std::map<Expression::Ptr, std::set<EventsInbox::Ptr>> m_Inboxes;
 };
 
 class EventsRouter
@@ -165,7 +165,7 @@ private:
        ~EventsRouter() = default;
 
        std::mutex m_Mutex;
-       std::map<EventType, std::map<std::shared_ptr<Expression>, std::set<EventsInbox::Ptr>>> m_Subscribers;
+       std::map<EventType, std::map<Expression::Ptr, std::set<EventsInbox::Ptr>>> m_Subscribers;
 };
 
 }