Diana Software
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
QEvent Class Reference

diana event More...

Public Types

typedef std::map< QEventLabel, QObject ** > QObjectMap
 

Public Member Functions

 QEvent ()
 constructor More...
 
 QEvent (const QEvent &ev)
 copy constructor More...
 
 ~QEvent ()
 destructor More...
 
unsigned int GetReadNumber () const
 return the event number as read by the current reader. More...
 
template<typename Q >
void Get (const char *owner, ReadHandle< Q > &handle) const
 Get a QObject Handle in read mode. More...
 
template<typename Q >
void Get (ReadHandle< Q > &handle) const
 Get a QObject Handle in read mode, owned by the current module. More...
 
template<typename Q >
const Q & Get (const char *owner, const char *name) const
 Get a QObject in read mode. More...
 
template<typename Q >
const Q & Get (const char *name) const
 Get a QObject in read mode, owned by the current module. More...
 
template<typename Q >
const Q & GetByLabel (const QEventLabel &label) const
 Get a QObject in read mode by label. More...
 
template<typename Q >
void Get (WriteHandle< Q > &handle)
 Get a QObject Handle in write mode. More...
 
template<typename Q >
Q & Get (const char *name)
 Get a QObject in write mode. More...
 
template<typename Q >
void Add (WriteHandle< Q > &handle)
 Add a QObject to the event. More...
 
template<typename Q >
Q & Add (const std::string &name)
 Add a QObject to the event. More...
 
template<typename Q >
void Require (const std::string &owner, const std::string &name) const
 notify the QEvent that we need a QObject, if not found an exception is thrown More...
 
template<typename Q >
void RequireByLabel (const QEventLabel &label) const
 notify the QEvent that we need a QObject, if not found an exception is thrown More...
 
void SetAlias (const std::string &name, const std::string &pathInObject, const std::string &alias)
 set alias for objects or variables in objects owned by currentmodule. More...
 
void Dump (std::ostream &o) const
 Print the event and its member. More...
 
const QAliasesGetAliases () const
 get aliases (const version) More...
 
const std::string * GetOwner () const
 get the name of the module that is currently acting on the event More...
 
template<typename Q >
bool Contains (const char *owner, const char *name) const
 Check to see if the event contains a particular object. More...
 
template<typename Q >
bool Contains (const char *label) const
 Check to see if the event contains a particular object. More...
 

Protected Member Functions

template<typename Q >
void Get (const char *owner, WriteHandle< Q > &handle)
 Get a QObject handle in write mode. More...
 
template<typename Q >
void Add (const char *owner, WriteHandle< Q > &handle)
 Add a QObject to the event. This method has to be called before the event loop. More...
 
template<typename Q >
Q & Add (const char *owner, const char *name)
 Add a QObject to the event. This method has to be called before the event loop. More...
 
void Clear ()
 reset members to default values More...
 
void Consolidate ()
 keep only Required and JustAdded QObjects
More...
 
void SetOwner (const std::string *owner) const
 set the name of the module that is currently acting on the event More...
 
QAliasesGetAliases ()
 get aliases More...
 
std::vector< QEventLabelGetLabels () const
 Get all object labels. More...
 
void SetReadNumber (const unsigned int readNumber)
 set the event number as read by the current reader. More...
 
void SetOverWrite (const bool ow=true)
 set whether an object can be overwritten More...
 
const QEventoperator= (const QEvent &ev)
 operator= new QObject's are created if needed and are owned by this. This this method is protected, use the copy ctor instead, or consider QEventAssembler. More...
 
QObject ** GetObject (const char *owner, const char *name) const
 
QObject ** GetObjectByLabel (const QEventLabel &label) const
 

Private Member Functions

void GetLabel (const char *owner, const char *name, QEventLabel &label) const
 
void Add (const char *owner, const char *name, QObject **)
 

Private Attributes

QObjectMap fObjectMap
 
std::map< std::string, std::string > fDefaultMap
 
