Belle II Software  release-06-00-14
Path.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #pragma once
10 
11 #include <framework/core/PathElement.h>
12 #include <memory>
13 #include <list>
14 
15 namespace boost {
16  namespace python {
17  class list;
18  }
19 }
20 
21 namespace Belle2 {
27  class Path;
28  class Module;
29 
30  //------------------------------------------------------
31  // Define convenient typdefs
32  //------------------------------------------------------
33 
35  typedef std::shared_ptr<Path> PathPtr;
36 
38  class Path : public PathElement {
39 
40  public:
41 
45  Path();
46 
50  ~Path();
51 
62  void addModule(const std::shared_ptr<Module>& module);
63 
65  bool isEmpty() const;
66 
70  std::list<std::shared_ptr<Module> > getModules() const override;
71 
82  std::list<std::shared_ptr<Module> > buildModulePathList(bool unique = true) const;
83 
87  void putModules(const std::list<std::shared_ptr<Module> >& mlist);
88 
94  bool contains(const std::string& moduleType) const;
95 
101  std::shared_ptr<PathElement> clone() const override;
102 
103 
104  //--------------------------------------------------
105  // Python API
106  //--------------------------------------------------
107 
109  void addPath(const PathPtr& path);
110 
112  void forEach(const std::string& loopObjectName, const std::string& arrayName, PathPtr path);
113 
115  void doWhile(PathPtr path, const std::string& condition, unsigned int maxIterations);
116 
118  void addIndependentPath(const PathPtr& independent_path, std::string ds_ID, const boost::python::list& merge_back);
119 
124  std::string getPathString() const override;
125 
127  static void exposePythonAPI();
128 
129 
130  private:
131 
132  std::list<std::shared_ptr<PathElement> > m_elements;
134  friend class PathIterator;
135  };
136 
138 } // end namespace Belle2
Base for classes that can be elements of a Path.
Definition: PathElement.h:27
Iterator over a Path (returning Module pointers).
Definition: PathIterator.h:26
Implements a path consisting of Module and/or Path objects.
Definition: Path.h:38
void forEach(const std::string &loopObjectName, const std::string &arrayName, PathPtr path)
See 'pydoc3 basf2.Path'.
Definition: Path.cc:92
std::list< std::shared_ptr< PathElement > > m_elements
The list of path elements (Modules and sub-Paths)
Definition: Path.h:132
void doWhile(PathPtr path, const std::string &condition, unsigned int maxIterations)
See 'pydoc3 basf2.Path'.
Definition: Path.cc:99
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:64
static void exposePythonAPI()
Exposes methods of the Path class to Python.
Definition: Path.cc:192
void putModules(const std::list< std::shared_ptr< Module > > &mlist)
Replaces all Modules and sub-Paths with the specified Module list.
Definition: Path.cc:86
Path()
Constructor.
void addPath(const PathPtr &path)
See 'pydoc3 basf2.Path'.
Definition: Path.cc:34
void addModule(const std::shared_ptr< Module > &module)
Adds a module to the path.
Definition: Path.cc:29
bool isEmpty() const
Returns true if this Path doesn't contain any elements.
Definition: Path.cc:42
~Path()
Destructor.
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:140
void addIndependentPath(const PathPtr &independent_path, std::string ds_ID, const boost::python::list &merge_back)
See 'pydoc3 basf2.Path'.
Definition: Path.cc:106
bool contains(const std::string &moduleType) const
Does this Path contain a module of the given type?
Definition: Path.cc:132
std::list< std::shared_ptr< Module > > getModules() const override
Returns a list of the modules in this path.
Definition: Path.cc:47
std::string getPathString() const override
return a string of the form [module a -> module b -> [another path]]
Definition: Path.cc:160
std::shared_ptr< Path > PathPtr
Defines a pointer to a path object as a boost shared pointer.
Definition: Path.h:28
Abstract base class for different kinds of events.