CFEL - ASG Software Suite  2.5.0
CASS
input_base.cpp
Go to the documentation of this file.
1 // Copyright (C) 2011,2013 Lutz Foucar
2 
3 /**
4  * @file input_base.cpp contains the base class for all input modules
5  *
6  * @author Lutz Foucar
7  */
8 
9 #include "input_base.h"
10 
11 #include "ratemeter.h"
12 
13 using namespace cass;
14 using namespace std;
15 
16 // ============define static members==============
19 
21 {
22  QMutexLocker lock(&_mutex);
23  if(!_instance)
24  throw logic_error("InputBase::instance(): is not created yet");
25  return _instance;
26 }
27 
28 InputBase::shared_pointer::element_type& InputBase::reference()
29 {
30  QMutexLocker lock(&_mutex);
31  if(!_instance)
32  throw logic_error("InputBase::reference():is not created yet");
33  return *_instance;
34 }
35 //===================================================
36 
37 void InputBase::newEventAdded(const size_t eventsize)
38 {
39  _ratemeter.count();
40  _loadmeter.count(eventsize);
41 }
42 
44 {
45  return _ringbuffer;
46 }
47 
49 {
50  InputBase::rbItem_t rbItem(_ringbuffer.end());
51  while ((rbItem = _ringbuffer.nextToFill(timeout)) == _ringbuffer.end())
52  if (_control == _quit)
53  break;
54  return rbItem;
55 }
56 
58 {
59  return 0.;
60 }
61 
63 {
64  return 0;
65 }
66 
68 {
69  return 0;
70 }
RingBuffer< CASSEvent >::iter_type rbItem_t
define an item in the ringbuffer
Definition: input_base.h:109
file contains declaration of class calculating a rate
virtual uint64_t eventcounter()
retrieve the number of events that have been input so far
Definition: input_base.cpp:62
STL namespace.
virtual double progress()
retrieve the fraction of how much of the input has been processed
Definition: input_base.cpp:57
virtual uint64_t skippedeventcounter()
retrieve the number of skipped events that have been input so far
Definition: input_base.cpp:67
RingBuffer< CASSEvent > & ringbuffer()
retrieve a reference to the the ringbuffer
Definition: input_base.cpp:43
A Ringbuffer, handles communication between Input and Worker Threads.
Definition: ringbuffer.hpp:52
static shared_pointer _instance
singelton instance
Definition: input_base.h:149
static QMutex _mutex
a mutex to lock operations
Definition: input_base.h:153
static shared_pointer instance()
get the signelton instance
Definition: input_base.cpp:20
contains the base class for all input modules
std::tr1::shared_ptr< InputBase > shared_pointer
shared pointer of this type
Definition: input_base.h:35
rbItem_t getNextFillable(unsigned timeout=500)
retrieve an iterator to the next fillable event
Definition: input_base.cpp:48
static shared_pointer::element_type & reference()
get reference to the singelton instance
Definition: input_base.cpp:28
void newEventAdded(const size_t eventsize)
increment the numer of events received in the ratemeter
Definition: input_base.cpp:37