Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TRootSnifferStore.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // $Id$
0002 // Author: Sergey Linev   22/12/2013
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TRootSnifferStore
0013 #define ROOT_TRootSnifferStore
0014 
0015 #include "TObject.h"
0016 
0017 #include "TString.h"
0018 
0019 class TDataMember;
0020 class TFolder;
0021 
0022 /** Abstract interface for storage of hierarchy scan in TRootSniffer */
0023 
0024 class TRootSnifferStore : public TObject {
0025 protected:
0026    void *fResPtr{nullptr};           ///<! pointer on found item
0027    TClass *fResClass{nullptr};       ///<! class of found item
0028    TDataMember *fResMember{nullptr}; ///<! datamember pointer of found item
0029    Int_t fResNumChilds{-1};          ///<! count of found childs, -1 by default
0030    Int_t fResRestrict{0};            ///<! restriction for result, 0-default, 1-readonly, 2-full
0031 public:
0032    virtual ~TRootSnifferStore() = default;
0033 
0034    virtual void CreateNode(Int_t, const char *) {}
0035    virtual void SetField(Int_t, const char *, const char *, Bool_t) {}
0036    virtual void BeforeNextChild(Int_t, Int_t, Int_t) {}
0037    virtual void CloseNode(Int_t, Int_t) {}
0038 
0039    void SetResult(void *_res, TClass *_rescl, TDataMember *_resmemb, Int_t _res_chld, Int_t restr = 0);
0040 
0041    void *GetResPtr() const { return fResPtr; }
0042    TClass *GetResClass() const { return fResClass; }
0043    TDataMember *GetResMember() const { return fResMember; }
0044    Int_t GetResNumChilds() const { return fResNumChilds; }
0045    Int_t GetResRestrict() const { return fResRestrict; }
0046    virtual Bool_t IsXml() const { return kFALSE; }
0047 
0048    ClassDefOverride(TRootSnifferStore, 0) // structure for results store of objects sniffer
0049 };
0050 
0051 // ========================================================================
0052 
0053 /** Storage of hierarchy scan in TRootSniffer in XML format */
0054 
0055 class TRootSnifferStoreXml : public TRootSnifferStore {
0056 protected:
0057    TString &fBuf;           ///<! output buffer
0058    Bool_t fCompact{kFALSE}; ///<! produce compact xml code
0059 
0060 public:
0061    explicit TRootSnifferStoreXml(TString &_buf, Bool_t _compact = kFALSE) : TRootSnifferStore(), fBuf(_buf), fCompact(_compact)
0062    {
0063    }
0064 
0065    void CreateNode(Int_t lvl, const char *nodename) final;
0066    void SetField(Int_t lvl, const char *field, const char *value, Bool_t) final;
0067    void BeforeNextChild(Int_t lvl, Int_t nchld, Int_t) final;
0068    void CloseNode(Int_t lvl, Int_t numchilds) final;
0069 
0070    Bool_t IsXml() const final { return kTRUE; }
0071 
0072    ClassDefOverride(TRootSnifferStoreXml, 0) // xml results store of objects sniffer
0073 };
0074 
0075 // ========================================================================
0076 
0077 /** Storage of hierarchy scan in TRootSniffer in JSON format */
0078 
0079 class TRootSnifferStoreJson : public TRootSnifferStore {
0080 protected:
0081    TString &fBuf;           ///<! output buffer
0082    Bool_t fCompact{kFALSE}; ///<! produce compact json code
0083 public:
0084    explicit TRootSnifferStoreJson(TString &_buf, Bool_t _compact = kFALSE) : TRootSnifferStore(), fBuf(_buf), fCompact(_compact)
0085    {
0086    }
0087 
0088    void CreateNode(Int_t lvl, const char *nodename) final;
0089    void SetField(Int_t lvl, const char *field, const char *value, Bool_t with_quotes) final;
0090    void BeforeNextChild(Int_t lvl, Int_t nchld, Int_t nfld) final;
0091    void CloseNode(Int_t lvl, Int_t numchilds) final;
0092 
0093    ClassDefOverride(TRootSnifferStoreJson, 0) // json results store of objects sniffer
0094 };
0095 
0096 #endif