EventAnalysis  1.3.0
AlgoSequence.h
Go to the documentation of this file.
1 /*
2  * AlgoSequence.h
3  *
4  * Created on: 23 Apr 2013
5  * Author: Nicola Mori
6  */
7 
10 #ifndef ALGOSEQUENCE_H_
11 #define ALGOSEQUENCE_H_
12 
13 #include "algorithm/Algorithm.h"
14 
15 #include <vector>
16 
17 namespace EA {
18 
37 class AlgoSequence : public Algorithm {
38 
39 public:
41  using Algorithms = std::vector<std::unique_ptr<Algorithm>>;
42 
47  AlgoSequence(const std::string &name);
48 
58  bool AddAlgorithm(std::unique_ptr<Algorithm> &&algo);
59 
67  observer_ptr<Algorithm> GetAlgorithm(const std::string name);
68 
75  const Algorithms &GetAlgorithms() const;
76 
84 
90  bool Initialize();
91 
104  bool Process();
105 
107  bool Finalize();
108 
124 
125  // STL-like container facilities
126  using iterator = Algorithms::iterator;
127  using const_iterator = Algorithms::const_iterator;
128  iterator begin() { return GetAlgorithms().begin(); }
129  iterator end() { return GetAlgorithms().end(); }
130  const_iterator begin() const { return GetAlgorithms().begin(); }
131  const_iterator end() const { return GetAlgorithms().end(); }
132  size_t size() { return GetAlgorithms().size(); }
133 
140 
147 
148 protected:
149  friend class AlgoSequenceDecorator; // For supporting AlgoSequenceDecorator
150 
158  virtual bool ProcessAlgo(size_t iAlgo);
159 
161  friend class AlgoSequence;
163  };
164 
165  AlgoSequence(const std::shared_ptr<Filter::Representation> &filterRepr,
166  const std::shared_ptr<Info::Representation> &infoRepr,
167  const std::shared_ptr<Configurable::Representation> &confRepr,
168  const std::shared_ptr<DataStoreUser::Representation> &dsuRepr,
169  const std::shared_ptr<ObjectProducer::Representation> &opRepr,
170  const std::shared_ptr<ObjectConsumer::Representation> &ocRepr,
171  const std::shared_ptr<Algorithm::Representation> &algoRepr)
172  : Algorithm{filterRepr, infoRepr, confRepr, dsuRepr, opRepr, ocRepr, algoRepr},
173  _repr{std::make_shared<Representation>()} {}
174 
175  std::shared_ptr<Representation> &GetRepresentation() { return _repr; }
176 
177 private:
178  std::shared_ptr<Representation> _repr;
179 
180 private:
181 };
182 
183 } // namespace EA
184 
185 #endif /* ALGOSEQUENCE_H_ */
std::shared_ptr< Representation > _repr
Definition: AlgoSequence.h:178
bool SetDataStoreManager(observer_ptr< DataStoreManager > dsManager)
Set the data store manager for the sequence and all the contained algorithms.
Definition: AlgoSequence.cpp:172
std::shared_ptr< Representation > & GetRepresentation()
Definition: AlgoSequence.h:175
Algorithms algorithms
Definition: AlgoSequence.h:162
iterator end()
Definition: AlgoSequence.h:129
IterateRequest
Definition: Algorithm.h:71
IterateRequest Iterate()
Forward the iteration request to the contained algorithms.
Definition: AlgoSequence.cpp:142
Algorithms::const_iterator const_iterator
Definition: AlgoSequence.h:127
A smart pointer not owning the wrapped object.
Definition: ObserverPtr.h:28
size_t size()
Definition: AlgoSequence.h:132
Definition: AlgoSequence.h:160
bool Process()
Processes all the algorithms.
Definition: AlgoSequence.cpp:117
const_iterator end() const
Definition: AlgoSequence.h:131
iterator begin()
Definition: AlgoSequence.h:128
Algorithm made by multiple basic algorithms.
Definition: AlgoSequence.h:37
bool Finalize()
Finalizes all algorithms and branches.
Definition: AlgoSequence.cpp:133
IncludeFileExc.h IncludeFileExc class declaration.
Definition: Algorithm.h:21
observer_ptr< Algorithm > GetAlgorithm(const std::string name)
Get an algorithm.
Definition: AlgoSequence.cpp:42
Base class for sequence decorators.
Definition: AlgoSequenceDecorator.h:56
std::vector< std::unique_ptr< Algorithm > > Algorithms
Type of underlying algorithm container.
Definition: AlgoSequence.h:41
bool Initialize()
Initializes all algorithms.
Definition: AlgoSequence.cpp:63
bool AddAlgorithm(std::unique_ptr< Algorithm > &&algo)
Adds a new algorithm to the sequence.
Definition: AlgoSequence.cpp:19
bool SetEventLoopProxy(observer_ptr< EventLoopProxy > loopProxy)
Set the event loop proxy for the sequence and all the contained algorithms.
Definition: AlgoSequence.cpp:186
virtual bool ProcessAlgo(size_t iAlgo)
Process the given algorithm.
Definition: AlgoSequence.cpp:99
Algorithms::iterator iterator
Definition: AlgoSequence.h:126
const_iterator begin() const
Definition: AlgoSequence.h:130
const Algorithms & GetAlgorithms() const
Get the algorithms.
Definition: AlgoSequence.cpp:59
AlgoSequence(const std::shared_ptr< Filter::Representation > &filterRepr, const std::shared_ptr< Info::Representation > &infoRepr, const std::shared_ptr< Configurable::Representation > &confRepr, const std::shared_ptr< DataStoreUser::Representation > &dsuRepr, const std::shared_ptr< ObjectProducer::Representation > &opRepr, const std::shared_ptr< ObjectConsumer::Representation > &ocRepr, const std::shared_ptr< Algorithm::Representation > &algoRepr)
Definition: AlgoSequence.h:165
Algorithm interface.
Definition: Algorithm.h:29
AlgoSequence(const std::string &name)
Constructor.
Definition: AlgoSequence.cpp:16