16 #ifndef DABC_Hierarchy
17 #define DABC_Hierarchy
85 uint64_t
StoreSize(uint64_t version,
int hist_limit = -1);
91 if (
fArr.Size()==0)
return nullptr;
105 if (sz>0)
GetObject()->fArr.Allocate(sz);
119 class HistoryIterContainer;
206 void SetModified(
bool node,
bool hierarchy,
bool recursive =
false);
226 void MarkReading(
bool withchilds,
bool readvalues,
bool readchilds);
249 virtual bool SaveTo(
HStore& res,
bool create_node =
true);
255 virtual const char*
ClassName()
const {
return "Hierarchy"; }
290 void Create(
const std::string &name,
bool withmutex =
false);
323 void EnableHistory(
unsigned length = 100,
bool withchilds =
false);
356 bool IsBinItemChanged(
const std::string &itemname, uint64_t hash, uint64_t last_version = 0);
359 bool FillBinHeader(
const std::string &itemname,
dabc::Command& cmd, uint64_t mhash = 0,
const std::string &dflt_master_name =
"");
388 Hierarchy GetHChild(
const std::string &name,
bool allowslahes =
false,
bool force =
false,
bool sortorder =
false);
393 {
return GetHChild(name, allowslahes,
true, sortorder); }
396 bool RemoveHChild(
const std::string &name,
bool allowslahes =
false);
#define DABC_REFERENCE(RefClass, ParentClass, T)
Reference on memory from memory pool.
Represents command with its arguments.
class, used for direct store of records in JSON/XML form
bool fChildsChanged
indicate if something was changed in the hierarchy
HierarchyContainer(const std::string &name)
uint64_t fChildsVersion
Version of hierarchy structure Childs version is changed when any childs is changed or inserted/remov...
uint64_t GetNextVersion() const
unsigned MarkVersionIfChanged(uint64_t ver, uint64_t &tm, bool withchilds)
If item changed, marked with version, time stamp applied, history recording returns mask with changes...
uint64_t fNamesVersion
Version used in DNS requests.
void AddHistory(RecordFieldsMap *diff)
Add new entry to history.
bool fPermanent
indicate that item is permanent and should be excluded from update
bool CheckIfDoingHistory()
Return true if history activated for the node If necessary, history object will be initialized.
uint64_t GetChildsVersion() const
History fHist
special object with history data
void ClearHistoryEntries()
Clear all entries in history, but not history object itself.
HierarchyContainer * TopParent()
bool ExtractHistoryStep(RecordFieldsMap *fields, unsigned step)
Extract values of specified history step.
HierarchyContainer * CreateChildAt(const std::string &name, int indx)
Create child with specified name.
bool fAutoTime
when enabled, by node change (not hierarchy) time attribute will be set
bool fDisableChildsReading
when true, non of childs should be read
bool fNodeChanged
indicate if something was changed in the node during update
Mutex * fHierarchyMutex
mutex, which should be use for access to hierarchy and all its childs
void SetModified(bool node, bool hierarchy, bool recursive=false)
Switch on node or hierarchy modified flags.
uint64_t GetVersion() const
bool DuplicateHierarchyFrom(HierarchyContainer *cont)
Duplicate hierarchy from provided container.
void MarkReading(bool withchilds, bool readvalues, bool readchilds)
Mark reading flags.
void EnableTimeRecording(bool withchilds=true)
Enable time recording for hierarchy element every time when item is changed.
virtual ~HierarchyContainer()
bool fDisableDataReading
when true, non of data (fields and history) need to be read in streamer
void SetVersion(uint64_t v)
virtual Object * CreateInstance(const std::string &name)
Method used to create new item to be placed as child of the object.
bool UpdateHierarchyFrom(HierarchyContainer *cont)
Update hierarchy from provided container.
bool Stream(iostream &s, unsigned kind=stream_Full, uint64_t v=0, unsigned hist_limit=0)
bool fDisableReadingAsChild
when true, object will not be updated when provided as child
uint64_t fNodeVersion
Version number of the node Any changes in the node will cause changes of the version.
virtual void _ChildsChanged()
Method called when new childs are add or old are removed.
virtual bool SaveTo(HStore &res, bool create_node=true)
Save hierarchy in json/xml form.
bool fNamesChanged
indicate if DNS structure was changed (either childs or relevant dabc fields)
void BuildObjectsHierarchy(const Reference &top)
void MarkChangedItems(uint64_t tm=0)
Central method, which analyzes all possible changes in node (and its childs) If any changes found,...
Buffer fBinData
binary data, assigned with element
bool IsNodeChanged(bool withchilds=true)
Returns true if any node field was changed or removed/inserted If specified, all childs will be check...
virtual const char * ClassName() const
Returns class name of the object instance.
uint64_t StoreSize(unsigned kind=stream_Full, uint64_t v=0, unsigned hist_limit=0)
Represents objects hierarchy of remote (or local) DABC process.
bool IsBinItemChanged(const std::string &itemname, uint64_t hash, uint64_t last_version=0)
Return true if one could suppose that binary item is changed and binary data must be regenerated.
void DisableReading(bool withchlds=true)
Mark all elements that non of data will be read.
bool FillBinHeader(const std::string &itemname, dabc::Command &cmd, uint64_t mhash=0, const std::string &dflt_master_name="")
Fill binary header with item and master versions.
Hierarchy GetTop() const
Returns reference on the top element of the hierarchy.
void DisableReadingAsChild()
Disable reading of element when it appears as child in the structure.
Hierarchy FindMaster() const
Find master item It is used in ROOT to specify position of streamer info.
bool HasLocalHistory() const
Returns true if item records history local, no need to request any other sources.
void EnableTimeRecording(bool withchilds=true)
Enable time recording for hierarchy element every time when item is changed.
void MarkChangedItems(uint64_t tm=0)
If any field was modified, item will be marked with new version.
uint64_t GetVersion() const
Returns actual version of hierarchy entry.
bool Duplicate(const Hierarchy &src)
Duplicate hierarchy from the source.
Hierarchy FindChild(const char *name)
Return child element from hierarchy.
bool RemoveHChild(const std::string &name, bool allowslahes=false)
Delete H item, including all empty parent folders.
bool IsAnyFieldChanged() const
Hierarchy CreateHChild(const std::string &name, bool allowslahes=false, bool sortorder=false)
Create child item in hierarchy with specified name If allowslahes enabled, instead of subfolders item...
std::string ItemName() const
Name which is used as item name in hierarchy.
bool DettachFromParent()
Detach from parent object.
const RecordField & Field(const std::string &name) const
Hierarchy GetHChild(const std::string &name, bool allowslahes=false, bool force=false, bool sortorder=false)
Return child, if necessary creates with full subfolder If force specified, missing childs and folders...
HistoryIter MakeHistoryIter()
Produce history iterator.
Hierarchy CreateFolder(const std::string &name)
Create folder in hierarchy, one could use it to add new childs to it.
bool RemoveEmptyFolders(const std::string &path)
Removes folder and its parents as long as no other childs are present.
void EnableReading(const Hierarchy &upto=nullptr)
Enable element and all its parents to read data.
void Create(const std::string &name, bool withmutex=false)
Create top-level object with specified name.
void SetPermanent(bool on=true)
Mark item as permanent - it will not be touched when update from other places will be done.
Mutex * GetHMutex() const
std::string FindBinaryProducer(std::string &request_name, bool topmost=true)
Search for parent element, where binary_producer property is specified Returns name of binary produce...
bool UpdateFromBuffer(const dabc::Buffer &buf, HierarchyStreamKind kind=stream_Full)
Apply modification to hierarchy, using stored binary data
bool HasActualRemoteHistory() const
Returns true if remote history is recorded and it is up-to-date.
bool ReadFromBuffer(const dabc::Buffer &buf)
Read hierarchy from buffer.
bool Update(Hierarchy &src)
Reconstruct complete hierarchy, setting node/structure modifications fields correctly.
void BuildNew(Reference top)
Build objects hierarchy, referenced by top.
void SetVersion(uint64_t v)
Change version of the item, only for advanced usage.
void EnableHistory(unsigned length=100, bool withchilds=false)
Activate history production for selected element and its childs.
uint64_t fRemoteReqVersion
last version, which was taken from remote
RecordFieldsMap * TakeNext()
bool fChildsEnabled
true if history recording also was enabled for childs
bool Stream(iostream &s, uint64_t version, int hist_limit=-1)
bool fEnabled
indicates if history recording is enabled
bool fCrossBoundary
flag set when recover from binary, indicates that history is complete for specified version
RecordFieldsMap * fPrev
map with previous set of attributes
uint64_t StoreSize(uint64_t version, int hist_limit=-1)
virtual ~HistoryContainer()
uint64_t fLocalReqVersion
local version, when request was done
RecordsQueue< HistoryItem > fArr
container with history items
void Allocate(unsigned sz=0)
unsigned Capacity() const
Base class for most of the DABC classes.
@ flAutoDestroy
object will be automatically destroyed when no references exists, normally set in constructor,...
@ flIsOwner
flag indicates default ownership for child objects
Container for records fields.
dabc::Buffer SaveToBuffer()
Template of queue with complex objects.
Reference on the arbitrary object
void SetObject(Object *obj, bool withmutex=true)
Direct set of object to reference.
Object * GetObject() const
Return pointer on the object.
Reference FindChild(const char *name) const
Searches for child in referenced object.
class to stream binary data
const char * prop_realname
const char * prop_masteritem
const char * prop_producer
const char * prop_history
const char * prop_version
uint64_t version
version number
RecordFieldsMap * fields
all fields, which are preserved