JODA  0.13.1 (59b41972)
JSON On-Demand Analysis
IReader.h
Go to the documentation of this file.
1 //
2 // Created by Nico on 27/11/2018.
3 //
4 
5 #ifndef JODA_IREADER_H
6 #define JODA_IREADER_H
7 
10 #include "../../../concurrency/include/joda/concurrency/IThreadUser.h"
11 
19 template <ReaderFlag R_FLAGS, ParserFlag P_FLAGS>
20 class IReader : public IThreadUser {
21  public:
22  /*
23  * Types
24  */
31  /*
32  * Constructor/Destructor
33  */
39  IReader(std::unique_ptr<RQueue>& rqueue, std::unique_ptr<PQueue>& pqueue);
47  IReader(std::unique_ptr<RQueue>& rqueue, std::unique_ptr<PQueue>& pqueue,
48  unsigned int maxThreads);
49  virtual ~IReader() = default;
50 
51  /*
52  * Read
53  */
58  virtual void read() { read(1); }
59 
65  virtual void read(double sample) = 0;
66 
71  virtual bool finishedReading() const = 0;
72 
73  protected:
74  std::unique_ptr<RQueue>& rqueue;
75  std::unique_ptr<PQueue>& pqueue;
76 
77  public:
78 };
79 
80 template <ReaderFlag R_FLAGS, ParserFlag P_FLAGS>
81 IReader<R_FLAGS, P_FLAGS>::IReader(std::unique_ptr<IReader::RQueue>& rqueue,
82  std::unique_ptr<IReader::PQueue>& pqueue)
83  : IReader(rqueue, pqueue, 1) {}
84 
85 template <ReaderFlag R_FLAGS, ParserFlag P_FLAGS>
86 IReader<R_FLAGS, P_FLAGS>::IReader(std::unique_ptr<IReader::RQueue>& rqueue,
87  std::unique_ptr<IReader::PQueue>& pqueue,
88  unsigned int maxThreads)
89  : IThreadUser(maxThreads), rqueue(rqueue), pqueue(pqueue) {
90  DLOG(INFO) << "Started IReader<" << JODA_FLAG_T(R_FLAGS) << ","
91  << JODA_FLAG_T(P_FLAGS) << "> with " << maxThreads << " threads";
92 }
93 
94 #endif // JODA_IREADER_H
#define JODA_FLAG_T
Definition: Queue.h:11
Definition: IReader.h:20
JODA_PARSER_QUEUE< P_FLAGS > PQueueFactory
Definition: IReader.h:30
JODA_PARSER_QUEUE< P_FLAGS >::queue_t PQueue
Definition: IReader.h:26
virtual void read(double sample)=0
virtual bool finishedReading() const =0
virtual void read()
Definition: IReader.h:58
std::unique_ptr< RQueue > & rqueue
Definition: IReader.h:74
JODA_PARSER_QUEUE< P_FLAGS >::payload_t PPayload
Definition: IReader.h:28
JODA_READER_QUEUE< R_FLAGS >::queue_t RQueue
Definition: IReader.h:25
JODA_READER_QUEUE< R_FLAGS >::payload_t RPayload
Definition: IReader.h:27
JODA_READER_QUEUE< R_FLAGS > RQueueFactory
Definition: IReader.h:29
std::unique_ptr< PQueue > & pqueue
Definition: IReader.h:75
IReader(std::unique_ptr< RQueue > &rqueue, std::unique_ptr< PQueue > &pqueue)
Definition: IReader.h:81
virtual ~IReader()=default
Definition: IThreadUser.h:13
size_t maxThreads
Definition: IThreadUser.h:30
Definition: ParserFlags.h:91
Definition: ReaderFlags.h:88