Logo ROOT   6.21/01
Reference Guide
TRootSnifferStore.h
Go to the documentation of this file.
1 // $Id$
2 // Author: Sergey Linev 22/12/2013
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TRootSnifferStore
13 #define ROOT_TRootSnifferStore
14 
15 #include "TObject.h"
16 
17 #include "TString.h"
18 
19 class TDataMember;
20 class TFolder;
21 
22 /** Abstract interface for storage of hierarchy scan in TRootSniffer */
23 
24 class TRootSnifferStore : public TObject {
25 protected:
26  void *fResPtr{nullptr}; ///<! pointer on found item
27  TClass *fResClass{nullptr}; ///<! class of found item
28  TDataMember *fResMember{nullptr}; ///<! datamember pointer of found item
29  Int_t fResNumChilds{-1}; ///<! count of found childs, -1 by default
30  Int_t fResRestrict{0}; ///<! restriction for result, 0-default, 1-readonly, 2-full
31 public:
32  virtual ~TRootSnifferStore() = default;
33 
34  virtual void CreateNode(Int_t, const char *) {}
35  virtual void SetField(Int_t, const char *, const char *, Bool_t) {}
36  virtual void BeforeNextChild(Int_t, Int_t, Int_t) {}
37  virtual void CloseNode(Int_t, Int_t) {}
38 
39  void SetResult(void *_res, TClass *_rescl, TDataMember *_resmemb, Int_t _res_chld, Int_t restr = 0);
40 
41  void *GetResPtr() const { return fResPtr; }
42  TClass *GetResClass() const { return fResClass; }
43  TDataMember *GetResMember() const { return fResMember; }
44  Int_t GetResNumChilds() const { return fResNumChilds; }
45  Int_t GetResRestrict() const { return fResRestrict; }
46  virtual Bool_t IsXml() const { return kFALSE; }
47 
48  ClassDef(TRootSnifferStore, 0) // structure for results store of objects sniffer
49 };
50 
51 // ========================================================================
52 
53 /** Storage of hierarchy scan in TRootSniffer in XML format */
54 
56 protected:
57  TString &fBuf; ///<! output buffer
58  Bool_t fCompact{kFALSE}; ///<! produce compact xml code
59 
60 public:
61  explicit TRootSnifferStoreXml(TString &_buf, Bool_t _compact = kFALSE) : TRootSnifferStore(), fBuf(_buf), fCompact(_compact)
62  {
63  }
64 
65  void CreateNode(Int_t lvl, const char *nodename) final;
66  void SetField(Int_t lvl, const char *field, const char *value, Bool_t) final;
67  void BeforeNextChild(Int_t lvl, Int_t nchld, Int_t) final;
68  void CloseNode(Int_t lvl, Int_t numchilds) final;
69 
70  Bool_t IsXml() const final { return kTRUE; }
71 
72  ClassDefOverride(TRootSnifferStoreXml, 0) // xml results store of objects sniffer
73 };
74 
75 // ========================================================================
76 
77 /** Storage of hierarchy scan in TRootSniffer in JSON format */
78 
80 protected:
81  TString &fBuf; ///<! output buffer
82  Bool_t fCompact{kFALSE}; ///<! produce compact json code
83 public:
84  explicit TRootSnifferStoreJson(TString &_buf, Bool_t _compact = kFALSE) : TRootSnifferStore(), fBuf(_buf), fCompact(_compact)
85  {
86  }
87 
88  void CreateNode(Int_t lvl, const char *nodename) final;
89  void SetField(Int_t lvl, const char *field, const char *value, Bool_t with_quotes) final;
90  void BeforeNextChild(Int_t lvl, Int_t nchld, Int_t nfld) final;
91  void CloseNode(Int_t lvl, Int_t numchilds) final;
92 
93  ClassDefOverride(TRootSnifferStoreJson, 0) // json results store of objects sniffer
94 };
95 
96 #endif
A TFolder object is a collection of objects and folders.
Definition: TFolder.h:30
virtual Bool_t IsXml() const
void * fResPtr
! pointer on found item
TClass * GetResClass() const
void CreateNode(Int_t lvl, const char *nodename) final
starts new xml node, will be closed by CloseNode
All ROOT classes may have RTTI (run time type identification) support added.
Definition: TDataMember.h:31
Storage of hierarchy scan in TRootSniffer in JSON format.
Bool_t fCompact
! produce compact json code
virtual ~TRootSnifferStore()=default
void * GetResPtr() const
Basic string class.
Definition: TString.h:131
TDataMember * fResMember
! datamember pointer of found item
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void BeforeNextChild(Int_t lvl, Int_t nchld, Int_t nfld) final
called before next child node created
virtual void BeforeNextChild(Int_t, Int_t, Int_t)
Int_t fResRestrict
! restriction for result, 0-default, 1-readonly, 2-full
Int_t fResNumChilds
! count of found childs, -1 by default
Abstract interface for storage of hierarchy scan in TRootSniffer.
void BeforeNextChild(Int_t lvl, Int_t nchld, Int_t) final
called before next child node created
#define ClassDef(name, id)
Definition: Rtypes.h:326
TRootSnifferStoreJson(TString &_buf, Bool_t _compact=kFALSE)
Storage of hierarchy scan in TRootSniffer in XML format.
Int_t GetResNumChilds() const
Bool_t IsXml() const final
void SetField(Int_t lvl, const char *field, const char *value, Bool_t with_quotes) final
set field (json field) in current node
Int_t GetResRestrict() const
TRootSnifferStoreXml(TString &_buf, Bool_t _compact=kFALSE)
Bool_t fCompact
! produce compact xml code
void SetResult(void *_res, TClass *_rescl, TDataMember *_resmemb, Int_t _res_chld, Int_t restr=0)
set pointer on found element, class and number of childs
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:75
void CreateNode(Int_t lvl, const char *nodename) final
starts new json object, will be closed by CloseNode
void CloseNode(Int_t lvl, Int_t numchilds) final
called when node should be closed depending from number of childs different xml format is applied ...
void CloseNode(Int_t lvl, Int_t numchilds) final
called when node should be closed depending from number of childs different xml format is applied ...
void SetField(Int_t lvl, const char *field, const char *value, Bool_t) final
set field (xml attribute) in current node
const Bool_t kFALSE
Definition: RtypesCore.h:88
TDataMember * GetResMember() const
TClass * fResClass
! class of found item
virtual void CreateNode(Int_t, const char *)
Mother of all ROOT objects.
Definition: TObject.h:37
TString & fBuf
! output buffer
virtual void SetField(Int_t, const char *, const char *, Bool_t)
virtual void CloseNode(Int_t, Int_t)
#define ClassDefOverride(name, id)
Definition: Rtypes.h:330
TString & fBuf
! output buffer
const Bool_t kTRUE
Definition: RtypesCore.h:87