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

Module manages published hierarchies and provide optimize access to them More...

#include <dabc/Publisher.h>

Inheritance diagram for dabc::Publisher:
dabc::Worker dabc::Object

Public Member Functions

virtual const char * ClassName () const
 Returns class name of the object instance. More...
 
 Publisher (const std::string &name, dabc::Command cmd=nullptr)
 
virtual ~Publisher ()
 
- Public Member Functions inherited from dabc::Worker
bool ActivateTimeout (double tmout_sec)
 Method used to produce timeout events in the worker. More...
 
Command Assign (Command cmd)
 ! Assign command with processor before command be submitted to other processor This produce ReplyCommand() call when command execution is finished Command itself returned if operation was successful, otherwise null() command More...
 
void AssignAddon (WorkerAddon *addon)
 Assigns addon to the worker Should be called before worker assigned to the thread. More...
 
bool AssignToThread (ThreadRef thrd, bool sync=true)
 Assign worker to thread, worker becomes active immediately. More...
 
bool CanSubmitCommand () const
 Returns true if command can be submitted to worker. More...
 
RecordField Cfg (const std::string &name, Command cmd=nullptr) const
 Returns configuration field of specified name Configuration value of specified name searched in following places: More...
 
bool DettachFromThread ()
 Detach worker from the thread, later worker can be assigned to some other thread Method especially useful to normally finish object recursion (if it possible). More...
 
bool Execute (Command cmd, double tmout=-1.)
 Execute command in the processor. More...
 
bool Execute (const std::string &cmd, double tmout=-1.)
 
bool HasThread () const
 Indicates if pointer on thread is not zero; thread-safe. More...
 
bool IsOwnThread () const
 Returns true if called from thread. More...
 
bool MakeThreadForWorker (const std::string &thrdname="")
 Creates appropriate thread for worker and assign worker to the thread. More...
 
Parameter Par (const std::string &name) const
 Returns reference on worker parameter object. More...
 
virtual std::string RequiredThrdClass () const
 Method returns name of required thread class for processor. More...
 
void SetWorkerPriority (int nq)
 
bool Submit (Command cmd)
 Submit command for execution in the processor. More...
 
ThreadRef thread ()
 Return reference on the worker thread; thread-safe. More...
 
std::string ThreadName () const
 Returns name of the worker thread; thread-safe
More...
 
 Worker (Reference parent, const std::string &name)
 
std::string WorkerAddress (bool full=true)
 Return address, which can be used to submit command to the worker If full specified, command can be submitted from any node, which has connection to this node. More...
 
uint32_t WorkerId () const
 
int WorkerPriority () const
 
virtual ~Worker ()
 
- 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 void BuildFieldsMap (RecordFieldsMap *cont)
 Fill fields map, which is relevant for the object Objects hierarchy produced from dabc::Manager. 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)
 
virtual void Print (int lvl=0)
 Print object content on debug output. More...
 
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 ()
 

Static Public Member Functions

static const char * DfltName ()
 
- Static Public Member Functions inherited from dabc::Worker
static int cmd_bool (bool v)
 
- 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...
 

Protected Types

typedef std::list< PublisherEntryPublishersList
 ! last local version, used to build global list More...
 
typedef std::list< SubscriberEntrySubscribersList
 
- 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 ApplyEntryDiff (unsigned recid, dabc::Buffer &buf, uint64_t version, bool witherror=false)
 
void CheckDnsSubscribers ()
 
dabc::Command CreateExeCmd (const std::string &path, const std::string &query, dabc::Command tgt=nullptr)
 
bool DoStorage () const
 
virtual int ExecuteCommand (Command cmd)
 Main method where commands are executed. More...
 
Hierarchy GetWorkItem (const std::string &path, bool *islocal=nullptr)
 Return hierarchy item selected for work. More...
 
bool IdentifyItem (bool asproducer, const std::string &itemname, bool &islocal, std::string &producer_name, std::string &request_name)
 Try to find producer which potentially could deliver item It could happen that item is not exists in hierarchy, therefore shorter name will be tried. More...
 
void InvalidateGlobal ()
 Method marks that global version is out of date and should be rebuild. More...
 