const std::string mutable * fModuleName
 
unsigned int fReadNumber
 event number More...
 
bool fOverWrite
 
QAliases fAliases
 

Friends

class QEventAssembler
 
class QBaseModule
 

Detailed Description

diana event

Author
Marco Vignati

QEvent is the I/O class for event by event quantities. It is a dynamic container of QObject s, referenced by a label that identifies the object owner and name. The label, implemented by the class QEventLabel, behaves like a string, whose value is "owner@name". Several Get interfaces are provided (both in read and write mode), and the access is mediated by the classes ReadHandle and WriteHandle. Direct access to QObject's is also possible (see the documentation of each method below). QObject's must be added to the event in the Init() of the modules using the Add method. QObject's by default are saved in the output file, but this feature can be disabled after an Add call (see description of single methods).

Public interfaces do not allow complete handling of this class, like using operator=, add an object specifying also the owner, and list all QObject's in the QEvent. The visitor class QEventAssembler provides full handling, and must be used to create a new QEvent. QReader (s), for example, interact with a QEventAssembler and not with a QEvent.

The QEventInspector is another visitor with less power of QEventAssembler that can retreive the list of all QObject (s). This class is used by the QWriter (s).

Examples
MTutorialAmplitudeFilter.cc, MTutorialAveragePulse.cc, and MTutorialPulseShape.cc.

Definition at line 45 of file QEvent.hh.

Member Typedef Documentation

◆ QObjectMap

typedef std::map<QEventLabel,QObject**> QEvent::QObjectMap

Definition at line 48 of file QEvent.hh.

Constructor & Destructor Documentation

◆ QEvent() [1/2]

Q_BEGIN_NAMESPACE QEvent::QEvent ( )

constructor

Definition at line 8 of file QEvent.cc.

References fDefaultMap, fModuleName, fObjectMap, fOverWrite, and fReadNumber.

◆ QEvent() [2/2]

QEvent::QEvent ( const QEvent ev)

copy constructor

Definition at line 33 of file QEvent.cc.

References fDefaultMap, fModuleName, fObjectMap, fOverWrite, fReadNumber, and operator=().

◆ ~QEvent()

QEvent::~QEvent ( )

destructor

Definition at line 17 of file QEvent.cc.

References fDefaultMap, fModuleName, fObjectMap, fOverWrite, and fReadNumber.

Member Function Documentation

◆ Add() [1/5]

template<typename Q >
Q& QEvent::Add ( const char *  owner,
const char *  name 
)
inlineprotected

Add a QObject to the event. This method has to be called before the event loop.

Parameters
ownermodule that owns the QObject
nameof the QObject to be added.

Definition at line 340 of file QEvent.hh.

References Add(), and WriteHandle< T >::Get().

◆ Add() [2/5]

void QEvent::Add ( const char *  owner,
const char *  name,
QObject **  evData 
)
private

◆ Add() [3/5]

template<typename Q >
void QEvent::Add ( const char *  owner,
WriteHandle< Q > &  handle 
)
inlineprotected

Add a QObject to the event. This method has to be called before the event loop.

Parameters
ownermodule that owns the QObject
handleWriteHandle<> of the QObject class to be added.

Definition at line 321 of file QEvent.hh.

References Add(), WriteHandle< T >::CreateObject(), fOverWrite, WriteHandle< T >::GetAddress(), GetObject(), QHandle< T >::GetObjectName(), and QHandle< T >::Set().

◆ Add() [4/5]

template<typename Q >
Q& QEvent::Add ( const std::string &  name)
inline

Add a QObject to the event.

   This method has to be
   called before the event loop, e.g. in the  
   QModule::Init() method of a module. QObject's are by default
   saved in the output file (if any). This feature can be
   disabled using the QObject::SetWrite() method.
Parameters
nameName of the QObject.
       ev.Add<QMyQObject>("ObjectName");
       
or
       ev.Add<QMyQObject>("ObjectName").SetWrite(false);
       

