Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 
55 class TRootSnifferStoreXml : public TRootSnifferStore {
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 
79 class TRootSnifferStoreJson : public TRootSnifferStore {
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