11#include <boost/python.hpp>
12#include <framework/utilities/CutNodes.h>
13#include <framework/utilities/NodeFactory.h>
25namespace py = boost::python;
26typedef const py::tuple& Nodetuple;
70 template <
class AVariableManager>
73 typedef typename AVariableManager::Object
Object;
75 typedef typename AVariableManager::Var
Var;
84 static std::unique_ptr<GeneralCut>
compile(
const std::string& cut)
89 py::object b2parser_namespace = py::import(
"b2parser");
90 py::tuple tuple = py::extract<py::tuple>(b2parser_namespace.attr(
"parse")(cut));
91 return std::unique_ptr<GeneralCut>(
new GeneralCut(tuple));
92 }
catch (py::error_already_set&) {
94 B2FATAL(
"Parsing error on cutstring:\n" + cut);
105 throw std::runtime_error(
"GeneralCut m_root is not initialized.");
121 std::stringstream stringstream;
122 stringstream <<
m_root->decompile();
123 return stringstream.str();
144 std::unique_ptr<const AbstractBooleanNode<AVariableManager>>
m_root;
This class implements a common way to implement cut/selection functionality for arbitrary objects.
std::unique_ptr< const AbstractBooleanNode< AVariableManager > > m_root
cut root node
AVariableManager::Var Var
Variable returned by the variable manager.
static std::unique_ptr< GeneralCut > compile(const std::string &cut)
Creates an instance of a cut and returns a unique_ptr to it, if you need a copy-able object instead y...
GeneralCut(const GeneralCut &)=delete
Delete Copy constructor.
GeneralCut(Nodetuple tuple)
Constructor of the cut.
void print() const
Print cut tree.
AVariableManager::Object Object
Object, that can be checked. This depends on the VariableManager, as the returned variables from the ...
std::string decompile() const
Do the compilation from a string in return.
GeneralCut & operator=(const GeneralCut &)=delete
Delete assign operator.
bool check(const Object *p) const
Check if the current cuts are passed by the given object.
Wrapper class for static node compile functions.
Abstract base class for different kinds of events.