DABC (Data Acquisition Backbone Core)  2.9.9
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends
dabc::ParameterContainer Class Reference

Container for parameter object. More...

#include <dabc/Parameter.h>

Inheritance diagram for dabc::ParameterContainer:
dabc::RecordContainer dabc::Object dabc::ConnectionObject

Public Member Functions

virtual const char * ClassName () const
 Returns class name of the object instance. More...
 
const std::string & Kind () const
 
- Public Member Functions inherited from dabc::RecordContainer
RecordFieldsMapFields () const
 
virtual void Print (int lvl=0)
 Print object content on debug output. More...
 
virtual ~RecordContainer ()
 
- Public Member Functions inherited from dabc::Object
bool AddChild (Object *child, bool withmutex=true) throw ()
 Add object to list of child objects, thread safe More...
 
bool AddChildAt (Object *child, unsigned pos, bool withmutex=true)
 Add object to list of child objects at specified position. More...
 
virtual bool Find (ConfigIO &cfg)
 Method to locate object in xml file. More...
 
ObjectFindChild (const char *name) const
 returns pointer on child object with given name More...
 
Reference FindChildRef (const char *name, bool force=false) const throw ()
 returns reference on child object with given name More...
 
bool GetAllChildRef (ReferencesVector *vect) const
 
ObjectGetChild (unsigned n) const
 returns pointer on child object More...
 
Reference GetChildRef (unsigned n) const
 returns reference on child object More...
 
Reference GetFolder (const std::string &name, bool force=false) throw ()
 Return folder of specified name, no special symbols allowed. More...
 
const char * GetName () const
 Returns name of the object, thread safe More...
 
ObjectGetParent () const
 Returns pointer on parent object, thread safe More...
 
Reference GetParentRef () const
 
bool IsChildsHidden () const
 Return true if object wants to hide childs from hierarchy scan, thread safe More...
 
bool IsHidden () const
 Return true if object wants to be hidden from hierarchy scan, thread safe More...
 
bool IsLogging () const
 Return true if object selected for logging, thread safe More...
 
bool IsName (const char *str) const
 Checks if object name is same as provided string, thread safe More...
 
bool IsName (const char *str, int len) const
 Checks if object name is same as provided, thread safe More...
 
bool IsName (const std::string &str) const
 Checks if object name is same as provided string, thread safe More...
 
bool IsNameMatch (const std::string &mask) const
 Check if object name match to the mask. More...
 
bool IsOwner () const
 Returns true if object is owner of its children, thread safe More...
 
bool IsParent (Object *obj) const
 Checks if specified argument is in the list of object parents. More...
 
bool IsTopXmlLevel () const
 Return true if object should be searched in the top level of the xml file, thread safe More...
 
std::string ItemName (bool compact=true) const
 Produce string, which can be used as name argument in dabc::mgr.FindItem(name) call. More...
 
unsigned NumChilds () const
 returns number of child objects More...
 
 Object (const std::string &name, unsigned flags=flIsOwner)
 Resolve problem with child-parent mutex locking. More...
 
 Object (Reference parent, const std::string &name, unsigned flags=flIsOwner)
 
bool RemoveChild (Object *child, bool cleanup=true) throw ()
 Detach child from parent object If cleanup==true and parent is owner of child, child will be destroyed. More...
 
bool RemoveChildAt (unsigned n, bool cleanup=true) throw ()
 Detach child object from parent at specified position If cleanup==true and object is owner of child, child will be destroyed. More...
 
bool RemoveChilds (bool cleanup=true)
 Remove all childs. More...
 
void SetLogging (bool on=true)
 Sets logging flag, thread safe More...
 
virtual ~Object ()
 

Protected Types

enum  EStatistic { kindNone , kindRate , kindAverage }
 
- Protected Types inherited from dabc::Object
enum  EFlags {
  flStateMask = 0x000f , flIsOwner = 0x0010 , flCleanup = 0x0020 , flHasThread = 0x0040 ,
  flAutoDestroy = 0x0080 , flLogging = 0x0100 , flNoMutex = 0x0200 , flHidden = 0x0400 ,
  flChildsHidden = 0x0800 , flTopXmlLevel = 0x1000
}
 

Protected Member Functions

