EventAnalysis  1.0.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 
86  bool Initialize();
87 
100  bool Process();
101 
103  bool Finalize();
104 
120 
121  // STL-like container facilities
122  using iterator = Algorithms::iterator;
123  using const_iterator = Algorithms::const_iterator;
124  iterator begin() { return GetAlgorithms().begin(); }
125  iterator end() { return GetAlgorithms().end(); }
126  const_iterator begin() const { return GetAlgorithms().begin(); }
127  const_iterator end() const { return GetAlgorithms().end(); }
128  size_t size() { return GetAlgorithms().size(); }
129 
136 
143 
144 protected:
145  friend class AlgoSequenceDecorator; // For supporting AlgoSequenceDecorator
146 
154  virtual bool ProcessAlgo(size_t iAlgo);
155 
157  friend class AlgoSequence;
159  };
160 
161  AlgoSequence(const std::shared_ptr<Filter::Representation> &filterRepr,
162  const std::shared_ptr<Info::Representation> &infoRepr,
163  const std::shared_ptr<Configurable::Representation> &confRepr,
164  const std::shared_ptr<DataStoreUser::Representation> &dsuRepr,
165  const std::shared_ptr<ObjectProducer::Representation> &opRepr,
166  const std::shared_ptr<ObjectConsumer::Representation> &ocRepr,
167  const std::shared_ptr<Algorithm::Representation> &algoRepr)
168  : Algorithm{filterRepr, infoRepr, confRepr, dsuRepr, opRepr, ocRepr, algoRepr},
169  _repr{std::make_shared<Representation>()} {}
170 
171  std::shared_ptr<Representation> &GetRepresentation() { return _repr; }
172 
173 private:
174  std::shared_ptr<Representation> _repr;
175 
176 private:
177 };
178 
179 } // namespace EA
180 
181 #endif /* ALGOSEQUENCE_H_ */
std::shared_ptr< Representation > _repr
Definition: AlgoSequence.h:174
bool SetDataStoreManager(observer_ptr< DataStoreManager > dsManager)
Set the data store manager for the sequence and all the contained algorithms.
Definition: AlgoSequence.cpp:177
std::shared_ptr< Representation > & GetRepresentation()
Definition: AlgoSequence.h:171
Algorithms algorithms
Definition: AlgoSequence.h:158
iterator end()
Definition: AlgoSequence.h:125
IterateRequest
Definition: Algorithm.h:70
IterateRequest Iterate()
Forward the iteration request to the contained algorithms.
Definition: AlgoSequence.cpp:147
Algorithms::const_iterator const_iterator
Definition: AlgoSequence.h:123
A smart pointer not owning the wrapped object.
Definition: ObserverPtr.h:28
size_t size()
Definition: AlgoSequence.h:128
Definition: AlgoSequence.h:156
bool Process()
Processes all the algorithms.
Definition: AlgoSequence.cpp:123
const_iterator end() const
Definition: AlgoSequence.h:127
iterator begin()
Definition: AlgoSequence.h:124
Algorithm made by multiple basic algorithms.
Definition: AlgoSequence.h:37
bool Finalize()
Finalizes all algorithms and branches.
Definition: AlgoSequence.cpp:139
IncludeFileExc.h IncludeFileExc class declaration.
Definition: Algorithm.h:21
observer_ptr< Algorithm > GetAlgorithm(const std::string name)
Get an algorithm.
Definition: AlgoSequence.cpp:62
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:83
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:191
virtual bool ProcessAlgo(size_t iAlgo)
Process the given algorithm.
Definition: AlgoSequence.cpp:106
Algorithms::iterator iterator
Definition: AlgoSequence.h:122
const_iterator begin() const
Definition: AlgoSequence.h:126
const Algorithms & GetAlgorithms() const
Get the algorithms.
Definition: AlgoSequence.cpp:79
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:161
Algorithm interface.
Definition: Algorithm.h:29
AlgoSequence(const std::string &name)
Constructor.
Definition: AlgoSequence.cpp:16