DABC (Data Acquisition Backbone Core)  2.9.9
Record.h
Go to the documentation of this file.
1 // $Id: Record.h 4472 2020-04-15 13:33:18Z linev $
2 
3 /************************************************************
4  * The Data Acquisition Backbone Core (DABC) *
5  ************************************************************
6  * Copyright (C) 2009 - *
7  * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
8  * Planckstr. 1, 64291 Darmstadt, Germany *
9  * Contact: http://dabc.gsi.de *
10  ************************************************************
11  * This software can be used under the GPL license *
12  * agreements as stated in LICENSE.txt file *
13  * which is part of the distribution. *
14  ************************************************************/
15 
16 #ifndef DABC_Record
17 #define DABC_Record
18 
19 #ifndef DABC_Object
20 #include "dabc/Object.h"
21 #endif
22 
23 #ifndef DABC_Buffer
24 #include "dabc/Buffer.h"
25 #endif
26 
27 #include <vector>
28 #include <map>
29 
30 namespace dabc {
31 
32  class ConfigIO;
33  class DateTime;
34 
35  // =================================================================================
36 
37  class RecordFieldsMap;
38 
41  class iostream {
42  protected:
43  bool fInput;
44 
46  virtual uint64_t tmpbuf_size() const { return 0; }
48  virtual char* tmpbuf() const { return 0; }
49 
50  iostream() : fInput(false) { }
51  iostream(bool isinp) : fInput(isinp) { }
52 
53  public:
54  virtual ~iostream() {}
55 
56  bool is_input() const { return fInput; }
57  bool is_output() const { return !fInput; }
58  virtual bool is_real() const { return true; }
59 
63  bool skip_object();
64 
65  bool verify_size(uint64_t pos, uint64_t sz);
66 
67  virtual bool write(const void* src, uint64_t len) { return false; }
68  virtual bool read(void* tgt, uint64_t len) { return false; }
69  virtual bool shift(uint64_t len) { return false; }
71  virtual uint64_t size() const { return 0; }
72 
74  virtual uint64_t maxstoresize() const { return 0; }
75 
76  bool write_int32(int32_t v) { return write(&v, sizeof(int32_t)); }
77  bool write_uint32(uint32_t v) { return write(&v, sizeof(uint32_t)); }
78  bool write_int64(int64_t v) { return write(&v, sizeof(int64_t)); }
79  bool write_uint64(uint64_t v) { return write(&v, sizeof(uint64_t)); }
80  bool write_double(double v) { return write(&v, sizeof(double)); }
81 
82  bool read_int32(int32_t& v) { return read(&v, sizeof(int32_t)); }
83  bool read_uint32(uint32_t& v) { return read(&v, sizeof(uint32_t)); }
84  bool read_int64(int64_t& v) { return read(&v, sizeof(int64_t)); }
85  bool read_uint64(uint64_t& v) { return read(&v, sizeof(uint64_t)); }
86  bool read_double(double& v) { return read(&v, sizeof(double)); }
87 
88 
90  static uint64_t str_storesize(const std::string &str);
91 
93  bool write_str(const std::string &str);
94 
96  bool read_str(std::string& str);
97  };
98 
99  // ===================================================================================
100 
102  class sizestream : public iostream {
103  protected:
104  uint64_t fLength;
105 
106  public:
107 
109  iostream(false),
110  fLength(0)
111  {
112  }
113 
114  virtual ~sizestream() {}
115 
116  virtual uint64_t size() const { return fLength; }
117  virtual uint64_t maxstoresize() const { return 0xffffffffLLU; }
118 
119  virtual bool is_real() const { return false; }
120 
121  virtual bool shift(uint64_t len) { fLength += len; return true; }
122 
123  virtual bool write(const void* src, uint64_t len) { fLength += len; return true; }
124 
125  virtual bool read(void* tgt, uint64_t len) { return true; }
126 
127  };
128 
129  // ===================================================================================
130 
133  class memstream : public iostream {
134  protected:
135  char* fMem;
136  uint64_t fLength;
137  char* fCurr;
138  uint64_t fRemains;
139 
140  virtual uint64_t tmpbuf_size() const { return fRemains; }
141  virtual char* tmpbuf() const { return fCurr; }
142 
143  public:
144 
145  virtual uint64_t size() const { return fCurr - fMem; }
146  virtual uint64_t maxstoresize() const { return fRemains; }
147 
148  virtual bool shift(uint64_t len);
149  virtual bool write(const void* src, uint64_t len);
150  virtual bool read(void* tgt, uint64_t len);
151 
152  memstream(bool isinp, char* buf, uint64_t len) :
153  iostream(isinp),
154  fMem(buf),
155  fLength(len),
156  fCurr(buf),
157  fRemains(len)
158  {
159  }
160 
161  virtual ~memstream() {}
162  };
163 
164  // ===================================================================================
165 
166 
167  enum HStoreMask {
168  storemask_Compact = 0x03, // 0..3 level of compactness
169  storemask_Version = 0x04, // write all versions
170  storemask_TopVersion = 0x08, // write version only for top node
171  storemask_History = 0x10, // write full history in the output
173  storemask_AsXML = 0x80 // create XML output
174  };
175 
176  // ===================================================================================
177 
179  class HStore {
180  protected:
181  unsigned fMask;
182  std::string buf;
183  int lvl;
184  std::vector<int> numflds;
185  std::vector<int> numchilds;
186  uint64_t fVersion;
187  unsigned fHLimit;
189 
190  unsigned compact() const { return mask() & storemask_Compact; }
191 
192  void NewLine()
193  {
194  if (compact()<2) buf.append("\n"); else
195  if (compact()<3) buf.append(" ");
196  }
197 
198  bool isxml() { return (mask() & storemask_AsXML) != 0; }
199 
200  public:
201  HStore(unsigned m = 0) : fMask(m), buf(), lvl(0), numflds(), numchilds(), fVersion(0), fHLimit(0), first_node(true) {}
202  virtual ~HStore() {}
203 
204  void SetLimits(uint64_t v, unsigned hlimit) { fVersion = v; fHLimit = hlimit; }
205 
206  unsigned mask() const { return fMask; }
207  void SetMask(unsigned m) { fMask = m; }
208 
209  uint64_t version() const { return fVersion; }
210  unsigned hlimit() const { return fHLimit; }
211 
212  std::string GetResult() { return buf; }
213 
214  void CreateNode(const char * nodename);
215  void SetField(const char * name, const char * value);
216  void BeforeNextChild(const char* basename = 0);
217  void CloseChilds();
218  void CloseNode(const char * nodename);
219  };
220 
221  // =========================================================
222 
223  class RecordField {
224  friend class RecordFieldsMap;
225 
226  protected:
227  enum ValueKind {
230  kind_int = 2,
240  kind_reference = 12
241  };
242 
244 
245  union {
246  int64_t valueInt;
247  uint64_t valueUInt;
248  double valueDouble;
249  };
250 
251  union {
252  int64_t* arrInt;
253  uint64_t* arrUInt;
254  double* arrDouble;
255  char* valueStr;
258  };
259 
260  bool fModified;
261  bool fTouched;
262  bool fProtected;
263 
264  void release();
265 
266  bool modified(bool reallychanged = true)
267  {
268  if (reallychanged) fModified = true;
269  return true;
270  }
271 
272  bool isreadonly() const { return false; }
273  bool cannot_modify();
274 
275  void SetArrStrDirect(int64_t size, char* arr, bool owner = false);
276 
277  void constructor() { fKind = kind_none; fModified = false; fTouched = false; fProtected = false; }
278 
279  public:
280  RecordField();
281  RecordField(const RecordField& src);
282  RecordField(const char* v) { constructor(); SetStr(v); }
283  RecordField(const std::string &v) { constructor(); SetStr(v); }
284  RecordField(const int& v) { constructor(); SetInt(v); }
285  RecordField(const int64_t& v) { constructor(); SetInt(v); }
286  RecordField(const unsigned& v) { constructor(); SetUInt(v); }
287  RecordField(const uint64_t& v) { constructor(); SetUInt(v); }
288  RecordField(const double& v) { constructor(); SetDouble(v); }
289  RecordField(const bool& v) { constructor(); SetBool(v); }
291  RecordField(const std::vector<int64_t>& v) { constructor(); SetVectInt(v); }
292  RecordField(const std::vector<uint64_t>& v) { constructor(); SetVectUInt(v); }
293  RecordField(const std::vector<double>& v) { constructor(); SetVectDouble(v); }
294  RecordField(const std::vector<std::string>& v) { constructor(); SetStrVect(v); }
295  RecordField(const Buffer& buf) { constructor(); SetBuffer(buf); }
297 
298  RecordField& operator=(const RecordField& src) { SetValue(src); return *this; }
299 
300  virtual ~RecordField();
301 
302  bool null() const { return fKind == kind_none; }
303 
304  bool IsModified() const { return fModified; }
305  void SetModified(bool on = true) { fModified = on; }
306 
307  bool IsProtected() const { return fProtected; }
308  void SetProtected(bool on = true) { fProtected = on; }
309 
310  bool IsArray() const
311  {
312  return (fKind == kind_arrint) ||
313  (fKind == kind_arruint) ||
314  (fKind == kind_arrdouble) ||
315  (fKind == kind_arrstr);
316  }
317  int64_t GetArraySize() const { return IsArray() ? valueInt : -1; }
318 
319  bool AsBool(bool dflt = false) const;
320  int64_t AsInt(int64_t dflt = 0) const;
321  uint64_t AsUInt(uint64_t dflt = 0) const;
322  double AsDouble(double dflt = 0.) const;
323  std::string AsStr(const std::string &dflt = "") const;
324  std::vector<int64_t> AsIntVect() const;
325  int64_t* GetIntArr() const { return fKind == kind_arrint ? arrInt : 0; }
326  std::vector<uint64_t> AsUIntVect() const;
327  uint64_t* GetUIntArr() const { return fKind == kind_arruint ? arrUInt : 0; }
328  std::vector<double> AsDoubleVect() const;
329  double* GetDoubleArr() const { return fKind == kind_arrdouble ? arrDouble : 0; }
330  std::vector<std::string> AsStrVect() const;
331  dabc::Buffer AsBuffer() const;
333 
335  std::string AsJson() const;
336 
337  bool SetValue(const RecordField& src);
338  bool SetNull();
339  bool SetBool(bool v);
340  bool SetInt(int64_t v);
341  bool SetDatime(uint64_t v);
342  bool SetDatime(const DateTime& v);
343  bool SetUInt(uint64_t v);
344  bool SetDouble(double v);
345  bool SetStr(const std::string &v);
346  bool SetStr(const char* v);
347  bool SetStrVect(const std::vector<std::string>& vect);
348  bool SetBuffer(const Buffer& buf);
349  bool SetReference(const Reference& ref);
350 
352  bool SetArrInt(int64_t size, int64_t* arr, bool owner = false);
353  bool SetVectInt(const std::vector<int64_t>& v);
355  bool SetArrUInt(int64_t size, uint64_t* arr, bool owner = false);
356  bool SetVectUInt(const std::vector<uint64_t>& v);
358  bool SetArrDouble(int64_t size, double* arr, bool owner = false);
359  bool SetVectDouble(const std::vector<double>& v);
360 
362  bool SetArrStr(int64_t size, char* arr, bool owner = false);
363 
365  uint64_t StoreSize();
366  bool Stream(iostream& s);
367 
368  static bool NeedJsonReformat(const std::string &str);
369  static std::string JsonReformat(const std::string &str);
370 
371  static bool StrToStrVect(const char* str, std::vector<std::string>& vect, bool verbose = true);
372  };
373 
375  protected:
376  typedef std::map<std::string, dabc::RecordField> FieldsMap;
377 
379 
380  bool fChanged;
381 
382  void clear() { fMap.clear(); }
383 
384  static bool match_prefix(const std::string &name, const std::string &prefix);
385 
386  public:
387 
388  RecordFieldsMap();
389  virtual ~RecordFieldsMap();
390 
391  uint64_t StoreSize(const std::string &nameprefix = "");
392  bool Stream(iostream& s, const std::string &nameprefix = "");
393 
394  bool HasField(const std::string &name) const;
395  bool RemoveField(const std::string &name);
396 
397  unsigned NumFields() const { return fMap.size(); }
398  std::string FieldName(unsigned n) const;
399 
401  RecordField& Field(const std::string &name) { return fMap[name]; }
402 
404  bool SaveTo(HStore& res);
405 
407  void CopyFrom(const RecordFieldsMap& src, bool overwrite = true);
408 
410  void MoveFrom(RecordFieldsMap& src);
411 
414  void MakeAsDiffTo(const RecordFieldsMap& src);
415 
418  void ApplyDiff(const RecordFieldsMap& diff);
419 
422 
424  bool WasChanged() const;
425 
427  bool WasChangedWith(const std::string &prefix);
428 
430  void ClearChangeFlags();
431  };
432 
433  // ===========================================================================
434 
440  class RecordContainer : public Object {
441  friend class Record;
442  friend class RecordField;
443  friend class ConfigIO;
444  friend class RecordFieldsMap;
445 
446  protected:
448 
449  RecordContainer(const std::string &name, unsigned flags = flIsOwner);
450 
451  RecordContainer(Reference parent, const std::string &name, unsigned flags = flIsOwner);
452 
456 
458  void SetFieldsMap(RecordFieldsMap* newmap);
459 
460  virtual bool HasField(const std::string &name) const
461  { return Fields().HasField(name); }
462 
463  virtual bool RemoveField(const std::string &name)
464  { return Fields().RemoveField(name); }
465 
466  virtual unsigned NumFields() const
467  { return Fields().NumFields(); }
468 
469  virtual std::string FieldName(unsigned cnt) const
470  { return Fields().FieldName(cnt); }
471 
472  virtual RecordField GetField(const std::string &name) const
473  { return Fields().Field(name); }
474 
475  virtual bool SetField(const std::string &name, const RecordField& v)
476  { return Fields().Field(name).SetValue(v); }
477 
478  virtual bool SaveTo(HStore& store, bool create_node = true);
479 
480  public:
481 
482  virtual ~RecordContainer();
483 
484  virtual const char* ClassName() const { return "Record"; }
485 
486  virtual void Print(int lvl = 0);
487 
488  RecordFieldsMap& Fields() const { return *fFields; }
489  };
490 
491  // ===================================================================================
492 
493 
494  class Record : public Reference {
495 
497 
498  bool HasField(const std::string &name) const
499  { return null() ? false : GetObject()->HasField(name); }
500 
501  bool RemoveField(const std::string &name)
502  { return null() ? false : GetObject()->RemoveField(name); }
503 
504  unsigned NumFields() const
505  { return null() ? 0 : GetObject()->NumFields(); }
506 
507  std::string FieldName(unsigned cnt) const
508  { return null() ? std::string() : GetObject()->FieldName(cnt); }
509 
510  RecordField GetField(const std::string &name) const
511  { return null() ? RecordField() : GetObject()->GetField(name); }
512 
513  RecordField* GetFieldPtr(const std::string &name) const
514  { return HasField(name) ? &(GetObject()->Fields().Field(name)) : 0; }
515 
516  bool SetField(const std::string &name, const RecordField &v)
517  { return null() ? false : GetObject()->SetField(name, v); }
518 
519  bool SetFieldModified(const std::string &name, bool on = true)
520  {
521  if (!HasField(name)) return false;
522  GetObject()->Fields().Field(name).SetModified(on);
523  return true;
524  }
525 
526  bool SetFieldProtected(const std::string &name, bool on = true)
527  {
528  if (!HasField(name)) return false;
529  GetObject()->Fields().Field(name).SetProtected(on);
530  return true;
531  }
532 
534  bool SaveTo(HStore &store, bool create_node = true)
535  { return null() ? false : GetObject()->SaveTo(store, create_node); }
536 
538  std::string SaveToJson(unsigned mask = 0);
539 
541  std::string SaveToXml(unsigned mask = 0);
542 
543  bool Stream(iostream &s);
544 
546 
547  bool ReadFromBuffer(const dabc::Buffer &buf);
548 
549  virtual void CreateRecord(const std::string &name);
550 
551  };
552 
553 }
554 
555 #endif
#define DABC_REFERENCE(RefClass, ParentClass, T)
Definition: Reference.h:222
Reference on memory from memory pool.
Definition: Buffer.h:135
Interface class between xml configuration and dabc objects.
Definition: ConfigIO.h:38
Class for holding GMT time with precision of nanoseconds.
Definition: timing.h:190
class, used for direct store of records in JSON/XML form
Definition: Record.h:179
void SetLimits(uint64_t v, unsigned hlimit)
Definition: Record.h:204
bool first_node
Definition: Record.h:188
unsigned hlimit() const
Definition: Record.h:210
unsigned fMask
Definition: Record.h:181
std::string buf
Definition: Record.h:182
void CloseNode(const char *nodename)
Definition: Record.cxx:221
virtual ~HStore()
Definition: Record.h:202
HStore(unsigned m=0)
Definition: Record.h:201
void SetField(const char *name, const char *value)
Definition: Record.cxx:170
unsigned compact() const
Definition: Record.h:190
std::vector< int > numchilds
Definition: Record.h:185
void CloseChilds()
Definition: Record.cxx:277
bool isxml()
Definition: Record.h:198
std::vector< int > numflds
Definition: Record.h:184
void BeforeNextChild(const char *basename=0)
Definition: Record.cxx:247
std::string GetResult()
Definition: Record.h:212
unsigned mask() const
Definition: Record.h:206
void SetMask(unsigned m)
Definition: Record.h:207
uint64_t fVersion
Definition: Record.h:186
unsigned fHLimit
Definition: Record.h:187
uint64_t version() const
Definition: Record.h:209
void CreateNode(const char *nodename)
Definition: Record.cxx:145
void NewLine()
Definition: Record.h:192
Base class for most of the DABC classes.
Definition: Object.h:116
@ flIsOwner
flag indicates default ownership for child objects
Definition: Object.h:164
Container for records fields.
Definition: Record.h:440
virtual ~RecordContainer()
Definition: Record.cxx:1615
virtual RecordField GetField(const std::string &name) const
Definition: Record.h:472
RecordFieldsMap * TakeFieldsMap()
Remove map and returns to the user.
Definition: Record.cxx:1620
RecordContainer(const std::string &name, unsigned flags=flIsOwner)
Definition: Record.cxx:1603
virtual const char * ClassName() const
Returns class name of the object instance.
Definition: Record.h:484
virtual bool HasField(const std::string &name) const
Definition: Record.h:460
void SetFieldsMap(RecordFieldsMap *newmap)
Replaces existing fields map.
Definition: Record.cxx:1627
virtual bool SetField(const std::string &name, const RecordField &v)
Definition: Record.h:475
virtual bool RemoveField(const std::string &name)
Definition: Record.h:463
virtual bool SaveTo(HStore &store, bool create_node=true)
Definition: Record.cxx:1645
RecordFieldsMap & Fields() const
Definition: Record.h:488
virtual void Print(int lvl=0)
Print object content on debug output.
Definition: Record.cxx:1634
virtual std::string FieldName(unsigned cnt) const
Definition: Record.h:469
virtual unsigned NumFields() const
Definition: Record.h:466
RecordFieldsMap * fFields
Definition: Record.h:447
bool SetUInt(uint64_t v)
Definition: Record.cxx:1101
bool SetArrUInt(int64_t size, uint64_t *arr, bool owner=false)
Set as array, if owner flag specified, one get ownership over array and do not need to create copy.
Definition: Record.cxx:1263
bool fTouched
! when true, field was modified at least once
Definition: Record.h:261
bool Stream(iostream &s)
Definition: Record.cxx:343
bool SetArrInt(int64_t size, int64_t *arr, bool owner=false)
Set as array, if owner flag specified, one get ownership over array and do not need to create copy.
Definition: Record.cxx:1224
void SetArrStrDirect(int64_t size, char *arr, bool owner=false)
Definition: Record.cxx:1347
RecordField(const std::vector< std::string > &v)
Definition: Record.h:294
RecordField(const int &v)
Definition: Record.h:284
RecordField(const double &v)
Definition: Record.h:288
RecordField(const Buffer &buf)
Definition: Record.h:295
virtual ~RecordField()
Definition: Record.cxx:331
bool SetVectInt(const std::vector< int64_t > &v)
Definition: Record.cxx:1251
RecordField(const std::vector< uint64_t > &v)
Definition: Record.h:292
Reference * valueRef
! buffer object
Definition: Record.h:257
RecordField(const char *v)
Definition: Record.h:282
bool SetStr(const std::string &v)
Definition: Record.cxx:1127
bool SetDatime(uint64_t v)
Definition: Record.cxx:1083
uint64_t * arrUInt
! int array, size in valueInt
Definition: Record.h:253
std::vector< uint64_t > AsUIntVect() const
Definition: Record.cxx:631
static std::string JsonReformat(const std::string &str)
Definition: Record.cxx:813
bool cannot_modify()
Definition: Record.cxx:302
std::vector< std::string > AsStrVect() const
Definition: Record.cxx:923
ValueKind fKind
Definition: Record.h:243
uint64_t valueUInt
scalar int type
Definition: Record.h:247
uint64_t AsUInt(uint64_t dflt=0) const
Definition: Record.cxx:525
bool SetBool(bool v)
Definition: Record.cxx:1060
RecordField(const Reference &ref)
Definition: Record.h:296
dabc::Reference AsReference() const
Definition: Record.cxx:976
RecordField(const unsigned &v)
Definition: Record.h:286
bool IsModified() const
Definition: Record.h:304
double * arrDouble
! uint array, size in valueInt
Definition: Record.h:254
int64_t GetArraySize() const
Definition: Record.h:317
std::vector< int64_t > AsIntVect() const
Definition: Record.cxx:573
int64_t * GetIntArr() const
Definition: Record.h:325
bool SetVectUInt(const std::vector< uint64_t > &v)
Definition: Record.cxx:1287
double * GetDoubleArr() const
Definition: Record.h:329
bool SetDouble(double v)
Definition: Record.cxx:1114
dabc::Buffer AsBuffer() const
Definition: Record.cxx:969
bool SetArrDouble(int64_t size, double *arr, bool owner=false)
Set as array, if owner flag specified, one get ownership over array and do not need to create copy.
Definition: Record.cxx:1312
int64_t * arrInt
Definition: Record.h:252
double valueDouble
scalar unsigned int type
Definition: Record.h:248
std::string AsJson() const
Returns field value in JSON format.
Definition: Record.cxx:835
bool SetReference(const Reference &ref)
Definition: Record.cxx:1210
bool SetStrVect(const std::vector< std::string > &vect)
Definition: Record.cxx:1162
bool AsBool(bool dflt=false) const
Definition: Record.cxx:477
std::string AsStr(const std::string &dflt="") const
Definition: Record.cxx:749
bool SetVectDouble(const std::vector< double > &v)
Definition: Record.cxx:1299
RecordField(const DateTime &v)
Definition: Record.h:290
bool IsProtected() const
Definition: Record.h:307
static bool NeedJsonReformat(const std::string &str)
Definition: Record.cxx:792
int64_t AsInt(int64_t dflt=0) const
Definition: Record.cxx:501
double AsDouble(double dflt=0.) const
Definition: Record.cxx:549
uint64_t * GetUIntArr() const
Definition: Record.h:327
bool SetArrStr(int64_t size, char *arr, bool owner=false)
Sets as array of string, placed one after another in memory.
Definition: Record.cxx:1336
RecordField(const std::vector< int64_t > &v)
Definition: Record.h:291
std::vector< double > AsDoubleVect() const
Definition: Record.cxx:691
void SetProtected(bool on=true)
Definition: Record.h:308
bool SetValue(const RecordField &src)
Definition: Record.cxx:1030
RecordField(const uint64_t &v)
Definition: Record.h:287
bool modified(bool reallychanged=true)
Definition: Record.h:266
char * valueStr
! double array, size in valueInt
Definition: Record.h:255
int64_t valueInt
Definition: Record.h:246
bool SetBuffer(const Buffer &buf)
Definition: Record.cxx:1197
Buffer * valueBuf
! string or array of strings
Definition: Record.h:256
void constructor()
Definition: Record.h:277
bool SetInt(int64_t v)
Definition: Record.cxx:1073
static bool StrToStrVect(const char *str, std::vector< std::string > &vect, bool verbose=true)
Definition: Record.cxx:983
uint64_t StoreSize()
Definition: Record.cxx:336
bool isreadonly() const
Definition: Record.h:272
RecordField(const std::vector< double > &v)
Definition: Record.h:293
RecordField(const bool &v)
Definition: Record.h:289
RecordField & operator=(const RecordField &src)
Definition: Record.h:298
RecordField(const int64_t &v)
Definition: Record.h:285
bool fProtected
! flag, used to detect in streamer when field was touched at all
Definition: Record.h:262
void release()
! when true, field will not be automatically deleted when full list updated from other hierarchy
Definition: Record.cxx:456
RecordField(const std::string &v)
Definition: Record.h:283
bool IsArray() const
Definition: Record.h:310
void SetModified(bool on=true)
Definition: Record.h:305
RecordFieldsMap * Clone()
Create complete copy of fields map.
Definition: Record.cxx:1440
virtual ~RecordFieldsMap()
Definition: Record.cxx:1378
bool fChanged
true when field was removed
Definition: Record.h:380
std::string FieldName(unsigned n) const
Definition: Record.cxx:1397
uint64_t StoreSize(const std::string &nameprefix="")
Definition: Record.cxx:1450
std::map< std::string, dabc::RecordField > FieldsMap
Definition: Record.h:376
void ApplyDiff(const RecordFieldsMap &diff)
Apply diff map One should use fields, generated with MakeAsDiffTo call.
Definition: Record.cxx:1586
unsigned NumFields() const
Definition: Record.h:397
bool WasChanged() const
Return true if any field was changed or map was modified (removed filed)
Definition: Record.cxx:1409
void CopyFrom(const RecordFieldsMap &src, bool overwrite=true)
Copy fields from source map.
Definition: Record.cxx:1543
bool HasField(const std::string &name) const
Definition: Record.cxx:1382
void MakeAsDiffTo(const RecordFieldsMap &src)
In the map only modified fields are remained Also dabc:delete field can appear which marks all remove...
Definition: Record.cxx:1570
void MoveFrom(RecordFieldsMap &src)
Move fields from source map, delete no longer existing (except protected)
Definition: Record.cxx:1550
RecordField & Field(const std::string &name)
Direct access to the fields.
Definition: Record.h:401
void ClearChangeFlags()
Clear all change flags.
Definition: Record.cxx:1433
FieldsMap fMap
Definition: Record.h:378
bool WasChangedWith(const std::string &prefix)
Returns true when fields with specified prefix were changed.
Definition: Record.cxx:1420
static bool match_prefix(const std::string &name, const std::string &prefix)
Definition: Record.cxx:1457
bool RemoveField(const std::string &name)
Definition: Record.cxx:1387
bool Stream(iostream &s, const std::string &nameprefix="")
Definition: Record.cxx:1467
bool SaveTo(HStore &res)
Save all field in json format.
Definition: Record.cxx:1529
dabc::Buffer SaveToBuffer()
Definition: Record.cxx:1712
bool SetFieldProtected(const std::string &name, bool on=true)
Definition: Record.h:526
RecordField GetField(const std::string &name) const
Definition: Record.h:510
bool Stream(iostream &s)
Definition: Record.cxx:1680
unsigned NumFields() const
Definition: Record.h:504
RecordField * GetFieldPtr(const std::string &name) const
Definition: Record.h:513
bool ReadFromBuffer(const dabc::Buffer &buf)
Definition: Record.cxx:1735
bool HasField(const std::string &name) const
Definition: Record.h:498
bool SetField(const std::string &name, const RecordField &v)
Definition: Record.h:516
std::string SaveToJson(unsigned mask=0)
Store record in JSON form.
Definition: Record.cxx:1658
bool RemoveField(const std::string &name)
Definition: Record.h:501
bool SetFieldModified(const std::string &name, bool on=true)
Definition: Record.h:519
std::string SaveToXml(unsigned mask=0)
Store record in XML form.
Definition: Record.cxx:1666
std::string FieldName(unsigned cnt) const
Definition: Record.h:507
bool SaveTo(HStore &store, bool create_node=true)
Store hierarchy in json/xml form
Definition: Record.h:534
virtual void CreateRecord(const std::string &name)
Definition: Record.cxx:1674
Reference on the arbitrary object
Definition: Reference.h:73
Object * GetObject() const
Return pointer on the object.
Definition: Reference.h:129
class to stream binary data
Definition: Record.h:41
virtual ~iostream()
Definition: Record.h:54
virtual bool write(const void *src, uint64_t len)
Definition: Record.h:67
virtual uint64_t maxstoresize() const
return maximum size of data which can be stored in the stream
Definition: Record.h:74
virtual uint64_t tmpbuf_size() const
return number of bytes which are directly available in temporary buffer
Definition: Record.h:46
bool write_int32(int32_t v)
Definition: Record.h:76
bool write_uint32(uint32_t v)
Definition: Record.h:77
bool write_int64(int64_t v)
Definition: Record.h:78
virtual bool is_real() const
Definition: Record.h:58
bool read_uint64(uint64_t &v)
Definition: Record.h:85
bool read_double(double &v)
Definition: Record.h:86
bool read_int32(int32_t &v)
Definition: Record.h:82
virtual bool read(void *tgt, uint64_t len)
Definition: Record.h:68
bool read_uint32(uint32_t &v)
Definition: Record.h:83
static uint64_t str_storesize(const std::string &str)
Returns bytes count, required to store string.
Definition: Record.cxx:68
bool is_output() const
Definition: Record.h:57
virtual uint64_t size() const
return number of bytes, written or read from the stream
Definition: Record.h:71
bool is_input() const
Definition: Record.h:56
bool skip_object()
Insted of reading object we read size and shift on that size Only can be done where size stored as 32...
Definition: Record.cxx:23
bool write_uint64(uint64_t v)
Definition: Record.h:79
iostream(bool isinp)
Definition: Record.h:51
bool read_int64(int64_t &v)
Definition: Record.h:84
bool read_str(std::string &str)
Restore string from the stream.
Definition: Record.cxx:94
bool write_double(double v)
Definition: Record.h:80
virtual bool shift(uint64_t len)
Definition: Record.h:69
bool write_str(const std::string &str)
Store string in the stream.
Definition: Record.cxx:76
bool verify_size(uint64_t pos, uint64_t sz)
Definition: Record.cxx:33
virtual char * tmpbuf() const
return temporary buffer
Definition: Record.h:48
bool fInput
Definition: Record.h:43
iostream class, which write and read data from memory
Definition: Record.h:133
virtual uint64_t maxstoresize() const
return maximum size of data which can be stored in the stream
Definition: Record.h:146
uint64_t fLength
Definition: Record.h:136
memstream(bool isinp, char *buf, uint64_t len)
Definition: Record.h:152
char * fMem
Definition: Record.h:135
char * fCurr
Definition: Record.h:137
virtual bool write(const void *src, uint64_t len)
Definition: Record.cxx:122
uint64_t fRemains
Definition: Record.h:138
virtual bool shift(uint64_t len)
Definition: Record.cxx:114
virtual uint64_t tmpbuf_size() const
return number of bytes which are directly available in temporary buffer
Definition: Record.h:140
virtual bool read(void *tgt, uint64_t len)
Definition: Record.cxx:132
virtual uint64_t size() const
return number of bytes, written or read from the stream
Definition: Record.h:145
virtual ~memstream()
Definition: Record.h:161
virtual char * tmpbuf() const
return temporary buffer
Definition: Record.h:141
special class only to define how many data will be written to the stream
Definition: Record.h:102
virtual bool write(const void *src, uint64_t len)
Definition: Record.h:123
uint64_t fLength
Definition: Record.h:104
virtual bool shift(uint64_t len)
Definition: Record.h:121
virtual uint64_t size() const
return number of bytes, written or read from the stream
Definition: Record.h:116
virtual ~sizestream()
Definition: Record.h:114
virtual bool read(void *tgt, uint64_t len)
Definition: Record.h:125
virtual bool is_real() const
Definition: Record.h:119
virtual uint64_t maxstoresize() const
return maximum size of data which can be stored in the stream
Definition: Record.h:117
Event manipulation API.
Definition: api.h:23
HStoreMask
Definition: Record.h:167
@ storemask_TopVersion
Definition: Record.h:170
@ storemask_History
Definition: Record.h:171
@ storemask_NoChilds
Definition: Record.h:172
@ storemask_Compact
Definition: Record.h:168
@ storemask_AsXML
Definition: Record.h:173
@ storemask_Version
Definition: Record.h:169