bool _CalcRate (double &value, std::string &svalue)
 
virtual bool _CanChangeField (const std::string &)
 Method allows in derived classes to block changes of some fields. More...
 
virtual void BuildFieldsMap (RecordFieldsMap *cont)
 Save parameter attributes into container. More...
 
unsigned ConfirmFromWorker ()
 Get confirmation from worker, which monitor parameters changes. More...
 
virtual std::string DefaultFiledName () const
 
virtual std::string FieldName (unsigned cnt) const
 
void FireModified (const std::string &svalue)
 Internal method, used to inform system that parameter is modified If configured, also debug output will be produced. More...
 
void FireParEvent (int id)
 
const std::string GetActualUnits () const
 
int GetDebugLevel () const
 
virtual RecordField GetField (const std::string &name) const
 
WorkerGetWorker () const
 
virtual bool HasField (const std::string &name) const
 
bool IsDeliverAllEvents () const
 If true, all events must be delivered to the consumer. More...
 
void Modified ()
 
virtual unsigned NumFields () const
 
virtual void ObjectCleanup ()
 User method to cleanup object content before it will be destroyed Main motivation is to release any references on other objects to avoid any cross-references and as result deadlocks in objects cleanup. More...
 
 ParameterContainer (Reference worker, const std::string &name, const std::string &parkind="", bool hidden=false)
 
void ProcessTimeout (double last_dif)
 Method called from manager thread when parameter configured as asynchronous. More...
 
virtual bool RemoveField (const std::string &name)
 
virtual bool SetField (const std::string &name, const RecordField &v)
 
void SetSynchron (bool on, double interval=1., bool everyevnt=false)
 Specifies that parameter produce 'modified' events synchronous with changes of parameter. More...
 
virtual ~ParameterContainer ()
 
- Protected Member Functions inherited from dabc::RecordContainer
 RecordContainer (const std::string &name, unsigned flags=flIsOwner)
 
 RecordContainer (Reference parent, const std::string &name, unsigned flags=flIsOwner)
 
virtual bool SaveTo (HStore &store, bool create_node=true)
 
void SetFieldsMap (RecordFieldsMap *newmap)
 Replaces existing fields map. More...
 
RecordFieldsMapTakeFieldsMap ()
 Remove map and returns to the user. More...
 
- Protected Member Functions inherited from dabc::Object
virtual void _ChildsChanged ()
 Method called when new childs are add or old are removed. More...
 
virtual bool _DoDeleteItself ()
 This method is called at the moment when DecReference think that object can be destroyed and wants to return true. More...
 
bool _IsNormalState ()
 Same as IsNormalState() but without mutex lock - user should lock mutex himself. More...
 
virtual ObjectCreateInstance (const std::string &name)
 Method used to create new item to be placed as child of the object. More...
 
void DeleteThis ()
 Method should be used by the object to delete itself. More...
 
virtual bool DestroyByOwnThread ()
 Internal DABC method, used to activate object cleanup via object thread Returns: false - object cannot be cleanup by the thread, true - thread guarantees that DestroyCalledFromOwnThread() will be called from thread context. More...
 
bool DestroyCalledFromOwnThread ()
 Internal DABC method, should be called by thread which was requested to destroy object. More...
 
void FillFullName (std::string &fullname, Object *upto, bool exclude_top_parent=false) const
 Method used to produce full item name,. More...
 
bool GetFlag (unsigned fl) const
 Return value of selected flag, not thread safe
More...
 
bool IsNormalState ()
 Return true if object is in normal state. More...
 
unsigned NumReferences ()
 Return number of references on the object. More...
 
 Object (const ConstructorPair &pair, unsigned flags=flIsOwner)
 
virtual void ObjectDestroyed (Object *)
 Method called by the manager when registered dependent object is destroyed Should be used in user class to clear all references on the object to let destroy it. More...
 
MutexObjectMutex () const
 Returns mutex, used for protection of Object data members. More...
 
void SetAutoDestroy (bool on=true)
 Set autodestroy flag for the object Once enabled, object will be destroyed when last reference will be cleared. More...
 
void SetFlag (unsigned fl, bool on=true)
 Change value of selected flag, not thread safe
More...
 
void SetName (const char *name)
 Changes object name. More...
 
