Belle II Software  release-05-02-19
Path.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Andreas Moll *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <framework/core/PathElement.h>
14 #include <memory>
15 #include <list>
16 
17 namespace boost {
18  namespace python {
19  class list;
20  }
21 }
22 
23 namespace Belle2 {
29  class Path;
30  class Module;
31 
32  //------------------------------------------------------
33  // Define convenient typdefs
34  //------------------------------------------------------
35 
37  typedef std::shared_ptr<Path> PathPtr;
38 
40  class Path : public PathElement {
41 
42  public:
43 
47  Path();
48 
52  ~Path();
53 
64  void addModule(const std::shared_ptr<Module>& module);
65 
67  bool isEmpty() const;
68 
72  std::list<std::shared_ptr<Module> > getModules() const override;
73 
84  std::list<std::shared_ptr<Module> > buildModulePathList(bool unique = true) const;
85 
89  void putModules(const std::list<std::shared_ptr<Module> >& mlist);
90 
96  bool contains(const std::string& moduleType) const;
97 
103  std::shared_ptr<PathElement> clone() const override;
104 
105 
106  //--------------------------------------------------
107  // Python API
108  //--------------------------------------------------
109 
111  void addPath(const PathPtr& path);
112 
114  void forEach(const std::string& loopObjectName, const std::string& arrayName, PathPtr path);
115 
117  void doWhile(PathPtr path, const std::string& condition, unsigned int maxIterations);
118 
120  void addIndependentPath(const PathPtr& independent_path, std::string ds_ID, const boost::python::list& merge_back);
121 
126  std::string getPathString() const override;
127 
129  static void exposePythonAPI();
130 
131 
132  private:
133 
134  std::list<std::shared_ptr<PathElement> > m_elements;
136  friend class PathIterator;
137  };
138 
140 } // end namespace Belle2
Belle2::Path::isEmpty
bool isEmpty() const
Returns true if this Path doesn't contain any elements.
Definition: Path.cc:44
Belle2::Path::exposePythonAPI
static void exposePythonAPI()
Exposes methods of the Path class to Python.
Definition: Path.cc:194
Belle2::Path::Path
Path()
Constructor.
Belle2::PathElement
Base for classes that can be elements of a Path.
Definition: PathElement.h:37
Belle2::Path::contains
bool contains(const std::string &moduleType) const
Does this Path contain a module of the given type?
Definition: Path.cc:134
Belle2::Path::addModule
void addModule(const std::shared_ptr< Module > &module)
Adds a module to the path.
Definition: Path.cc:31
Belle2::Path::addIndependentPath
void addIndependentPath(const PathPtr &independent_path, std::string ds_ID, const boost::python::list &merge_back)
See 'pydoc3 basf2.Path'.
Definition: Path.cc:108
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::Path::forEach
void forEach(const std::string &loopObjectName, const std::string &arrayName, PathPtr path)
See 'pydoc3 basf2.Path'.
Definition: Path.cc:94
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::Path::doWhile
void doWhile(PathPtr path, const std::string &condition, unsigned int maxIterations)
See 'pydoc3 basf2.Path'.
Definition: Path.cc:101
Belle2::PathPtr
std::shared_ptr< Path > PathPtr
Defines a pointer to a path object as a boost shared pointer.
Definition: Path.h:30
Belle2::Path::buildModulePathList
std::list< std::shared_ptr< Module > > buildModulePathList(bool unique=true) const
Builds a list of all modules which could be executed during the data processing.
Definition: Path.cc:66
Belle2::Path::m_elements
std::list< std::shared_ptr< PathElement > > m_elements
The list of path elements (Modules and sub-Paths)
Definition: Path.h:134
Belle2::Path::clone
std::shared_ptr< PathElement > clone() const override
Create an independent copy of this path, recreating all contained modules with the same parameters.
Definition: Path.cc:142
Belle2::Path::addPath
void addPath(const PathPtr &path)
See 'pydoc3 basf2.Path'.
Definition: Path.cc:36
Belle2::Path::getPathString
std::string getPathString() const override
return a string of the form [module a -> module b -> [another path]]
Definition: Path.cc:162
Belle2::Path
Implements a path consisting of Module and/or Path objects.
Definition: Path.h:40
Belle2::Path::putModules
void putModules(const std::list< std::shared_ptr< Module > > &mlist)
Replaces all Modules and sub-Paths with the specified Module list.
Definition: Path.cc:88
Belle2::PathIterator
Iterator over a Path (returning Module pointers).
Definition: PathIterator.h:36
Belle2::Path::~Path
~Path()
Destructor.
Belle2::Path::getModules
std::list< std::shared_ptr< Module > > getModules() const override
Returns a list of the modules in this path.
Definition: Path.cc:49