CFEL - ASG Software Suite  2.5.0
CASS
zmq_input.h
Go to the documentation of this file.
1 // Copyright (C) 2017 Lutz Foucar
2 
3 /**
4  * @file zmq_input.h contains input that uses ZMQ as interface
5  *
6  * @author Lutz Foucar
7  */
8 
9 #ifndef __ZMQINPUT_H__
10 #define __ZMQINPUT_H__
11 
12 #include <string>
13 
14 #include "cass.h"
15 #include "input_base.h"
16 #include "cass_event.h"
17 #include "ringbuffer.hpp"
18 
19 
20 namespace cass
21 {
22 /** ZMQ Input for receiving data
23  *
24  * This class is a thread that connects to a ZMQ Server and retrieves the data
25  * from it.
26  *
27  * @cassttng ZMQInput/{Server}\n
28  * The name or ip address of the machine that the server is running on.
29  * Default is "localhost"
30  *
31  * @author Lutz Foucar
32  */
33 class ZMQInput : public InputBase
34 {
35 public:
36  /** create an instance of this
37  *
38  * this initializes the _instance member of the base class. Check here if
39  * it is already initialized, if so throw logic error.
40  *
41  * @param buffer the ringbuffer, that we take events out and fill it
42  * with the incomming information
43  * @param ratemeter reference to the ratemeter to measure the rate of the input
44  * @param loadmeter reference to the ratemeter to measure the load of the input
45  * @param quitwhendone flag to tell whether to quit the input when done
46  * @param parent the parent of this object
47  */
48  static void instance(RingBuffer<CASSEvent>& buffer,
49  Ratemeter &ratemeter, Ratemeter &loadmeter,
50  bool quitwhendone=false,
51  QObject *parent=0);
52 
53  /** starts the thread
54  *
55  * Starts the thread and the loop that waits for data. When an timout occured
56  * it will just restart the loop until the quit flag is set.
57  */
58  void runthis();
59 
60  /** do not load anything */
61  void load() {}
62 
63  /** retrieve the number of processed events
64  *
65  * @return number of processed events
66  */
67  uint64_t eventcounter() {return _counter;}
68 
69  /** retrieve the number of skipped processed events
70  *
71  * @return number of processed events
72  */
73  uint64_t skippedeventcounter() {return _scounter;}
74 
75 private:
76  /** constructor
77  *
78  * creates the thread. Connects to the tcp server and then retrieves the
79  * data streams. The data within the stream will be deserialized with the
80  * help of deserialization functions, where the user has to choose which
81  * one is appropriate via the .ini file parameters. The thread runs as long
82  * as noone calls the end() member of the base class.
83  * In case a timeout occurs when waiting for a new event, it will just continue
84  * and wait for the next timeout. In case that a timeout occurred when waiting
85  * for the data of an event it throws an runtime error.
86  *
87  * @param buffer the ringbuffer, that we take events out and fill it
88  * with the incomming information
89  * @param ratemeter reference to the ratemeter to measure the rate of the input
90  * @param loadmeter reference to the ratemeter to measure the load of the input
91  * @param quitwhendone flag to tell whether to quit the input when done
92  * @param parent the parent of this object
93  */
95  Ratemeter &ratemeter, Ratemeter &loadmeter, bool quitwhendone,
96  QObject *parent=0);
97 
98  /** flag to tell the thread to quit when its done with all files */
100 
101  /** the counter for all events */
102  uint64_t _counter;
103 
104  /** the counter for all events */
105  uint64_t _scounter;
106 };
107 
108 }//end namespace cass
109 
110 #endif
ZMQInput(RingBuffer< CASSEvent > &buffer, Ratemeter &ratemeter, Ratemeter &loadmeter, bool quitwhendone, QObject *parent=0)
constructor
Definition: zmq_input.cpp:38
class calculating a rate in Hz.
Definition: ratemeter.h:28
file contains declaration of the CASSEvent
void runthis()
starts the thread
Definition: zmq_input.cpp:267
Input base class.
Definition: input_base.h:31
ZMQ Input for receiving data.
Definition: zmq_input.h:33
uint64_t skippedeventcounter()
retrieve the number of skipped processed events
Definition: zmq_input.h:73
A Ringbuffer, handles communication between Input and Worker Threads.
Definition: ringbuffer.hpp:52
uint64_t _scounter
the counter for all events
Definition: zmq_input.h:105
file contains the ringbuffer class
file contains global definitions for project cass
void load()
do not load anything
Definition: zmq_input.h:61
static shared_pointer instance()
get the signelton instance
Definition: input_base.cpp:20
uint64_t _counter
the counter for all events
Definition: zmq_input.h:102
contains the base class for all input modules
uint64_t eventcounter()
retrieve the number of processed events
Definition: zmq_input.h:67
bool _quitWhenDone
flag to tell the thread to quit when its done with all files
Definition: zmq_input.h:99