virtual void OnThreadAssigned ()
 ! how often storage is triggered More...
 
virtual double ProcessTimeout (double last_diff)
 
bool RedirectCommand (dabc::Command cmd, const std::string &itemname)
 Command redirected to local modules or remote publisher, where it should be processed Primary usage - for GetBinary commands, but also for any extra requests. More...
 
virtual bool ReplyCommand (Command cmd)
 Reimplement this method to react on command reply Return true if command can be destroyed by framework. More...
 
- Protected Member Functions inherited from dabc::Worker
bool _FireDoNothingEvent ()
 
bool _FireEvent (uint16_t evid)
 
bool _FireEvent (uint16_t evid, uint32_t arg, int pri=-1)
 
bool _IsFireEvent () const
 
bool ActivateMainLoop ()
 
virtual void BeforeHierarchyScan (Hierarchy &h)
 Method called before publisher makes next snapshot of hierarchy. More...
 
void CancelCommands ()
 
void CleanupPublisher (bool sync=true)
 Release reference on publisher and unsubscribe/unpublish all registered entries. More...
 
CommandDefinition CreateCmdDef (const std::string &name)
 
virtual Parameter CreatePar (const std::string &name, const std::string &kind="")
 
virtual bool DestroyByOwnThread ()
 Inherited method from Object, invoked at the moment when worker requested to be destroyed by its thread. More...
 
bool DestroyPar (const std::string &name)
 Method must be used if worker wants to destroy parameter. More...
 
virtual void DoWorkerAfterMainLoop ()
 Internal - function executed after leaving main loop. More...
 
virtual void DoWorkerMainLoop ()
 Internal - entrance function for main loop execution. More...
 
bool ExecuteIn (Worker *dest, Command cmd)
 Executes command in specified worker. More...
 
virtual bool Find (ConfigIO &cfg)
 Method to locate object in xml file. More...
 
bool FireEvent (uint16_t evid)
 
bool FireEvent (uint16_t evid, uint32_t arg, int pri=-1)
 
Reference GetPublisher ()
 Return reference on publisher. More...
 
bool IsWorkerActive () const
 Method indicates if worker is running in the thread and accepts normal events. More...
 
virtual void ObjectCleanup ()
 Central cleanup method for worker. More...
 
virtual void ObjectDestroyed (Object *)
 Method to clear object reference, will be called from thread context (when possible) More...
 
virtual int PreviewCommand (Command cmd)
 This method called before command will be executed. More...
 
virtual void ProcessEvent (const EventId &)
 
virtual void ProcessParameterEvent (const ParameterEvent &evnt)
 Interface method to retrieve subscribed parameter events. More...
 
virtual bool Publish (const Hierarchy &h, const std::string &path)
 
virtual bool PublishPars (const std::string &path)
 
bool RegisterForParameterEvent (const std::string &mask, bool onlychangeevent=true)
 Subscribe to parameter events from local or remote node. More...
 
void SetParValue (const std::string &name, const RecordField &v)
 Set parameter value and sync with worker hierarchy. More...
 
void SetWorkerCfgId (int id=-1)
 Set identifier which can be used in XML configuration ${}# formula It means that correspondent to the ID element of array will be extracted. More...
 
bool SingleLoop (double tmout)
 
virtual bool Subscribe (const std::string &path)
 
virtual bool Unpublish (const Hierarchy &h, const std::string &path)
 
bool UnregisterForParameterEvent (const std::string &mask)
 Unsubscribe to parameter events from local or remote node. More...
 
virtual bool Unsubscribe (const std::string &path)
 
 Worker (const ConstructorPair &pair)
 Special constructor, designed for inherited classes. More...
 
void WorkerSleep (double tmout)
 
- 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...
 
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)
 
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

unsigned fCnt
 
int fFileLimit
 ! selected hierarchy path for storage like 'MBS' or 'FESA/server' More...
 
Hierarchy fGlobal
 
uint64_t fLastLocalVers
 ! this is hierarchy only for entries from local modules More...
 
Hierarchy fLocal
 ! this is hierarchy of all known items, including remote, used only when any global hierarchies are existing More...
 
