#ifndef ROOT_TRootSniffer
#define ROOT_TRootSniffer
#ifndef ROOT_TNamed
#include "TNamed.h"
#endif
#ifndef ROOT_TList
#include "TList.h"
#endif
class TFolder;
class TMemFile;
class TBufferFile;
class TDataMember;
class THttpCallArg;
class TRootSnifferStore;
class TRootSniffer;
class TRootSnifferScanRec {
friend class TRootSniffer;
protected:
enum {
kScan = 0x0001,
kExpand = 0x0002,
kSearch = 0x0004,
kCheckChilds = 0x0008,
kOnlyFields = 0x0010,
kActions = 0x001F
};
TRootSnifferScanRec *fParent;
UInt_t fMask;
const char *fSearchPath;
Int_t fLevel;
TString fItemName;
TList fItemsNames;
Int_t fRestriction;
TRootSnifferStore *fStore;
Bool_t fHasMore;
Bool_t fNodeStarted;
Int_t fNumFields;
Int_t fNumChilds;
public:
TRootSnifferScanRec();
virtual ~TRootSnifferScanRec();
void CloseNode();
Bool_t CanSetFields() const
{
return (fMask & kScan) && (fStore != 0);
}
Bool_t ScanOnlyFields() const
{
return (fMask & kOnlyFields) && (fMask & kScan);
}
void CreateNode(const char *_node_name);
void BeforeNextChild();
void SetField(const char *name, const char *value, Bool_t with_quotes = kTRUE);
void SetRootClass(TClass *cl);
Bool_t CanExpandItem();
Bool_t IsReadyForResult() const;
Bool_t SetResult(void *obj, TClass *cl, TDataMember *member = 0);
Bool_t SetFoundResult(void *obj, TClass *cl, TDataMember *member = 0);
Int_t Depth() const;
Bool_t Done() const;
void MakeItemName(const char *objname, TString &itemname);
void BuildFullName(TString& buf, TRootSnifferScanRec* prnt = 0);
Bool_t IsReadOnly(Bool_t dflt = kTRUE);
Bool_t GoInside(TRootSnifferScanRec &super, TObject *obj, const char *obj_name = 0, TRootSniffer* sniffer = 0);
ClassDef(TRootSnifferScanRec, 0)
};
class TRootSniffer : public TNamed {
enum {
kItemField = BIT(21)
};
protected:
TString fObjectsPath;
TMemFile *fMemFile;
TList *fSinfo;
Bool_t fReadOnly;
Bool_t fScanGlobalDir;
THttpCallArg *fCurrentArg;
Int_t fCurrentRestrict;
TString fCurrentAllowedMethods;
TList fRestrictions;
TString fAutoLoad;
void ScanObjectMembers(TRootSnifferScanRec &rec, TClass *cl, char *ptr);
virtual void ScanObjectProperties(TRootSnifferScanRec &rec, TObject *obj);
virtual void ScanObjectChilds(TRootSnifferScanRec &rec, TObject *obj);
void ScanCollection(TRootSnifferScanRec &rec, TCollection *lst,
const char *foldername = 0, TCollection *keys_lst = 0);
virtual void ScanRoot(TRootSnifferScanRec &rec);
void CreateMemFile();
TString DecodeUrlOptionValue(const char *value, Bool_t remove_quotes = kTRUE);
TObject *GetItem(const char *fullname, TFolder *&parent, Bool_t force = kFALSE, Bool_t within_objects = kTRUE);
TFolder *GetSubFolder(const char *foldername, Bool_t force = kFALSE);
const char *GetItemField(TFolder *parent, TObject *item, const char *name);
Bool_t IsItemField(TObject* obj) const;
Bool_t AccessField(TFolder *parent, TObject *item,
const char *name, const char *value, TNamed **only_get = 0);
Int_t WithCurrentUserName(const char* option);
public:
TRootSniffer(const char *name, const char *objpath = "Objects");
virtual ~TRootSniffer();
static Bool_t IsDrawableClass(TClass *cl);
void SetReadOnly(Bool_t on = kTRUE)
{
fReadOnly = on;
}
Bool_t IsReadOnly() const
{
return fReadOnly;
}
void Restrict(const char* path, const char* options);
Bool_t HasRestriction(const char* item_name);
Int_t CheckRestriction(const char* item_name);
void SetScanGlobalDir(Bool_t on = kTRUE)
{
fScanGlobalDir = on;
}
void SetAutoLoad(const char* scripts = "");
const char* GetAutoLoad() const;
Bool_t IsScanGlobalDir() const { return fScanGlobalDir; }
Bool_t RegisterObject(const char *subfolder, TObject *obj);
Bool_t UnregisterObject(TObject *obj);
Bool_t RegisterCommand(const char *cmdname, const char *method, const char *icon);
Bool_t CreateItem(const char *fullname, const char *title);
Bool_t SetItemField(const char *fullname, const char *name, const char *value);
const char *GetItemField(const char *fullname, const char *name);
void SetCurrentCallArg(THttpCallArg* arg);
void ScanHierarchy(const char *topname, const char *path,
TRootSnifferStore *store, Bool_t only_fields = kFALSE);
TObject *FindTObjectInHierarchy(const char *path);
virtual void *FindInHierarchy(const char *path, TClass **cl = 0, TDataMember **member = 0, Int_t *chld = 0);
Bool_t CanDrawItem(const char *path);
Bool_t CanExploreItem(const char *path);
Bool_t IsStreamerInfoItem(const char *itemname);
ULong_t GetStreamerInfoHash();
ULong_t GetItemHash(const char *itemname);
Bool_t ProduceJson(const char *path, const char *options, TString &res);
Bool_t ProduceXml(const char *path, const char *options, TString &res);
Bool_t ProduceBinary(const char *path, const char *options, void *&ptr, Long_t &length);
Bool_t ProduceImage(Int_t kind, const char *path, const char *options, void *&ptr, Long_t &length);
Bool_t ProduceExe(const char *path, const char *options, Int_t reskind, TString *ret_str, void **ret_ptr = 0, Long_t *ret_length = 0);
Bool_t ExecuteCmd(const char *path, const char *options, TString &res);
Bool_t ProduceItem(const char *path, const char *options, TString &res, Bool_t asjson = kTRUE);
Bool_t ProduceMulti(const char *path, const char *options, void *&ptr, Long_t &length, TString &str, Bool_t asjson = kTRUE);
Bool_t Produce(const char *path, const char *file, const char *options, void *&ptr, Long_t &length, TString &str);
ClassDef(TRootSniffer, 0)
};
#endif