void SetNameDirect (const char *name)
 Changes object name disregard of existing references. More...
 
void SetOwner (bool on=true)
 Specifies if object will be owner of its new childs. More...
 

Protected Attributes

bool fAsynchron
 indicates if parameter can produce events asynchronous to the modification of parameter itself it is a case for ratemeters More...
 
bool fAttrModified
 indicate if attribute was modified since last parameter event More...
 
bool fDeliverAllEvents
 if true, any modification event will be delivered, default off More...
 
double fInterval
 how often modified events are produced TODO: should we move it in the normal record field? More...
 
std::string fKind
 specified kind of parameter (int, double, info, ratemeter), to be used by reference to decide if object can be assigned More...
 
TimeStamp fLastChangeTm
 last time when parameter was modified More...
 
bool fMonitored
 if true parameter change event will be delivered to the worker More...
 
double fRateNumSum
 sum of accumulated counts More...
 
int fRatePrec
 display precision of rate variable More...
 
double fRateTimeSum
 sum of time More...
 
double fRateValueSum
 sum of values More...
 
int fRateWidth
 display width of rate variable More...
 
bool fRecorded
 if true, parameter changes should be reported to worker where it will be recorded More...
 
EStatistic fStatistic
 indicates if statistic is calculated: 0 - off, 1 - rate, 2 - average More...
 
bool fWaitWorker
 if true, waiting confirmation from worker More...
 
- Protected Attributes inherited from dabc::RecordContainer
RecordFieldsMapfFields
 
- Protected Attributes inherited from dabc::Object
int fObjectBlock
 counter for blocking calls, as long as non-zero, non of child can be removed More...
 
ReferencesVectorfObjectChilds
 list of the child objects More...
 
unsigned fObjectFlags
 flag, protected by the mutex More...
 
MutexfObjectMutex
 mutex protects all private property of the object More...
 
std::string fObjectName
 object name More...
 
Reference fObjectParent
 reference on the parent object More...
 
int fObjectRefCnt
 accounts how many references existing on the object, thread safe More...
 

Friends

class Manager
 
class Parameter
 
class Worker
 

Additional Inherited Members

- Static Public Member Functions inherited from dabc::Object
static void Destroy (Object *obj) throw ()
 User method for object destroyment. More...
 
static void InspectGarbageCollector ()
 \ brief Methods to inspect how many objects pointers are remained More...
 
static bool NameMatch (const std::string &name, const std::string &mask)
 Check if name matches to specified mask. More...
 
static bool NameMatchM (const std::string &name, const std::string &mask)
 Check if name matches to specified mask. More...
 
static unsigned NumInstances ()
 Static variable counts total number of objects instances. More...
 
- Static Protected Member Functions inherited from dabc::Object
static ConstructorPair MakePair (const std::string &fullname, bool withmanager=true)
 Internal DABC method, used to produce pair - object parent and object name, which is typically should be used as argument in class constructor. More...
 
static ConstructorPair MakePair (Object *prnt, const std::string &fullname, bool withmanager=true)
 Internal DABC method, used to produce pair - object parent and object name, which is typically should be used as argument in class constructor. More...
 
static ConstructorPair MakePair (Reference prnt, const std::string &fullname, bool withmanager=true)
 Internal DABC method, used to produce pair - object parent and object name, which is typically should be used as argument in class constructor. More...
 

Detailed Description

Container for parameter object.

Definition at line 52 of file Parameter.h.

Member Enumeration Documentation

◆ EStatistic

Enumerator
kindNone 
kindRate 
kindAverage 

Definition at line 59 of file Parameter.h.

Constructor & Destructor Documentation

◆ ParameterContainer()

dabc::ParameterContainer::ParameterContainer ( Reference  worker,
const std::string &  name,
const std::string &  parkind = "",
bool  hidden = false 
)
protected

Definition at line 23 of file Parameter.cxx.

◆ ~ParameterContainer()

dabc::ParameterContainer::~ParameterContainer ( )
protectedvirtual

Definition at line 46 of file Parameter.cxx.

Member Function Documentation

◆ DefaultFiledName()

std::string dabc::ParameterContainer::DefaultFiledName ( ) const
protectedvirtual

