CFEL - ASG Software Suite  2.5.0
CASS
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | Static Private Attributes | List of all members
cass::InputBase Class Referenceabstract

Input base class. More...

#include <input_base.h>

+ Inheritance diagram for cass::InputBase:
+ Collaboration diagram for cass::InputBase:

Public Types

typedef std::tr1::shared_ptr< InputBaseshared_pointer
 shared pointer of this type More...
 
typedef RingBuffer< CASSEvent >::iter_type rbItem_t
 define an item in the ringbuffer More...
 
- Public Types inherited from lmf::PausableThread
enum  status_t { running, paused, notstarted }
 enum describing the internal status of the thread More...
 
enum  control_t { _run, _quit, _pause }
 enum describing the control status of the thread More...
 
enum  exception_t {
  NO_EXCEPTION, INVALID_ARGUMENT_EXCEPTION, RUNTIME_ERROR_EXCEPTION, OUT_OF_RANGE_EXCEPTION,
  LOGIC_ERROR_EXCEPTION, STANDART_EXCEPTION, UNKNOWN_EXCEPTION
}
 enum describing which exception was thrown More...
 

Public Member Functions

virtual ~InputBase ()
 destructor More...
 
virtual void runthis ()=0
 function with the main loop More...
 
virtual void load ()=0
 load the settings of the input module from ini file More...
 
virtual double progress ()
 retrieve the fraction of how much of the input has been processed More...
 
virtual uint64_t eventcounter ()
 retrieve the number of events that have been input so far More...
 
virtual uint64_t skippedeventcounter ()
 retrieve the number of skipped events that have been input so far More...
 
void newEventAdded (const size_t eventsize)
 increment the numer of events received in the ratemeter More...
 
RingBuffer< CASSEvent > & ringbuffer ()
 retrieve a reference to the the ringbuffer More...
 
rbItem_t getNextFillable (unsigned timeout=500)
 retrieve an iterator to the next fillable event More...
 
- Public Member Functions inherited from lmf::PausableThread
 PausableThread (control_t control=_run, QObject *parent=0)
 constructor More...
 
virtual ~PausableThread ()
 destructor More...
 
void run ()
 run the thread More...
 
void pause (bool block=false)
 pause the thread More...
 
void waitUntilPaused ()
 waits until thread is paused More...
 
void resume ()
 resume the thread More...
 
status_t status () const
 return the current status of the thread More...
 
bool shouldQuit () const
 query whether this thread is told to quit More...
 
void rethrowException () const
 rethrow the thrown exception More...
 
exception_t exceptionThrown () const
 
- Public Member Functions inherited from QThread
 QThread (QObject *parent=0)
 
 currentThread ()
 
 HANDLE QThread::currentThreadId()
 
 exec ()
 
 exit (int returnCode=0)
 
 finished ()
 
 idealThreadCount ()
 
 isFinished ()
 
 isRunning ()
 
 msleep (unsigned long msecs)
 
 priority ()
 
 quit ()
 
 run ()
 
 setPriority (Priority priority)
 
 setStackSize (uint stackSize)
 
 setTerminationEnabled (bool enabled=true)
 
 sleep (unsigned long secs)
 
 stackSize ()
 
 start (Priority priority=InheritPriority)
 
 started ()
 
 terminate ()
 
 terminated ()
 
 usleep (unsigned long usecs)
 
 wait (unsigned long time=ULONG_MAX)
 
 yieldCurrentThread ()
 

Static Public Member Functions

static shared_pointer instance ()
 get the signelton instance More...
 
static shared_pointer::element_type & reference ()
 get reference to the singelton instance More...
 

Public Attributes

QMutex lock
 a mutex so that external program can lock access to this More...
 

Protected Member Functions

 InputBase (RingBuffer< CASSEvent > &ringbuffer, Ratemeter &ratemeter, Ratemeter &loadmeter, QObject *parent=0)
 protected constructor since it should be a singelton More...
 
- Protected Member Functions inherited from lmf::PausableThread
void pausePoint ()
 point where the thread will be paused More...
 

