JODA  0.13.1 (59b41972)
JSON On-Demand Analysis
IExportDestination.h
Go to the documentation of this file.
1 //
2 // Created by Nico on 20/03/2019.
3 //
4 
5 #ifndef JODA_IEXPORTDESTINATION_H
6 #define JODA_IEXPORTDESTINATION_H
7 
10 
15  public:
16  virtual ~IExportDestination() = default;
17 
23  virtual void consume(JsonContainerQueue::queue_t &queue) {
24  timer.start();
25  this->consumeContainer(queue);
26  timer.stop();
27  };
28 
34  std::pair<std::string, double> getTimer() {
35  return {getTimerName(), timer.durationSeconds()};
36  };
37 
43  virtual const std::string toString() = 0;
44 
49  virtual const std::string toQueryString() = 0;
50 
51  protected:
53  std::unique_ptr<JSONContainer> cont;
54  while (!queue.isFinished()) {
55  queue.retrieve(cont);
56  if (cont == nullptr) {
57  LOG(WARNING) << "Received nullptr as container.";
58  continue;
59  }
60  this->exportContainer(std::move(cont));
61  }
62  };
63  virtual void exportContainer(std::unique_ptr<JSONContainer> &&cont) = 0;
64  virtual const std::string getTimerName() = 0;
66 };
67 
68 #endif // JODA_IEXPORTDESTINATION_H
Definition: IExportDestination.h:14
virtual void consumeContainer(JsonContainerQueue::queue_t &queue)
Definition: IExportDestination.h:52
virtual void exportContainer(std::unique_ptr< JSONContainer > &&cont)=0
std::pair< std::string, double > getTimer()
Definition: IExportDestination.h:34
virtual ~IExportDestination()=default
virtual const std::string toString()=0
RecurringTimer timer
Definition: IExportDestination.h:65
virtual void consume(JsonContainerQueue::queue_t &queue)
Definition: IExportDestination.h:23
virtual const std::string toQueryString()=0
virtual const std::string getTimerName()=0
Definition: RecurringTimer.h:14
void stop()
Definition: RecurringTimer.cpp:16
void start()
Definition: RecurringTimer.cpp:11
double durationSeconds() const
Definition: RecurringTimer.cpp:36
Definition: Queue.h:19
void retrieve(payload_t &e)
Definition: Queue.h:114
bool isFinished()
Definition: Queue.h:42