Definition at line 222 of file QEvent.hh.

References Add(), and WriteHandle< T >::Get().

◆ Add() [5/5]

template<typename Q >
void QEvent::Add ( WriteHandle< Q > &  handle)
inline

Add a QObject to the event.

   This method has to be
   called before the event loop, e.g. in the  
   QModule::Init() method of a module. QObject's are by default
   saved in the output file (if any). This feature can be
   disabled using the QObject::SetWrite() method.
Parameters
handleWriteHandle<> of the QObject class to be written. Example:
        WriteHandle<QMyObject> wHandle("MyObject");
        ev.Add(wHandle);
        // use this if the variable is temporary and should not be saved in the output file
        wHandle.Get().SetWrite(false);

        
Examples
MTutorialPulseShape.cc.

Definition at line 193 of file QEvent.hh.

References fModuleName, WriteHandle< T >::Get(), QHandle< T >::GetObjectName(), and QERR_EVENT_GENERIC.

Referenced by QEventAssembler::Add(), Add(), QFilter::Begin(), QDriver::Begin(), QModule::Begin(), MExpandEventToBaseTypes::Init(), MQVectorToQPulse::Init(), MApplyCalibration::Init(), MRunDataLoader::Init(), MVariableOperation::Init(), MLockinDenoising::Init(), MCOFBiComponent::Init(), MOptimumFilter::Init(), MAdvancedPeakFinder::Init(), MPeakDetector::Init(), MPulseIntegral::Init(), MPulseTimeConstants::Init(), MTestModule::Init(), MTestNeighbours::Init(), MFastCoincidence::Init(), MSideAmplitude::Init(), MSideCoincidence::Init(), MSourceRunTime::Init(), MTutorialPulseShape::Init(), MExtractVariableFromObject::Init(), MCustomWaveform::Init(), MNeighboursPacker::Init(), MDownSampling::Init(), MTestRawEvent::Init(), and MQinoDataReader::Init().

◆ Clear()

void QEvent::Clear ( )
protected

reset members to default values

Definition at line 74 of file QEvent.cc.

References fObjectMap.

Referenced by QEventAssembler::Clear(), operator=(), and QEventAssembler::QEventAssembler().

◆ Consolidate()

void QEvent::Consolidate ( )
protected

keep only Required and JustAdded QObjects

Definition at line 84 of file QEvent.cc.

References fObjectMap.

Referenced by QEventAssembler::Consolidate().

◆ Contains() [1/2]

template<typename Q >
bool QEvent::Contains ( const char *  label) const
inline

Check to see if the event contains a particular object.

Definition at line 290 of file QEvent.hh.

References fObjectMap.

◆ Contains() [2/2]

template<typename Q >
bool QEvent::Contains ( const char *  owner,
const char *  name 
) const
inline

Check to see if the event contains a particular object.

Definition at line 279 of file QEvent.hh.

References fObjectMap.

Referenced by QEventAssembler::Contains(), and QFileWriter::Init().

◆ Dump()

void QEvent::Dump ( std::ostream &  o) const

Print the event and its member.

Parameters
ooutput stream

Definition at line 98 of file QEvent.cc.

References QObject::Dump(), fModuleName, fObjectMap, fReadNumber, QEventLabel::GetStringLabel(), QObject::IsRequired(), QObject::IsValid(), and QStringHandler::Resize().

Referenced by QSequence::PrintEvents().

◆ Get() [1/7]

template<typename Q >
Q& QEvent::Get ( const char *  name)
inline

Get a QObject in write mode.

Parameters
nameName of the QObject to be written. Example:
       QMyQObject& obj = ev.Get<QMyQObject>("ObjectName");
       

Definition at line 169 of file QEvent.hh.

References WriteHandle< T >::Get(), and Get().

◆ Get() [2/7]

template<typename Q >
const Q& QEvent::Get ( const char *  name) const
inline

Get a QObject in read mode, owned by the current module.

Parameters
nameName of the QObject to be read, owned by the caller module. Example:
       const QMyQObject& obj = ev.Get<QMyQObject>("ObjectName");
       

Definition at line 120 of file QEvent.hh.

References ReadHandle< T >::Get(), and Get().

◆ Get() [3/7]

template<typename Q >
const Q& QEvent::Get ( const char *  owner,
const char *  name 
) const
inline

Get a QObject in read mode.

Parameters
ownerName of the module that owns the QObject. If owner="" the default owner for that QObject is used.
nameName of the QObject to be read. Example:
       const QMyQObject& obj = ev.Get<QMyQObject>("ModuleNameWithoutM","ObjectName");
       

Definition at line 106 of file QEvent.hh.

References ReadHandle< T >::Get(), and Get().

◆ Get() [4/7]

template<typename Q >
void QEvent::Get ( const char *  owner,
ReadHandle< Q > &  handle 
) const
inline

Get a QObject Handle in read mode.

Parameters
ownerName of the module that owns the QObject. if owner="" the default owner for that QObject is used.
handleReadHandle<> of the QObject class to be read. Example:
       ReadHandle<QMyQObject> handle("ObjectName");
       ev.Get("ModuleNameWithoutM",handle);
       const QMyQObject& obj = handle.Get();
       
Examples
MTutorialAveragePulse.cc, and MTutorialPulseShape.cc.

Definition at line 74 of file QEvent.hh.

References GetObject(), QHandle< T >::GetObjectName(), and QHandle< T >::Set().

Referenced by QFileWriter::BuildFileName(), MExpandEventToBaseTypes::Do(), MQVectorToQPulse::Do(), MApplyCalibration::Do(), MRunDataLoader::Do(), MVariableOperation::Do(), MCOFBiComponent::Do(), MOptimumFilter::Do(), MAdvancedPeakFinder::Do(), MBaselineModule::Do(), MPeakDetector::Do(), MPulseBasicParameters::Do(), MPulseIntegral::Do(), MPulseTimeConstants::Do(), MPulserFlagByRegularTiming::Do(), MAveragePulses::Do(), MTestFetchContinuousIO::Do(), MTestLight::Do(), MTestModule::Do(), MAlphaDelayedCoincidence::Do(), MCheckTimeOrdering::Do(), MFastCoincidence::Do(), MJitterByCoincidence::Do(), MJitterByDelay::Do(), MSourceRunTime::Do(), MTutorialAveragePulse::Do(), MTutorialPulseShape::Do(), MExtractVariableFromObject::Do(), MDecorrelator::Do(), MLockinDenoising::Do(), MNoiseCrossFrequencyCovariance::Do(), MNoiseCrossPowerSpectrum::Do(), MNoiseFrequencyCoherence::Do(), MTestNeighbours::Do(), MTestNeighboursContinuousIO::Do(), MTestUnroll::Do(), MCoincidence::Do(), MSideAmplitude::Do(), MSideCoincidence::Do(), MCoincidenceSimple::Do(), MCustomWaveform::Do(), MGuiDriver::Do(), MDownSampling::Do(), MTestDriver::Do(), MNeighboursPacker::Do(), MTestRawEvent::Do(), MQinoDataReader::Do(), QFileWriter::Do(), QRootFileWriterBase::Dump(), QCreateSidePulseByPulseSplitting::FillList(), QTestReaderEventGenerator::FillList(), QUnrollSidePulses::FillList(), MFilterValidity::Filter(), MRejectNotValid::Filter(), MTwoVariablesEnergyFilter::Filter(), MEarlierEventsFilter::Filter(), MOverlappedWindowFilter::Filter(), MRawDataFilter::Filter(), MTimeCutFilter::Filter(), MSelectRunType::Filter(), MBadPulse::Filter(), MGoodWaveform::Filter(), MSelectPulserByDelay::Filter(), MFilterTest::Filter(), QFilter::FilterAlgorithm(), Get(), QEventAssembler::Get(), QFileWriter::GetCorrespondingReaderFileName(), QAllSideNeighbour::GetNeighbourInfo(), QSameChannelNeighbour::GetNeighbourInfo(), QSameTimeNeighbour::GetNeighbourInfo(), QSideNeighbour::GetNeighbourInfo(), QSideOrSameTimeTrigger::GetNeighbourInfo(), QTimeNeighbour::GetNeighbourInfo(), MCoincidence::GetTime(), MFastCoincidence::GetTime(), MSideCoincidence::GetTime(), MVariableOperation::GetValue(), QFileWriter::IsToOpen(), QFilter::Process(), QDriver::Process(), QModule::Process(), and RequireByLabel().