Protected Attributes

RingBuffer< CASSEvent > & _ringbuffer
 reference to the ringbuffer More...
 
Ratemeter_ratemeter
 ratemeter to measure the rate More...
 
Ratemeter_loadmeter
 meter to measure the data load More...
 
- Protected Attributes inherited from lmf::PausableThread
QMutex _pauseMutex
 mutex to wait on until thread is paused More...
 
QWaitCondition _pauseCondition
 wait condition to wait on until thread is resumed More...
 
QWaitCondition _waitUntilPausedCondition
 wait condition to wait unitl thread is paused More...
 
status_t _status
 the internal status of the thread More...
 
control_t _control
 the internal control status of the thread More...
 
size_t _pausecount
 a counter how many threads have pause this thread More...
 
exception_t _exception_thrown
 flag to show that general exception was thrown More...
 
std::invalid_argument _invarg_excep
 the invalid arguemnt exception thrown More...
 
std::runtime_error _runt_excep
 the invalid arguemnt exception thrown More...
 
std::out_of_range _outrange_excep
 the invalid arguemnt exception thrown More...
 
std::logic_error _logic_excep
 the invalid arguemnt exception thrown More...
 

Static Protected Attributes

static shared_pointer _instance
 singelton instance More...
 

Static Private Attributes

static QMutex _mutex
 a mutex to lock operations More...
 

Additional Inherited Members

- Public Slots inherited from lmf::PausableThread
virtual void end ()
 tell the thread to quit More...
 

Detailed Description

Input base class.

This class acts as base class for all input modules.

Author
Lutz Foucar

Definition at line 31 of file input_base.h.

Member Typedef Documentation

define an item in the ringbuffer

Definition at line 109 of file input_base.h.

typedef std::tr1::shared_ptr<InputBase> cass::InputBase::shared_pointer

shared pointer of this type

Definition at line 35 of file input_base.h.

Constructor & Destructor Documentation

virtual cass::InputBase::~InputBase ( )
inlinevirtual

destructor

Definition at line 38 of file input_base.h.

cass::InputBase::InputBase ( RingBuffer< CASSEvent > &  ringbuffer,
Ratemeter ratemeter,
Ratemeter loadmeter,
QObject parent = 0 
)
inlineprotected

protected constructor since it should be a singelton

Parameters
ringbufferreference to the ringbuffer containing the CASSEvents
ratemeterreference to the ratemeter to measure the rate of the input
loadmeterreference to the ratemeter to measure the load of the input
parentThe parent QT Object of this class

Definition at line 129 of file input_base.h.

Member Function Documentation

uint64_t InputBase::eventcounter ( )
virtual

retrieve the number of events that have been input so far

needs to be implemented by the individual imputs, defaults to 0 otherwise

Reimplemented in cass::SACLAOnlineInput, cass::XFELHDF5FileInput, cass::SharedMemoryInput, cass::SACLAOfflineInput, cass::FileInput, cass::XFELOnlineInput, and cass::ZMQInput.

Definition at line 62 of file input_base.cpp.

Referenced by cass::HDF5FileInput::runthis().

InputBase::rbItem_t InputBase::getNextFillable ( unsigned  timeout = 500)

retrieve an iterator to the next fillable event

try to get an event to be filled from the buffer. Do this until either an event could be retrieved or the thread has been told to quit.

Returns
iterator to the next fillable event, when the end of the ringbuffer has been returned, the thread should quit

Definition at line 48 of file input_base.cpp.

Referenced by cass::SharedMemoryInput::processDgram(), cass::MultiFileInput::readEventData(), cass::ZMQInput::runthis(), cass::XFELOnlineInput::runthis(), cass::TCPInput::runthis(), cass::XFELHDF5FileInput::runthis(), cass::SACLAOnlineInput::runthis(), and cass::HDF5FileInput::runthis().

InputBase::shared_pointer InputBase::instance ( )
static

get the signelton instance

throws logic error when instance does not exist yet

Returns
the singleton instance

Definition at line 20 of file input_base.cpp.

