EventAnalysis  1.3.0
Algorithm.h
Go to the documentation of this file.
1 /*
2  * Algorithm.h
3  *
4  * Created on: 23 Apr 2013
5  * Author: Nicola Mori
6  */
7 
10 #ifndef ALGORITHM_H_
11 #define ALGORITHM_H_
12 
14 #include "core/Configurable.h"
15 #include "core/Filter.h"
16 #include "core/Info.h"
17 #include "data/DataStoreUser.h"
18 #include "data/ObjectConsumer.h"
19 #include "data/ObjectProducer.h"
20 
21 namespace EA {
22 
29 class Algorithm : public Filter,
30  public Info,
31  public Configurable,
32  public DataStoreUser,
33  public ObjectProducer,
34  public ObjectConsumer {
35 public:
37  Algorithm(const std::string &name);
38 
44  virtual bool SetEventLoopProxy(observer_ptr<EventLoopProxy> loopProxy);
45 
53  virtual bool Initialize();
54 
61  virtual bool Process();
62 
69  virtual bool Finalize();
70 
71  enum class IterateRequest { YES, NO, WHATEVER, ERROR };
72 
92  virtual IterateRequest Iterate();
93 
99 
100 protected:
102  friend class Algorithm;
104  };
105 
106  Algorithm(const std::shared_ptr<Filter::Representation> &filterRepr,
107  const std::shared_ptr<Info::Representation> &infoRepr,
108  const std::shared_ptr<Configurable::Representation> &confRepr,
109  const std::shared_ptr<DataStoreUser::Representation> &dsuRepr,
110  const std::shared_ptr<ObjectProducer::Representation> &opRepr,
111  const std::shared_ptr<ObjectConsumer::Representation> &ocRepr,
112  const std::shared_ptr<Algorithm::Representation> &algoRepr)
113  : Filter{filterRepr}, Info{infoRepr}, Configurable{confRepr}, DataStoreUser{dsuRepr}, ObjectProducer{opRepr},
114  ObjectConsumer{ocRepr}, _repr{algoRepr} {}
115 
116  std::shared_ptr<Representation> &GetRepresentation() { return _repr; }
117 
118 private:
119  std::shared_ptr<Representation> _repr;
120 };
121 
122 } // namespace EA
123 
124 #include "plugin/FactoryMacros.h"
125 #define RegisterAlgorithm(className) RegisterClass(EA::Algorithm, className, const std::string &)
126 #define RegisterNSAlgorithm(namespace, className) \
127  RegisterClassAs(EA::Algorithm, className, #namespace "::" #className, const std::string &)
128 
129 #endif /* ALGORITHM_H_ */
virtual bool Process()
Processing method.
Definition: Algorithm.cpp:27
IterateRequest
Definition: Algorithm.h:71
Algorithm(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: Algorithm.h:106
observer_ptr< EventLoopProxy > loopProxy
Definition: Algorithm.h:103
virtual bool SetEventLoopProxy(observer_ptr< EventLoopProxy > loopProxy)
Injector for dependency on EventLoopProxy.
Definition: Algorithm.cpp:17
A smart pointer not owning the wrapped object.
Definition: ObserverPtr.h:28
Algorithm(const std::string &name)
Definition: Algorithm.cpp:15
Interface for retrieving informations about an object.
Definition: Info.h:18
IncludeFileExc.h IncludeFileExc class declaration.
Definition: Algorithm.h:21
Filter class.
Definition: Filter.h:32
std::shared_ptr< Representation > _repr
Definition: Algorithm.h:119
Definition: Algorithm.h:101
Interface for classes needing access to the data stores.
Definition: DataStoreUser.h:17
virtual bool Initialize()
Initialization method.
Definition: Algorithm.cpp:25
Interface for a class which produced data objects.
Definition: ObjectProducer.h:29
virtual IterateRequest Iterate()
Request for another iteration of the event loop.
Definition: Algorithm.cpp:31
virtual bool Finalize()
Finalization method.
Definition: Algorithm.cpp:29
Algorithm interface.
Definition: Algorithm.h:29
std::shared_ptr< Representation > & GetRepresentation()
Definition: Algorithm.h:116
Interface for a configurable class.
Definition: Configurable.h:25
observer_ptr< EventLoopProxy > GetEventLoopProxy()
Accessor for the event loop proxy.
Definition: Algorithm.h:98
Interface for a class which consumes data objects.
Definition: ObjectConsumer.h:27