◆ Get() [5/7]

template<typename Q >
void QEvent::Get ( const char *  owner,
WriteHandle< Q > &  handle 
)
inlineprotected

Get a QObject handle in write mode.

Parameters
ownermodule that owns the QObject
handleWriteHandle<> of the QObject class to be get.

Definition at line 309 of file QEvent.hh.

References GetObject(), QHandle< T >::GetObjectName(), and QHandle< T >::Set().

◆ Get() [6/7]

template<typename Q >
void QEvent::Get ( ReadHandle< Q > &  handle) const
inline

Get a QObject Handle in read mode, owned by the current module.

Parameters
nameHandle of the QObject to be read, owned by the caller module. Example:
       ReadHandle<QMyQObject> handle("ObjectName");
       ev.Get(handle);
       const QMyQObject& obj = handle.Get();
       

Definition at line 89 of file QEvent.hh.

References fModuleName, GetObject(), QHandle< T >::GetObjectName(), and QHandle< T >::Set().

◆ Get() [7/7]

template<typename Q >
void QEvent::Get ( WriteHandle< Q > &  handle)
inline

Get a QObject Handle in write mode.

Parameters
handleWriteHandle<> of the QObject class to be written. Example:
       WriteHandle<QMyQObject> handle("ObjectName");
       ev.Get(handle);
       QMyQObject& obj = handle.Get();
       

Definition at line 153 of file QEvent.hh.

References fModuleName, Get(), QHandle< T >::GetObjectName(), and QERR_EVENT_GENERIC.

◆ GetAliases() [1/2]

QAliases& QEvent::GetAliases ( )
inlineprotected

get aliases

Definition at line 357 of file QEvent.hh.

References fAliases.

◆ GetAliases() [2/2]

const QAliases& QEvent::GetAliases ( ) const
inline

get aliases (const version)

Definition at line 274 of file QEvent.hh.

References fAliases.

Referenced by QEventAssembler::GetAliases(), and SetAlias().

◆ GetByLabel()

template<typename Q >
const Q& QEvent::GetByLabel ( const QEventLabel label) const
inline

◆ GetLabel()

void QEvent::GetLabel ( const char *  owner,
const char *  name,
QEventLabel label 
) const
private

Definition at line 184 of file QEvent.cc.

References fDefaultMap, QEventLabel::name, and QEventLabel::owner.

Referenced by GetObject().

◆ GetLabels()

std::vector< QEventLabel > QEvent::GetLabels ( ) const
protected

◆ GetObject()

QObject ** QEvent::GetObject ( const char *  owner,
const char *  name 
) const
protected

Definition at line 167 of file QEvent.cc.

References GetLabel(), and GetObjectByLabel().

Referenced by Add(), QEventAssembler::Get(), and Get().

◆ GetObjectByLabel()

QObject ** QEvent::GetObjectByLabel ( const QEventLabel label) const
protected

Definition at line 175 of file QEvent.cc.

References fObjectMap.

Referenced by GetByLabel(), GetObject(), and RequireByLabel().

◆ GetOwner()

const std::string* QEvent::GetOwner ( ) const
inline

get the name of the module that is currently acting on the event

Definition at line 277 of file QEvent.hh.

References fModuleName.

Referenced by QSequence::PrintEvents(), and SetAlias().

◆ GetReadNumber()

unsigned int QEvent::GetReadNumber ( ) const
inline

return the event number as read by the current reader.

Definition at line 60 of file QEvent.hh.

References fReadNumber.

Referenced by MTestModule::Do(), MTestNeighbours::Do(), MCoincidence::Do(), MCoincidenceSimple::Do(), MFlagCoincidence::Do(), MTimeEnergy::Do(), MTimeSort::Do(), QReader::DoBase(), and QDriver::Process().

◆ operator=()

const QEvent & QEvent::operator= ( const QEvent ev)
protected

operator= new QObject's are created if needed and are owned by this. This this method is protected, use the copy ctor instead, or consider QEventAssembler.

Parameters
evother QEvent

Definition at line 43 of file QEvent.cc.

References Clear(), QObject::Duplicate(), fDefaultMap, fModuleName, fObjectMap, fOverWrite, fReadNumber, QObject::FullyFill(), and QObject::IsValid().

Referenced by QEvent().

◆ Require()

template<typename Q >
void QEvent::Require ( const std::string &  owner,
const std::string &  name 
) const
inline

◆ RequireByLabel()

template<typename Q >
void QEvent::RequireByLabel ( const QEventLabel label) const
inline

◆ SetAlias()

void QEvent::SetAlias ( const std::string &  name,
const std::string &  pathInObject,
const std::string &  alias 
)
inline

set alias for objects or variables in objects owned by currentmodule.

Parameters
nameQObject name
pathInObjectvariable in object that needs alias.
aliasalias for the QObject

Definition at line 261 of file QEvent.hh.

References QAliases::Add(), GetAliases(), and GetOwner().

Referenced by QFilter::Begin(), and MExtractVariableFromObject::Init().

◆ SetOverWrite()

void QEvent::SetOverWrite ( const bool  ow = true)
inlineprotected

set whether an object can be overwritten

Definition at line 366 of file QEvent.hh.

References fOverWrite.

Referenced by QEventAssembler::SetOverWrite().

◆ SetOwner()

void QEvent::SetOwner ( const std::string *  owner) const
inlineprotected

set the name of the module that is currently acting on the event

Definition at line 354 of file QEvent.hh.

References fModuleName.

Referenced by QEventAssembler::SetOwner().

◆ SetReadNumber()

void QEvent::SetReadNumber ( const unsigned int  readNumber)
inlineprotected

set the event number as read by the current reader.

Definition at line 363 of file QEvent.hh.

References fReadNumber.

Referenced by QEventAssembler::SetReadNumber().

Friends And Related Function Documentation

◆ QBaseModule

friend class QBaseModule
friend

Definition at line 396 of file QEvent.hh.

◆ QEventAssembler

friend class QEventAssembler
friend

Definition at line 395 of file QEvent.hh.

Member Data Documentation

◆ fAliases

QAliases QEvent::fAliases
private

Definition at line 393 of file QEvent.hh.

Referenced by GetAliases().

◆ fDefaultMap

std::map<std::string, std::string> QEvent::fDefaultMap
private

Definition at line 384 of file QEvent.hh.

Referenced by Add(), GetLabel(), operator=(), QEvent(), and ~QEvent().

◆ fModuleName

const std::string mutable* QEvent::fModuleName
private

Definition at line 386 of file QEvent.hh.

Referenced by Add(), Dump(), Get(), GetOwner(), operator=(), QEvent(), SetOwner(), and ~QEvent().

◆ fObjectMap

QObjectMap QEvent::fObjectMap
private

◆ fOverWrite

bool QEvent::fOverWrite
private

Definition at line 391 of file QEvent.hh.

Referenced by Add(), operator=(), QEvent(), SetOverWrite(), and ~QEvent().

◆ fReadNumber

unsigned int QEvent::fReadNumber
private

event number

Definition at line 389 of file QEvent.hh.

Referenced by Dump(), GetReadNumber(), operator=(), QEvent(), SetReadNumber(), and ~QEvent().


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