virtual void cass::InputBase::load ( )
pure virtual

load the settings of the input module from ini file

Note
before calling this the caller has to make sure that the input has paused. And resume it afterwards.

Implemented in cass::HDF5FileInput, cass::SACLAOnlineInput, cass::XFELHDF5FileInput, cass::SharedMemoryInput, cass::MultiFileInput, cass::TCPInput, cass::SACLAOfflineInput, cass::XFELOnlineInput, cass::FileInput, cass::ZMQInput, and cass::TestInput.

void InputBase::newEventAdded ( const size_t  eventsize)

increment the numer of events received in the ratemeter

To indicate that we are done processing an event this signal is emitted. This is used for by the ratemeter to evaluate how fast we get events.

Parameters
eventsizesize of the event in bytes

Definition at line 37 of file input_base.cpp.

Referenced by cass::SharedMemoryInput::processDgram(), cass::MultiFileInput::readEventData(), cass::TestInput::run(), cass::ZMQInput::runthis(), cass::XFELOnlineInput::runthis(), cass::TCPInput::runthis(), cass::XFELHDF5FileInput::runthis(), cass::SACLAOnlineInput::runthis(), and cass::HDF5FileInput::runthis().

double InputBase::progress ( )
virtual

retrieve the fraction of how much of the input has been processed

needs to be implemented by the individual inputs, defaults to 0 in case it has not been implemented

Reimplemented in cass::XFELHDF5FileInput, cass::SACLAOfflineInput, and cass::FileInput.

Definition at line 57 of file input_base.cpp.

InputBase::shared_pointer::element_type & InputBase::reference ( )
static

get reference to the singelton instance

throws logic error when instance does not exist yet

Returns
reference to the singleton

Definition at line 28 of file input_base.cpp.

Referenced by cass::pp76::processEvent(), cass::RatePlotter::run(), cass::TxtParser::runthis(), cass::XtcParser::runthis(), and cass::ACQIRIS::LMAParser::runthis().

RingBuffer< CASSEvent > & InputBase::ringbuffer ( )

retrieve a reference to the the ringbuffer

Returns
reference to the ringbuffer

Definition at line 43 of file input_base.cpp.

virtual void cass::InputBase::runthis ( )
pure virtual

function with the main loop

the implementation of this function needs to start by setting the _status variable of the PausableThread to running.like follows: _status = lmf::PausableThread::running;

Implements lmf::PausableThread.

Implemented in cass::HDF5FileInput, cass::SACLAOnlineInput, cass::XFELHDF5FileInput, cass::MultiFileInput, cass::TCPInput, cass::SACLAOfflineInput, cass::XFELOnlineInput, cass::FileInput, cass::SharedMemoryInput, and cass::ZMQInput.

uint64_t InputBase::skippedeventcounter ( )
virtual

retrieve the number of skipped events that have been input so far

needs to be implemented by the individual imputs, defaults to 0 otherwise

Reimplemented in cass::SACLAOnlineInput, cass::XFELHDF5FileInput, cass::SharedMemoryInput, cass::SACLAOfflineInput, cass::FileInput, cass::XFELOnlineInput, and cass::ZMQInput.

Definition at line 67 of file input_base.cpp.

Member Data Documentation

InputBase::shared_pointer InputBase::_instance
staticprotected

singelton instance

Definition at line 149 of file input_base.h.

Ratemeter& cass::InputBase::_loadmeter
protected

meter to measure the data load

Definition at line 146 of file input_base.h.

QMutex InputBase::_mutex
staticprivate

a mutex to lock operations

Definition at line 153 of file input_base.h.

Ratemeter& cass::InputBase::_ratemeter
protected

ratemeter to measure the rate

Definition at line 143 of file input_base.h.

RingBuffer<CASSEvent>& cass::InputBase::_ringbuffer
protected
QMutex cass::InputBase::lock

a mutex so that external program can lock access to this

Definition at line 106 of file input_base.h.

Referenced by cass::MultiFileInput::runthis().


The documentation for this class was generated from the following files: