20 #include "dabc/defines.h"
23 #ifndef DABC_Reference
37 class ReferencesVector;
38 class HierarchyContainer;
146 bool DecReference(
bool ask_to_destroy,
bool do_decrement =
true,
bool from_thread =
false);
235 void FillFullName(std::string &fullname,
Object* upto,
bool exclude_top_parent =
false)
const;
264 static ConstructorPair
MakePair(
Reference prnt,
const std::string &fullname,
bool withmanager =
true);
268 static ConstructorPair
MakePair(
Object* prnt,
const std::string &fullname,
bool withmanager =
true);
272 static ConstructorPair
MakePair(
const std::string &fullname,
bool withmanager =
true);
310 bool IsName(
const char* str,
int len)
const;
395 virtual
void Print(
int lvl = 0);
403 std::
string ItemName(
bool compact = true) const;
419 virtual const
char*
ClassName()
const {
return "Object"; }
448 static bool NameMatch(
const std::string &name,
const std::string &mask);
453 static bool NameMatchM(
const std::string &name,
const std::string &mask);
455 #ifdef DABC_EXTRA_CHECKS
456 static void DebugObject(
const char* classname = 0,
Object* instance = 0,
int kind = 0);
461 void SetName(
const char* name);
Interface class between xml configuration and dabc objects.
Manager of everything in DABC
Base class for most of the DABC classes.
Reference fObjectParent
reference on the parent object
bool RemoveChild(Object *child, bool cleanup=true)
Detach child from parent object If cleanup==true and parent is owner of child, child will be destroye...
bool IsName(const char *str) const
Checks if object name is same as provided string, thread safe
void Destructor()
Destroys all internal data, reentrant.
bool IsOwner() const
Returns true if object is owner of its children, thread safe
bool IsTopXmlLevel() const
Return true if object should be searched in the top level of the xml file, thread safe
ReferencesVector * fObjectChilds
list of the child objects
virtual Object * CreateInstance(const std::string &name)
Method used to create new item to be placed as child of the object.
bool IncReference(bool withmutex=true)
Increments reference counter, return false if it cannot be done.
void FillFullName(std::string &fullname, Object *upto, bool exclude_top_parent=false) const
Method used to produce full item name,.
void SetFlag(unsigned fl, bool on=true)
Change value of selected flag, not thread safe
unsigned fObjectFlags
flag, protected by the mutex
std::string ItemName(bool compact=true) const
Produce string, which can be used as name argument in dabc::mgr.FindItem(name) call.
Object * GetParent() const
Returns pointer on parent object, thread safe
bool DecReference(bool ask_to_destroy, bool do_decrement=true, bool from_thread=false)
Decrements reference counter, return true if object must be destroyed.
unsigned NumReferences()
Return number of references on the object.
virtual void Print(int lvl=0)
Print object content on debug output.
void Constructor()
Initializes all variables of the object.
std::string fObjectName
object name
virtual bool DestroyByOwnThread()
Internal DABC method, used to activate object cleanup via object thread Returns: false - object canno...
bool GetFlag(unsigned fl) const
Return value of selected flag, not thread safe
bool RemoveChildAt(unsigned n, bool cleanup=true)
Detach child object from parent at specified position If cleanup==true and object is owner of child,...
virtual void _ChildsChanged()
Method called when new childs are add or old are removed.
Reference GetChildRef(unsigned n) const
returns reference on child object
static bool NameMatchM(const std::string &name, const std::string &mask)
Check if name matches to specified mask.
Mutex * fObjectMutex
mutex protects all private property of the object
void SetNameDirect(const char *name)
Changes object name disregard of existing references.
static unsigned gNumCreated
number of created instances, will used for object id
void SetState(EState st)
Set object state value.
Object(const ConstructorPair &pair, unsigned flags=flIsOwner)
void SetLogging(bool on=true)
Sets logging flag, thread safe
const char * GetName() const
Returns name of the object, thread safe
void SetAutoDestroy(bool on=true)
Set autodestroy flag for the object Once enabled, object will be destroyed when last reference will b...
Mutex * ObjectMutex() const
Returns mutex, used for protection of Object data members.
static void InspectGarbageCollector()
\ brief Methods to inspect how many objects pointers are remained
virtual void BuildFieldsMap(RecordFieldsMap *cont)
Fill fields map, which is relevant for the object Objects hierarchy produced from dabc::Manager.
int fObjectRefCnt
accounts how many references existing on the object, thread safe
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...
virtual void ObjectCleanup()
User method to cleanup object content before it will be destroyed Main motivation is to release any r...
bool DestroyCalledFromOwnThread()
Internal DABC method, should be called by thread which was requested to destroy object.
bool IsNormalState()
Return true if object is in normal state.
@ flChildsHidden
hide all childs from hierarchy scan
@ flTopXmlLevel
object (or folder) can be found on top xml level in the Context
@ flStateMask
use 4 bits for state
@ flNoMutex
object will be created without mutex, only can be used in constructor
@ flHasThread
flag indicates that object has thread and should be cleaned up via thread
@ flAutoDestroy
object will be automatically destroyed when no references exists, normally set in constructor,...
@ flIsOwner
flag indicates default ownership for child objects
@ flHidden
hide object from hierarchy scan
@ flLogging
object is marked to provide logging information, for debug purposes only
@ flCleanup
flag indicates that one should cleanup pointer from depended objects
bool IsParent(Object *obj) const
Checks if specified argument is in the list of object parents.
Reference GetFolder(const std::string &name, bool force=false)
Return folder of specified name, no special symbols allowed.
virtual bool _DoDeleteItself()
This method is called at the moment when DecReference think that object can be destroyed and wants to...
static bool NameMatch(const std::string &name, const std::string &mask)
Check if name matches to specified mask.
bool AddChild(Object *child, bool withmutex=true)
Add object to list of child objects, thread safe
Reference FindChildRef(const char *name, bool force=false) const
returns reference on child object with given name
bool _IsNormalState()
Same as IsNormalState() but without mutex lock - user should lock mutex himself.
static Reference SearchForChild(Reference &ref, const char *name, bool firsttime, bool force)
bool RemoveChilds(bool cleanup=true)
Remove all childs.
virtual const char * ClassName() const
Returns class name of the object instance.
static void Destroy(Object *obj)
User method for object destroyment.
static unsigned NumInstances()
Static variable counts total number of objects instances.
bool IsNameMatch(const std::string &mask) const
Check if object name match to the mask.
bool AddChildAt(Object *child, unsigned pos, bool withmutex=true)
Add object to list of child objects at specified position.
void SetOwner(bool on=true)
Specifies if object will be owner of its new childs.
EState GetState() const
Returns object state value.
bool IsChildsHidden() const
Return true if object wants to hide childs from hierarchy scan, thread safe
static unsigned gNumInstances
actual number of existing instances
bool GetAllChildRef(ReferencesVector *vect) const
bool IsName(const std::string &str) const
Checks if object name is same as provided string, thread safe
virtual bool Find(ConfigIO &cfg)
Method to locate object in xml file.
virtual void ObjectDestroyed(Object *)
Method called by the manager when registered dependent object is destroyed Should be used in user cla...
bool IsLogging() const
Return true if object selected for logging, thread safe
bool IsHidden() const
Return true if object wants to be hidden from hierarchy scan, thread safe
void SetCleanupBit()
Method set cleanup bit that object will be cleaned up in all registered objects Used only by manager ...
void DeleteThis()
Method should be used by the object to delete itself.
void SetName(const char *name)
Changes object name.
EState
These are object live stages.
@ stWaitForThread
object must be cleaned by the thread
@ stConstructor
state during constructor
@ stDestructor
state during destructor
@ stWaitForDestructor
one waits unit refcounter decreases
@ stDoingDestroy
we are inside destroy method
@ stNormal
state during object normal functioning
Reference GetParentRef() const
int fObjectBlock
counter for blocking calls, as long as non-zero, non of child can be removed
unsigned NumChilds() const
returns number of child objects
Object * FindChild(const char *name) const
returns pointer on child object with given name
Object * GetChild(unsigned n) const
returns pointer on child object
Reference on the arbitrary object
Vector of dabc::Reference objects.
const char * xmlBufferSize
const char * xmlNumOutputs
const char * xmlOutputQueueSize
const char * typeSocketThread
const char * xmlFixedLayout
const char * xmlNumSegments
const char * typeSocketDevice
const char * xmlInputMask
const char * xmlOutputMask
const char * xmlMcastAddr
const char * xmlConnectionNode
const char * xmlAlignment
const char * xmlSignalAttr
const char * xmlUseAcknowledge
const char * xmlFlushTimeout
const char * xmlOutputPrefix
const char * xmlInputQueueSize
const char * xmlCleanupTimeout
const char * xmlInlineDataSize
const char * xmlMemoryPoolNode
const char * xmlNumBuffers
const char * xmlMcastPort
const char * xmlModuleNode
const char * xmlConnTimeout
const char * xmlFileNumber
const char * xmlFileSizeLimit
const char * xmlInputPrefix
const char * xmlMcastRecv
const char * xmlQueueAttr
const char * xmlDeviceNode
const char * xmlThreadNode
const char * xmlNumInputs
const char * typeApplication
Structure used to specify arguments for object constructor.
ConstructorPair(const ConstructorPair &src)