Reimplemented in dabc::ConnectionObject.

Definition at line 74 of file Parameter.cxx.

◆ HasField()

virtual bool dabc::ParameterContainer::HasField ( const std::string &  name) const
inlineprotectedvirtual

Reimplemented from dabc::RecordContainer.

Definition at line 81 of file Parameter.h.

◆ RemoveField()

virtual bool dabc::ParameterContainer::RemoveField ( const std::string &  name)
inlineprotectedvirtual

Reimplemented from dabc::RecordContainer.

Definition at line 84 of file Parameter.h.

◆ NumFields()

virtual unsigned dabc::ParameterContainer::NumFields ( ) const
inlineprotectedvirtual

Reimplemented from dabc::RecordContainer.

Definition at line 87 of file Parameter.h.

◆ FieldName()

virtual std::string dabc::ParameterContainer::FieldName ( unsigned  cnt) const
inlineprotectedvirtual

Reimplemented from dabc::RecordContainer.

Definition at line 90 of file Parameter.h.

◆ GetField()

dabc::RecordField dabc::ParameterContainer::GetField ( const std::string &  name) const
protectedvirtual

Reimplemented from dabc::RecordContainer.

Definition at line 80 of file Parameter.cxx.

◆ SetField()

bool dabc::ParameterContainer::SetField ( const std::string &  name,
const RecordField v 
)
protectedvirtual

Reimplemented from dabc::RecordContainer.

Definition at line 92 of file Parameter.cxx.

◆ ProcessTimeout()

void dabc::ParameterContainer::ProcessTimeout ( double  last_dif)
protected

Method called from manager thread when parameter configured as asynchronous.

It is done intentionally to avoid situation that in non-deterministic way event processing per-timeout invoked from the worker thread. TODO: should be invocation of parModified events generally done from the manager thread, or keep it only for asynchron parameters?

Definition at line 216 of file Parameter.cxx.

◆ Modified()

void dabc::ParameterContainer::Modified ( )
inlineprotected

Definition at line 106 of file Parameter.h.

◆ _CanChangeField()

virtual bool dabc::ParameterContainer::_CanChangeField ( const std::string &  )
inlineprotectedvirtual

Method allows in derived classes to block changes of some fields.

Reimplemented in dabc::ConnectionObject.

Definition at line 109 of file Parameter.h.

◆ FireParEvent()

void dabc::ParameterContainer::FireParEvent ( int  id)
protected

Definition at line 202 of file Parameter.cxx.

◆ ObjectCleanup()

void dabc::ParameterContainer::ObjectCleanup ( )
protectedvirtual

User method to cleanup object content before it will be destroyed Main motivation is to release any references on other objects to avoid any cross-references and as result deadlocks in objects cleanup.

Method is called in context of thread, to which object belongs to. If user redefines this method, he is responsible to call method of parent class

Reimplemented from dabc::Object.

Definition at line 209 of file Parameter.cxx.

◆ _CalcRate()

bool dabc::ParameterContainer::_CalcRate ( double &  value,
std::string &  svalue 
)
protected

Definition at line 263 of file Parameter.cxx.

◆ SetSynchron()

void dabc::ParameterContainer::SetSynchron ( bool  on,
double  interval = 1.,
bool  everyevnt = false 
)
protected

Specifies that parameter produce 'modified' events synchronous with changes of parameter.

If on=false (asynchronous), events are produced by timeout from manager (with granularity of 1 sec). Interval specifies how often event should be produced - if 0 specified every parameter change will call parameter modified event.

Definition at line 283 of file Parameter.cxx.

◆ GetWorker()

dabc::Worker * dabc::ParameterContainer::GetWorker ( ) const
protected

Definition at line 294 of file Parameter.cxx.

◆ GetDebugLevel()

int dabc::ParameterContainer::GetDebugLevel ( ) const
inlineprotected

Definition at line 125 of file Parameter.h.

◆ GetActualUnits()

const std::string dabc::ParameterContainer::GetActualUnits ( ) const
protected

Definition at line 54 of file Parameter.cxx.

◆ IsDeliverAllEvents()

bool dabc::ParameterContainer::IsDeliverAllEvents ( ) const
protected

If true, all events must be delivered to the consumer.

Definition at line 67 of file Parameter.cxx.