Hierarchy fMgrHiearchy
 ! path for manager More...
 
std::string fMgrPath
 ! counter for new records More...
 
PublishersList fPublishers
 
std::string fStoreDir
 ! this is manager hierarchy, published by ourselfs More...
 
double fStorePeriod
 ! maximum time of store file, in seconds More...
 
std::string fStoreSel
 ! directory to store data More...
 
SubscribersList fSubscribers
 
int fTimeLimit
 ! maximum size of store file, in MB More...
 
- Protected Attributes inherited from dabc::Worker
WorkerAddonRef fAddon
 extension of worker for some special events More...
 
Reference fPublisher
 reference on publisher, once found, remain until end of object live More...
 
ThreadRef fThread
 reference on the thread, once assigned remain whole time More...
 
MutexfThreadMutex
 pointer on main thread mutex More...
 
bool fWorkerActive
 indicates if worker can submit events to the thread More...
 
int fWorkerCfgId
 special ID, can be used in XML configuration in ${}# formula More...
 
CommandsQueue fWorkerCommands
 all kinds of commands, processed by the worker More...
 
int fWorkerCommandsLevel
 Number of process commands recursion. More...
 
unsigned fWorkerFiredEvents
 indicate current balance between fired and processed events, used to correctly halt worker More...
 
Hierarchy fWorkerHierarchy
 place for publishing of worker parameters More...
 
uint32_t fWorkerId
 worker id in thread list, used for events submit More...
 
int fWorkerPriority
 priority of events, submitted by worker to the thread More...
 
- 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 PublisherRef
 

Additional Inherited Members

- Public Types inherited from dabc::Worker
enum  EPriotiryLevels { priorityMaximum = 0 , priorityMinimum = -1 , priorityDefault = -7 , priorityMagic = -77 }
 
enum  EWorkerEventsCodes { evntFirstCore = 1 , evntFirstAddOn = 100 , evntFirstSystem = 200 , evntFirstUser = 1000 }
 
- 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

Module manages published hierarchies and provide optimize access to them

Definition at line 146 of file Publisher.h.

Member Typedef Documentation

◆ PublishersList

typedef std::list<PublisherEntry> dabc::Publisher::PublishersList
protected

! last local version, used to build global list

Definition at line 158 of file Publisher.h.

◆ SubscribersList

typedef std::list<SubscriberEntry> dabc::Publisher::SubscribersList
protected

Definition at line 160 of file Publisher.h.

Constructor & Destructor Documentation

◆ Publisher()

dabc::Publisher::Publisher ( const std::string &  name,
dabc::Command  cmd = nullptr 
)

Definition at line 96 of file Publisher.cxx.

◆ ~Publisher()

dabc::Publisher::~Publisher ( )
virtual

Definition at line 123 of file Publisher.cxx.

Member Function Documentation

◆ OnThreadAssigned()

void dabc::Publisher::OnThreadAssigned ( )
protectedvirtual

! how often storage is triggered

Reimplemented from dabc::Worker.

Definition at line 128 of file Publisher.cxx.

◆ ProcessTimeout()

double dabc::Publisher::ProcessTimeout ( double  last_diff)
protectedvirtual

Reimplemented from dabc::Worker.

Definition at line 165 of file Publisher.cxx.

◆ ExecuteCommand()

int dabc::Publisher::ExecuteCommand ( Command  cmd)
protectedvirtual

Main method where commands are executed.

Reimplemented from dabc::Worker.

Definition at line 620 of file Publisher.cxx.

◆ ReplyCommand()

bool dabc::Publisher::ReplyCommand ( Command  cmd)
protectedvirtual

Reimplement this method to react on command reply Return true if command can be destroyed by framework.

Reimplemented from dabc::Worker.

Definition at line 361 of file Publisher.cxx.

◆ CreateExeCmd()

dabc::Command dabc::Publisher::CreateExeCmd ( const std::string &  path,
const std::string &  query,
dabc::Command  tgt = nullptr 
)
protected

Definition at line 512 of file Publisher.cxx.

◆ CheckDnsSubscribers()