◆ FireModified()

void dabc::ParameterContainer::FireModified ( const std::string &  svalue)
protected

Internal method, used to inform system that parameter is modified If configured, also debug output will be produced.

Definition at line 191 of file Parameter.cxx.

◆ BuildFieldsMap()

void dabc::ParameterContainer::BuildFieldsMap ( RecordFieldsMap cont)
protectedvirtual

Save parameter attributes into container.

Reimplemented from dabc::Object.

Definition at line 311 of file Parameter.cxx.

◆ ConfirmFromWorker()

unsigned dabc::ParameterContainer::ConfirmFromWorker ( )
protected

Get confirmation from worker, which monitor parameters changes.

One use such call to allow next generation of event

Definition at line 179 of file Parameter.cxx.

◆ ClassName()

virtual const char* dabc::ParameterContainer::ClassName ( ) const
inlinevirtual

Returns class name of the object instance.

In some cases class name used to correctly locate object in xml file

Reimplemented from dabc::RecordContainer.

Reimplemented in dabc::ConnectionObject.

Definition at line 145 of file Parameter.h.

◆ Kind()

const std::string & dabc::ParameterContainer::Kind ( ) const

Definition at line 305 of file Parameter.cxx.

Friends And Related Function Documentation

◆ Parameter

friend class Parameter
friend

Definition at line 53 of file Parameter.h.

◆ Worker

friend class Worker
friend

Definition at line 54 of file Parameter.h.

◆ Manager

friend class Manager
friend

Definition at line 55 of file Parameter.h.

Field Documentation

◆ fKind

std::string dabc::ParameterContainer::fKind
protected

specified kind of parameter (int, double, info, ratemeter), to be used by reference to decide if object can be assigned

Definition at line 61 of file Parameter.h.

◆ fLastChangeTm

TimeStamp dabc::ParameterContainer::fLastChangeTm
protected

last time when parameter was modified

Definition at line 62 of file Parameter.h.

◆ fInterval

double dabc::ParameterContainer::fInterval
protected

how often modified events are produced TODO: should we move it in the normal record field?

Definition at line 63 of file Parameter.h.

◆ fAsynchron

bool dabc::ParameterContainer::fAsynchron
protected

indicates if parameter can produce events asynchronous to the modification of parameter itself it is a case for ratemeters

Definition at line 64 of file Parameter.h.

◆ fStatistic

EStatistic dabc::ParameterContainer::fStatistic
protected

indicates if statistic is calculated: 0 - off, 1 - rate, 2 - average

Definition at line 66 of file Parameter.h.

◆ fRateValueSum

double dabc::ParameterContainer::fRateValueSum
protected

sum of values

Definition at line 67 of file Parameter.h.

◆ fRateTimeSum

double dabc::ParameterContainer::fRateTimeSum
protected

sum of time

Definition at line 68 of file Parameter.h.

◆ fRateNumSum

double dabc::ParameterContainer::fRateNumSum
protected

sum of accumulated counts

Definition at line 69 of file Parameter.h.

◆ fMonitored

bool dabc::ParameterContainer::fMonitored
protected

if true parameter change event will be delivered to the worker

Definition at line 70 of file Parameter.h.

◆ fRecorded

bool dabc::ParameterContainer::fRecorded
protected

if true, parameter changes should be reported to worker where it will be recorded

Definition at line 71 of file Parameter.h.

◆ fWaitWorker

bool dabc::ParameterContainer::fWaitWorker
protected

if true, waiting confirmation from worker

Definition at line 72 of file Parameter.h.

◆ fAttrModified

bool dabc::ParameterContainer::fAttrModified
protected

indicate if attribute was modified since last parameter event

Definition at line 73 of file Parameter.h.

◆ fDeliverAllEvents

bool dabc::ParameterContainer::fDeliverAllEvents
protected

if true, any modification event will be delivered, default off

Definition at line 74 of file Parameter.h.

◆ fRateWidth

int dabc::ParameterContainer::fRateWidth
protected

display width of rate variable

Definition at line 75 of file Parameter.h.

◆ fRatePrec

int dabc::ParameterContainer::fRatePrec
protected

display precision of rate variable

Definition at line 76 of file Parameter.h.


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