void dabc::Publisher::CheckDnsSubscribers ( )
protected

Definition at line 299 of file Publisher.cxx.

◆ InvalidateGlobal()

void dabc::Publisher::InvalidateGlobal ( )
protected

Method marks that global version is out of date and should be rebuild.

Definition at line 155 of file Publisher.cxx.

◆ ApplyEntryDiff()

bool dabc::Publisher::ApplyEntryDiff ( unsigned  recid,
dabc::Buffer buf,
uint64_t  version,
bool  witherror = false 
)
protected

Definition at line 312 of file Publisher.cxx.

◆ DoStorage()

bool dabc::Publisher::DoStorage ( ) const
inlineprotected

Definition at line 194 of file Publisher.h.

◆ GetWorkItem()

dabc::Hierarchy dabc::Publisher::GetWorkItem ( const std::string &  path,
bool *  islocal = nullptr 
)
protected

Return hierarchy item selected for work.

Definition at line 382 of file Publisher.cxx.

◆ RedirectCommand()

bool dabc::Publisher::RedirectCommand ( dabc::Command  cmd,
const std::string &  itemname 
)
protected

Command redirected to local modules or remote publisher, where it should be processed Primary usage - for GetBinary commands, but also for any extra requests.

Definition at line 452 of file Publisher.cxx.

◆ IdentifyItem()

bool dabc::Publisher::IdentifyItem ( bool  asproducer,
const std::string &  itemname,
bool &  islocal,
std::string &  producer_name,
std::string &  request_name 
)
protected

Try to find producer which potentially could deliver item It could happen that item is not exists in hierarchy, therefore shorter name will be tried.

Definition at line 394 of file Publisher.cxx.

◆ DfltName()

static const char* dabc::Publisher::DfltName ( )
inlinestatic

Definition at line 214 of file Publisher.h.

◆ ClassName()

virtual const char* dabc::Publisher::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::Worker.

Definition at line 216 of file Publisher.h.

Friends And Related Function Documentation

◆ PublisherRef

friend class PublisherRef
friend

Definition at line 148 of file Publisher.h.

Field Documentation

◆ fGlobal

Hierarchy dabc::Publisher::fGlobal
protected

Definition at line 152 of file Publisher.h.

◆ fLocal

Hierarchy dabc::Publisher::fLocal
protected

! this is hierarchy of all known items, including remote, used only when any global hierarchies are existing

Definition at line 154 of file Publisher.h.

◆ fLastLocalVers

uint64_t dabc::Publisher::fLastLocalVers
protected

! this is hierarchy only for entries from local modules

Definition at line 156 of file Publisher.h.

◆ fPublishers

PublishersList dabc::Publisher::fPublishers
protected

Definition at line 162 of file Publisher.h.

◆ fSubscribers

SubscribersList dabc::Publisher::fSubscribers
protected

Definition at line 164 of file Publisher.h.

◆ fCnt

unsigned dabc::Publisher::fCnt
protected

Definition at line 166 of file Publisher.h.

◆ fMgrPath

std::string dabc::Publisher::fMgrPath
protected

! counter for new records

Definition at line 168 of file Publisher.h.

◆ fMgrHiearchy

Hierarchy dabc::Publisher::fMgrHiearchy
protected

! path for manager

Definition at line 169 of file Publisher.h.

◆ fStoreDir

std::string dabc::Publisher::fStoreDir
protected

! this is manager hierarchy, published by ourselfs

Definition at line 171 of file Publisher.h.

◆ fStoreSel

std::string dabc::Publisher::fStoreSel
protected

! directory to store data

Definition at line 172 of file Publisher.h.

◆ fFileLimit

int dabc::Publisher::fFileLimit
protected

! selected hierarchy path for storage like 'MBS' or 'FESA/server'

Definition at line 173 of file Publisher.h.

◆ fTimeLimit

int dabc::Publisher::fTimeLimit
protected

! maximum size of store file, in MB

Definition at line 174 of file Publisher.h.

◆ fStorePeriod

double dabc::Publisher::fStorePeriod
protected

! maximum time of store file, in seconds

Definition at line 175 of file Publisher.h.


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