Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TRootSniffer Class Reference

Sniffer of ROOT objects, data provider for THttpServer.

Provides methods to scan different structures like folders, directories, files and collections. Can locate objects (or its data member) per name. Can be extended to application-specific classes.

Normally TRootSnifferFull class is used which able to access data from trees, canvases, histograms.

Definition at line 115 of file TRootSniffer.h.

Public Member Functions

 TRootSniffer (const char *name, const char *objpath="Objects")
 constructor
 
virtual ~TRootSniffer ()
 destructor
 
Bool_t CanDrawItem (const char *path)
 Method verifies if object can be drawn.
 
Bool_t CanExploreItem (const char *path)
 Method returns true when object has childs or one could try to expand item.
 
Int_t CheckRestriction (const char *item_name)
 Checked if restriction is applied to the item full_item_name should have full path to the item.
 
Bool_t CreateItem (const char *fullname, const char *title)
 Create item element.
 
void CreateOwnTopFolder ()
 Create own TFolder structures independent from gROOT This allows to have many independent TRootSniffer instances At the same time such sniffer lost access to all global lists and folders.
 
virtual void * FindInHierarchy (const char *path, TClass **cl=nullptr, TDataMember **member=nullptr, Int_t *chld=nullptr)
 Search element with specified path Returns pointer on element Optionally one could obtain element class, member description and number of childs.
 
TObjectFindTObjectInHierarchy (const char *path)
 Search element in hierarchy, derived from TObject.
 
const char * GetAutoLoad () const
 return name of configured autoload scripts (or 0)
 
const char * GetItemField (const char *fullname, const char *name)
 Return field for specified item.
 
virtual ULong_t GetItemHash (const char *itemname)
 Get hash function for specified item used to detect any changes in the specified object.
 
virtual ULong_t GetStreamerInfoHash ()
 
TFolderGetTopFolder (Bool_t force=kFALSE)
 Returns top TFolder instance for the sniffer.
 
Bool_t HasRestriction (const char *item_name)
 Made fast check if item with specified name is in restriction list If returns true, requires precise check with CheckRestriction() method.
 
TClassIsA () const override
 
Bool_t IsReadOnly () const
 Returns readonly mode.
 
Bool_t IsScanGlobalDir () const
 Returns true when sniffer allowed to scan global directories.
 
virtual Bool_t IsStreamerInfoItem (const char *)
 
Bool_t Produce (const std::string &path, const std::string &file, const std::string &options, std::string &res)
 Method produce different kind of data out of object.
 
Bool_t RegisterCommand (const char *cmdname, const char *method, const char *icon)
 Register command which can be executed from web interface.
 
Bool_t RegisterObject (const char *subfolder, TObject *obj)
 Register object in subfolder structure.
 
void Restrict (const char *path, const char *options)
 Restrict access to the specified location.
 
void ScanHierarchy (const char *topname, const char *path, TRootSnifferStore *store, Bool_t only_fields=kFALSE)
 Method scans normal objects, registered in ROOT.
 
void SetAutoLoad (const char *scripts="")
 When specified, _autoload attribute will be always add to top element of h.json/h.hml requests Used to instruct browser automatically load special code.
 
void SetCurrentCallArg (THttpCallArg *arg)
 set current http arguments, which then used in different process methods For instance, if user authorized with some user name, depending from restrictions some objects will be invisible or user get full access to the element
 
Bool_t SetItemField (const char *fullname, const char *name, const char *value)
 Set field for specified item.
 
void SetReadOnly (Bool_t on=kTRUE)
 When readonly on (default), sniffer is not allowed to change ROOT structures For instance, it is not allowed to read new objects from files.
 
void SetScanGlobalDir (Bool_t on=kTRUE)
 When enabled (default), sniffer scans gROOT for files, canvases, histograms.
 
void Streamer (TBuffer &) override
 Stream an object of class TObject.
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
Bool_t UnregisterObject (TObject *obj)
 Unregister (remove) object from folders structures.
 
- Public Member Functions inherited from TNamed
 TNamed ()
 
 TNamed (const char *name, const char *title)
 
 TNamed (const TNamed &named)
 TNamed copy ctor.
 
 TNamed (const TString &name, const TString &title)
 
virtual ~TNamed ()
 TNamed destructor.
 
void Clear (Option_t *option="") override
 Set name and title to empty strings ("").
 
TObjectClone (const char *newname="") const override
 Make a clone of an object using the Streamer facility.
 
Int_t Compare (const TObject *obj) const override
 Compare two TNamed objects.
 
void Copy (TObject &named) const override
 Copy this to obj.
 
virtual void FillBuffer (char *&buffer)
 Encode TNamed into output buffer.
 
const char * GetName () const override
 Returns name of object.
 
const char * GetTitle () const override
 Returns title of object.
 
ULong_t Hash () const override
 Return hash value for this object.
 
Bool_t IsSortable () const override
 
void ls (Option_t *option="") const override
 List TNamed name and title.
 
TNamedoperator= (const TNamed &rhs)
 TNamed assignment operator.
 
void Print (Option_t *option="") const override
 Print TNamed name and title.
 
virtual void SetName (const char *name)
 Set the name of the TNamed.
 
virtual void SetNameTitle (const char *name, const char *title)
 Set all the TNamed parameters (name and title).
 
virtual void SetTitle (const char *title="")
 Set the title of the TNamed.
 
virtual Int_t Sizeof () const
 Return size of the TNamed part of the TObject.
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
- Public Member Functions inherited from TObject
 TObject ()
 TObject constructor.
 
 TObject (const TObject &object)
 TObject copy ctor.
 
virtual ~TObject ()
 TObject destructor.
 
void AbstractMethod (const char *method) const
 Use this method to implement an "abstract" method that you don't want to leave purely abstract.
 
virtual void AppendPad (Option_t *option="")
 Append graphics object to current pad.
 
virtual void Browse (TBrowser *b)
 Browse object. May be overridden for another default action.
 
ULong_t CheckedHash ()
 Check and record whether this class has a consistent Hash/RecursiveRemove setup (*) and then return the regular Hash value for this object.
 
virtual const char * ClassName () const
 Returns name of class to which the object belongs.
 
virtual void Delete (Option_t *option="")
 Delete this object.
 
virtual Int_t DistancetoPrimitive (Int_t px, Int_t py)
 Computes distance from point (px,py) to the object.
 
virtual void Draw (Option_t *option="")
 Default Draw method for all objects.
 
virtual void DrawClass () const
 Draw class inheritance tree of the class to which this object belongs.
 
virtual TObjectDrawClone (Option_t *option="") const
 Draw a clone of this object in the current selected pad with: gROOT->SetSelectedPad(c1).
 
virtual void Dump () const
 Dump contents of object on stdout.
 
virtual void Error (const char *method, const char *msgfmt,...) const
 Issue error message.
 
virtual void Execute (const char *method, const char *params, Int_t *error=nullptr)
 Execute method on this object with the given parameter string, e.g.
 
virtual void Execute (TMethod *method, TObjArray *params, Int_t *error=nullptr)
 Execute method on this object with parameters stored in the TObjArray.
 
virtual void ExecuteEvent (Int_t event, Int_t px, Int_t py)
 Execute action corresponding to an event at (px,py).
 
virtual void Fatal (const char *method, const char *msgfmt,...) const
 Issue fatal error message.
 
virtual TObjectFindObject (const char *name) const
 Must be redefined in derived classes.
 
virtual TObjectFindObject (const TObject *obj) const
 Must be redefined in derived classes.
 
virtual Option_tGetDrawOption () const
 Get option used by the graphics system to draw this object.
 
virtual const char * GetIconName () const
 Returns mime type name of object.
 
virtual char * GetObjectInfo (Int_t px, Int_t py) const
 Returns string containing info about the object at position (px,py).
 
virtual Option_tGetOption () const
 
virtual UInt_t GetUniqueID () const
 Return the unique object id.
 
virtual Bool_t HandleTimer (TTimer *timer)
 Execute action in response of a timer timing out.
 
Bool_t HasInconsistentHash () const
 Return true is the type of this object is known to have an inconsistent setup for Hash and RecursiveRemove (i.e.
 
virtual void Info (const char *method, const char *msgfmt,...) const
 Issue info message.
 
virtual Bool_t InheritsFrom (const char *classname) const
 Returns kTRUE if object inherits from class "classname".
 
virtual Bool_t InheritsFrom (const TClass *cl) const
 Returns kTRUE if object inherits from TClass cl.
 
virtual void Inspect () const
 Dump contents of this object in a graphics canvas.
 
void InvertBit (UInt_t f)
 
Bool_t IsDestructed () const
 IsDestructed.
 
virtual Bool_t IsEqual (const TObject *obj) const
 Default equal comparison (objects are equal if they have the same address in memory).
 
virtual Bool_t IsFolder () const
 Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
 
R__ALWAYS_INLINE Bool_t IsOnHeap () const
 
R__ALWAYS_INLINE Bool_t IsZombie () const
 
void MayNotUse (const char *method) const
 Use this method to signal that a method (defined in a base class) may not be called in a derived class (in principle against good design since a child class should not provide less functionality than its parent, however, sometimes it is necessary).
 
virtual Bool_t Notify ()
 This method must be overridden to handle object notification.
 
void Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const
 Use this method to declare a method obsolete.
 
void operator delete (void *ptr)
 Operator delete.
 
void operator delete[] (void *ptr)
 Operator delete [].
 
void * operator new (size_t sz)
 
void * operator new (size_t sz, void *vp)
 
void * operator new[] (size_t sz)
 
void * operator new[] (size_t sz, void *vp)
 
TObjectoperator= (const TObject &rhs)
 TObject assignment operator.
 
virtual void Paint (Option_t *option="")
 This method must be overridden if a class wants to paint itself.
 
virtual void Pop ()
 Pop on object drawn in a pad to the top of the display list.
 
virtual Int_t Read (const char *name)
 Read contents of object with specified name from the current directory.
 
virtual void RecursiveRemove (TObject *obj)
 Recursively remove this object from a list.
 
void ResetBit (UInt_t f)
 
virtual void SaveAs (const char *filename="", Option_t *option="") const
 Save this object in the file specified by filename.
 
virtual void SavePrimitive (std::ostream &out, Option_t *option="")
 Save a primitive as a C++ statement(s) on output stream "out".
 
void SetBit (UInt_t f)
 
void SetBit (UInt_t f, Bool_t set)
 Set or unset the user status bits as specified in f.
 
virtual void SetDrawOption (Option_t *option="")
 Set drawing option for object.
 
virtual void SetUniqueID (UInt_t uid)
 Set the unique object id.
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
virtual void SysError (const char *method, const char *msgfmt,...) const
 Issue system error message.
 
R__ALWAYS_INLINE Bool_t TestBit (UInt_t f) const
 
Int_t TestBits (UInt_t f) const
 
virtual void UseCurrentStyle ()
 Set current style settings in this object This function is called when either TCanvas::UseCurrentStyle or TROOT::ForceStyle have been invoked.
 
virtual void Warning (const char *method, const char *msgfmt,...) const
 Issue warning message.
 
virtual Int_t Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
 Write this object to the current directory.
 
virtual Int_t Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const
 Write this object to the current directory.
 

Static Public Member Functions

static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 
- Static Public Member Functions inherited from TNamed
static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 
- Static Public Member Functions inherited from TObject
static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 
static Longptr_t GetDtorOnly ()
 Return destructor only flag.
 
static Bool_t GetObjectStat ()
 Get status of object stat flag.
 
static void SetDtorOnly (void *obj)
 Set destructor only flag.
 
static void SetObjectStat (Bool_t stat)
 Turn on/off tracking of objects in the TObjectTable.
 

Protected Member Functions

Bool_t AccessField (TFolder *parent, TObject *item, const char *name, const char *value, TNamed **only_get=nullptr)
 Set or get field for the child.
 
virtual Bool_t CanDrawClass (TClass *)
 
TString DecodeUrlOptionValue (const char *value, Bool_t remove_quotes=kTRUE)
 Method replaces all kind of special symbols, which could appear in URL options.
 
virtual Bool_t ExecuteCmd (const std::string &path, const std::string &options, std::string &res)
 Execute command marked as _kind=='Command'.
 
TObjectGetItem (const char *fullname, TFolder *&parent, Bool_t force=kFALSE, Bool_t within_objects=kTRUE)
 Return item from the subfolders structure.
 
const char * GetItemField (TFolder *parent, TObject *item, const char *name)
 Return field for specified item.
 
TFolderGetSubFolder (const char *foldername, Bool_t force=kFALSE)
 Creates subfolder where objects can be registered.
 
virtual Bool_t HasStreamerInfo () const
 
Bool_t IsItemField (TObject *obj) const
 Return true when object is TNamed with kItemField bit set.
 
virtual Bool_t ProduceBinary (const std::string &path, const std::string &options, std::string &res)
 Produce binary data for specified item.
 
virtual Bool_t ProduceExe (const std::string &path, const std::string &options, Int_t reskind, std::string &res)
 Execute command for specified object.
 
virtual Bool_t ProduceImage (Int_t kind, const std::string &path, const std::string &options, std::string &res)
 Method to produce image from specified object.
 
virtual Bool_t ProduceItem (const std::string &path, const std::string &options, std::string &res, Bool_t asjson=kTRUE)
 Produce JSON/XML for specified item.
 
virtual Bool_t ProduceJson (const std::string &path, const std::string &options, std::string &res)
 Produce JSON data for specified item For object conversion TBufferJSON is used.
 
virtual Bool_t ProduceMulti (const std::string &path, const std::string &options, std::string &res, Bool_t asjson=kTRUE)
 Process several requests, packing all results into binary or JSON buffer.
 
virtual Bool_t ProduceXml (const std::string &path, const std::string &options, std::string &res)
 Produce XML data for specified item.
 
void ScanCollection (TRootSnifferScanRec &rec, TCollection *lst, const char *foldername=nullptr, TCollection *keys_lst=nullptr)
 Scan collection content.
 
virtual void ScanKeyProperties (TRootSnifferScanRec &rec, TKey *key, TObject *&obj, TClass *&obj_class)
 Scans TKey properties in special cases load objects from the file.
 
virtual void ScanObjectChilds (TRootSnifferScanRec &rec, TObject *obj)
 scans object childs (if any) here one scans collection, branches, trees and so on
 
void ScanObjectMembers (TRootSnifferScanRec &rec, TClass *cl, char *ptr)
 scan object data members some members like enum or static members will be excluded
 
virtual void ScanObjectProperties (TRootSnifferScanRec &rec, TObject *obj)
 Scans object properties here such fields as _autoload or _icon properties depending on class or object name could be assigned By default properties, coded in the Class title are scanned.
 
virtual void ScanRoot (TRootSnifferScanRec &rec)
 scan complete ROOT objects hierarchy For the moment it includes objects in gROOT directory and list of canvases and files Also all registered objects are included.
 
Int_t WithCurrentUserName (const char *option)
 return 2 when option match to current user name return 1 when option==all return 0 when option does not match user name
 
- Protected Member Functions inherited from TObject
virtual void DoError (int level, const char *location, const char *fmt, va_list va) const
 Interface to ErrorHandler (protected).
 
void MakeZombie ()
 

Protected Attributes

TString fAutoLoad
 ! scripts names, which are add as _autoload parameter to h.json request
 
TString fCurrentAllowedMethods
 ! list of allowed methods, extracted when analyzed object restrictions
 
THttpCallArgfCurrentArg {nullptr}
 ! current http arguments (if any)
 
Int_t fCurrentRestrict {0}
 ! current restriction for last-found object
 
TString fObjectsPath
 ! default path for registered objects
 
Bool_t fReadOnly {kTRUE}
 ! indicate if sniffer allowed to change ROOT structures - like read objects from file
 
TList fRestrictions
 ! list of restrictions for different locations
 
Bool_t fScanGlobalDir {kTRUE}
 ! when enabled (default), scan gROOT for histograms, canvases, open files
 
std::unique_ptr< TFolderfTopFolder
 ! own top TFolder object, used for registering objects
 
- Protected Attributes inherited from TNamed
TString fName
 
TString fTitle
 

Private Types

enum  { kItemField = (1ULL << ( 21 )) }
 

Additional Inherited Members

- Public Types inherited from TObject
enum  {
  kIsOnHeap = 0x01000000 , kNotDeleted = 0x02000000 , kZombie = 0x04000000 , kInconsistent = 0x08000000 ,
  kBitMask = 0x00ffffff
}
 
enum  { kSingleKey = (1ULL << ( 0 )) , kOverwrite = (1ULL << ( 1 )) , kWriteDelete = (1ULL << ( 2 )) }
 
enum  EDeprecatedStatusBits { kObjInCanvas = (1ULL << ( 3 )) }
 
enum  EStatusBits {
  kCanDelete = (1ULL << ( 0 )) , kMustCleanup = (1ULL << ( 3 )) , kIsReferenced = (1ULL << ( 4 )) , kHasUUID = (1ULL << ( 5 )) ,
  kCannotPick = (1ULL << ( 6 )) , kNoContextMenu = (1ULL << ( 8 )) , kInvalidObject = (1ULL << ( 13 ))
}
 
- Protected Types inherited from TObject
enum  { kOnlyPrepStep = (1ULL << ( 3 )) }
 

#include <TRootSniffer.h>

Inheritance diagram for TRootSniffer:
[legend]

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
kItemField 

Definition at line 116 of file TRootSniffer.h.

Constructor & Destructor Documentation

◆ TRootSniffer()

TRootSniffer::TRootSniffer ( const char *  name,
const char *  objpath = "Objects" 
)

constructor

Definition at line 416 of file TRootSniffer.cxx.

◆ ~TRootSniffer()

TRootSniffer::~TRootSniffer ( )
virtual

destructor

Definition at line 425 of file TRootSniffer.cxx.

Member Function Documentation

◆ AccessField()

Bool_t TRootSniffer::AccessField ( TFolder parent,
TObject chld,
const char *  name,
const char *  value,
TNamed **  only_get = nullptr 
)
protected

Set or get field for the child.

each field coded as TNamed object, placed after chld in the parent hierarchy

Definition at line 1698 of file TRootSniffer.cxx.

◆ CanDrawClass()

virtual Bool_t TRootSniffer::CanDrawClass ( TClass )
inlineprotectedvirtual

Reimplemented in TRootSnifferFull.

Definition at line 158 of file TRootSniffer.h.

◆ CanDrawItem()

Bool_t TRootSniffer::CanDrawItem ( const char *  path)

Method verifies if object can be drawn.

Definition at line 1110 of file TRootSniffer.cxx.

◆ CanExploreItem()

Bool_t TRootSniffer::CanExploreItem ( const char *  path)

Method returns true when object has childs or one could try to expand item.

Definition at line 1121 of file TRootSniffer.cxx.

◆ CheckRestriction()

Int_t TRootSniffer::CheckRestriction ( const char *  full_item_name)

Checked if restriction is applied to the item full_item_name should have full path to the item.

Returns:

  • -1 - object invisible, cannot be accessed or listed
  • 0 - no explicit restrictions, use default
  • 1 - read-only access
  • 2 - full access

Definition at line 544 of file TRootSniffer.cxx.

◆ Class()

static TClass * TRootSniffer::Class ( )
static
Returns
TClass describing this class

◆ Class_Name()

static const char * TRootSniffer::Class_Name ( )
static
Returns
Name of this class

◆ Class_Version()

static constexpr Version_t TRootSniffer::Class_Version ( )
inlinestaticconstexpr
Returns
Version of this class

Definition at line 245 of file TRootSniffer.h.

◆ CreateItem()

Bool_t TRootSniffer::CreateItem ( const char *  fullname,
const char *  title 
)

Create item element.

Definition at line 1671 of file TRootSniffer.cxx.

◆ CreateOwnTopFolder()

void TRootSniffer::CreateOwnTopFolder ( )

Create own TFolder structures independent from gROOT This allows to have many independent TRootSniffer instances At the same time such sniffer lost access to all global lists and folders.

Definition at line 914 of file TRootSniffer.cxx.

◆ DeclFileName()

static const char * TRootSniffer::DeclFileName ( )
inlinestatic
Returns
Name of the file containing the class declaration

Definition at line 245 of file TRootSniffer.h.

◆ DecodeUrlOptionValue()

TString TRootSniffer::DecodeUrlOptionValue ( const char *  value,
Bool_t  remove_quotes = kTRUE 
)
protected

Method replaces all kind of special symbols, which could appear in URL options.

Definition at line 1283 of file TRootSniffer.cxx.

◆ ExecuteCmd()

Bool_t TRootSniffer::ExecuteCmd ( const std::string &  path,
const std::string &  options,
std::string &  res 
)
protectedvirtual

Execute command marked as _kind=='Command'.

Definition at line 1165 of file TRootSniffer.cxx.

◆ FindInHierarchy()

void * TRootSniffer::FindInHierarchy ( const char *  path,
TClass **  cl = nullptr,
TDataMember **  member = nullptr,
Int_t chld = nullptr 
)
virtual

Search element with specified path Returns pointer on element Optionally one could obtain element class, member description and number of childs.

When chld!=nullptr, not only element is searched, but also number of childs are counted. When member!=0, any object will be scanned for its data members (disregard of extra options)

Reimplemented in TRootSnifferFull.

Definition at line 1042 of file TRootSniffer.cxx.

◆ FindTObjectInHierarchy()

TObject * TRootSniffer::FindTObjectInHierarchy ( const char *  path)

Search element in hierarchy, derived from TObject.

Definition at line 1087 of file TRootSniffer.cxx.

◆ GetAutoLoad()

const char * TRootSniffer::GetAutoLoad ( ) const

return name of configured autoload scripts (or 0)

Definition at line 488 of file TRootSniffer.cxx.

◆ GetItem()

TObject * TRootSniffer::GetItem ( const char *  fullname,
TFolder *&  parent,
Bool_t  force = kFALSE,
Bool_t  within_objects = kTRUE 
)
protected

Return item from the subfolders structure.

Definition at line 1551 of file TRootSniffer.cxx.

◆ GetItemField() [1/2]

const char * TRootSniffer::GetItemField ( const char *  fullname,
const char *  name 
)

Return field for specified item.

Definition at line 1817 of file TRootSniffer.cxx.

◆ GetItemField() [2/2]

const char * TRootSniffer::GetItemField ( TFolder parent,
TObject item,
const char *  name 
)
protected

Return field for specified item.

Definition at line 1801 of file TRootSniffer.cxx.

◆ GetItemHash()

ULong_t TRootSniffer::GetItemHash ( const char *  itemname)
virtual

Get hash function for specified item used to detect any changes in the specified object.

Reimplemented in TRootSnifferFull.

Definition at line 1100 of file TRootSniffer.cxx.

◆ GetStreamerInfoHash()

virtual ULong_t TRootSniffer::GetStreamerInfoHash ( )
inlinevirtual

Reimplemented in TRootSnifferFull.

Definition at line 239 of file TRootSniffer.h.

◆ GetSubFolder()

TFolder * TRootSniffer::GetSubFolder ( const char *  foldername,
Bool_t  force = kFALSE 
)
protected

Creates subfolder where objects can be registered.

Definition at line 1602 of file TRootSniffer.cxx.

◆ GetTopFolder()

TFolder * TRootSniffer::GetTopFolder ( Bool_t  force = kFALSE)

Returns top TFolder instance for the sniffer.

Definition at line 933 of file TRootSniffer.cxx.

◆ HasRestriction()

Bool_t TRootSniffer::HasRestriction ( const char *  item_name)

Made fast check if item with specified name is in restriction list If returns true, requires precise check with CheckRestriction() method.

Definition at line 497 of file TRootSniffer.cxx.

◆ HasStreamerInfo()

virtual Bool_t TRootSniffer::HasStreamerInfo ( ) const
inlineprotectedvirtual

Reimplemented in TRootSnifferFull.

Definition at line 160 of file TRootSniffer.h.

◆ IsA()

TClass * TRootSniffer::IsA ( ) const
inlineoverridevirtual
Returns
TClass describing current object

Reimplemented from TNamed.

Definition at line 245 of file TRootSniffer.h.

◆ IsItemField()

Bool_t TRootSniffer::IsItemField ( TObject obj) const
protected

Return true when object is TNamed with kItemField bit set.

such objects used to keep field values for item

Definition at line 1688 of file TRootSniffer.cxx.

◆ IsReadOnly()

Bool_t TRootSniffer::IsReadOnly ( ) const
inline

Returns readonly mode.

Definition at line 189 of file TRootSniffer.h.

◆ IsScanGlobalDir()

Bool_t TRootSniffer::IsScanGlobalDir ( ) const
inline

Returns true when sniffer allowed to scan global directories.

Definition at line 209 of file TRootSniffer.h.

◆ IsStreamerInfoItem()

virtual Bool_t TRootSniffer::IsStreamerInfoItem ( const char *  )
inlinevirtual

Reimplemented in TRootSnifferFull.

Definition at line 237 of file TRootSniffer.h.

◆ Produce()

Bool_t TRootSniffer::Produce ( const std::string &  path,
const std::string &  file,
const std::string &  options,
std::string &  res 
)

Method produce different kind of data out of object.

Parameters
pathspecifies object or object member
filecan be:
  • "root.bin" - binary data
  • "root.png" - png image
  • "root.jpeg" - jpeg image
  • "root.gif" - gif image
  • "root.xml" - xml representation
  • "root.json" - json representation
  • "exe.json" - method execution with json reply
  • "exe.bin" - method execution with binary reply
  • "exe.txt" - method execution with debug output
  • "cmd.json" - execution of registered commands
Parameters
resreturns result - binary or text.

Definition at line 1497 of file TRootSniffer.cxx.

◆ ProduceBinary()

Bool_t TRootSniffer::ProduceBinary ( const std::string &  path,
const std::string &  options,
std::string &  res 
)
protectedvirtual

Produce binary data for specified item.

If "zipped" option specified in query, buffer will be compressed

Implemented only in TRootSnifferFull class

Reimplemented in TRootSnifferFull.

Definition at line 1443 of file TRootSniffer.cxx.

◆ ProduceExe()

Bool_t TRootSniffer::ProduceExe ( const std::string &  path,
const std::string &  options,
Int_t  reskind,
std::string &  res 
)
protectedvirtual

Execute command for specified object.

Options include method and extra list of parameters sniffer should be not-readonly to allow execution of the commands reskind defines kind of result 0 - debug, 1 - json, 2 - binary

Method implemented only in TRootSnifferFull class

Reimplemented in TRootSnifferFull.

Definition at line 1317 of file TRootSniffer.cxx.

◆ ProduceImage()

Bool_t TRootSniffer::ProduceImage ( Int_t  kind,
const std::string &  path,
const std::string &  options,
std::string &  res 
)
protectedvirtual

Method to produce image from specified object.

Parameters:

kind - image kind TImage::kPng, TImage::kJpeg, TImage::kGif
path - path to object
options - extra options

By default, image 300x200 is produced In options string one could provide following parameters:

w - image width
h - image height
opt - draw options

For instance:

http://localhost:8080/Files/hsimple.root/hpx/get.png?w=500&h=500&opt=lego1

Return is memory with produced image Memory must be released by user with free(ptr) call

Method implemented only in TRootSnifferFull class

Reimplemented in TRootSnifferFull.

Definition at line 1473 of file TRootSniffer.cxx.

◆ ProduceItem()

Bool_t TRootSniffer::ProduceItem ( const std::string &  path,
const std::string &  options,
std::string &  res,
Bool_t  asjson = kTRUE 
)
protectedvirtual

Produce JSON/XML for specified item.

Contrary to h.json request, only fields for specified item are stored

Definition at line 1255 of file TRootSniffer.cxx.

◆ ProduceJson()

Bool_t TRootSniffer::ProduceJson ( const std::string &  path,
const std::string &  options,
std::string &  res 
)
protectedvirtual

Produce JSON data for specified item For object conversion TBufferJSON is used.

Definition at line 1133 of file TRootSniffer.cxx.

◆ ProduceMulti()

Bool_t TRootSniffer::ProduceMulti ( const std::string &  path,
const std::string &  options,
std::string &  str,
Bool_t  asjson = kTRUE 
)
protectedvirtual

Process several requests, packing all results into binary or JSON buffer.

Input parameters should be coded in the POST block and has individual request relative to current path, separated with '
' symbol like item1/root.bin
item2/exe.bin?method=GetList
item3/exe.bin?method=GetTitle
Request requires 'number' URL option which contains number of requested items

In case of binary request output buffer looks like:

4bytes length + payload,
4bytes length + payload, ...

In case of JSON request output is array with results for each item multi.json request do not support binary requests for the items

Definition at line 1341 of file TRootSniffer.cxx.

◆ ProduceXml()

Bool_t TRootSniffer::ProduceXml ( const std::string &  path,
const std::string &  options,
std::string &  res 
)
protectedvirtual

Produce XML data for specified item.

For object conversion TBufferXML is used Method implemented only in TRootSnifferFull class

Reimplemented in TRootSnifferFull.

Definition at line 1275 of file TRootSniffer.cxx.

◆ RegisterCommand()

Bool_t TRootSniffer::RegisterCommand ( const char *  cmdname,
const char *  method,
const char *  icon 
)

Register command which can be executed from web interface.

As method one typically specifies string, which is executed with gROOT->ProcessLine() method. For instance:

serv->RegisterCommand("Invoke","InvokeFunction()");

Or one could specify any method of the object which is already registered to the server. For instance:

serv->Register("/", hpx);
serv->RegisterCommand("/ResetHPX", "/hpx/->Reset()");

Here symbols '/->' separates item name from method to be executed

One could specify additional arguments in the command with syntax like arg1%, arg2% and so on. For example:

serv->RegisterCommand("/ResetHPX", "/hpx/->SetTitle(\"%arg1%\")");
serv->RegisterCommand("/RebinHPXPY", "/hpxpy/->Rebin2D(%arg1%,%arg2%)");

Such parameter(s) will be requested when command clicked in the browser.

Once command is registered, one could specify icon which will appear in the browser:

serv->SetIcon("/ResetHPX", "rootsys/icons/ed_execute.png");

One also can set extra property '_fastcmd', that command appear as tool button on the top of the browser tree:

serv->SetItemField("/ResetHPX", "_fastcmd", "true");

Or it is equivalent to specifying extra argument when register command:

serv->RegisterCommand("/ResetHPX", "/hpx/->Reset()", "button;rootsys/icons/ed_delete.png"); 

Definition at line 1865 of file TRootSniffer.cxx.

◆ RegisterObject()

Bool_t TRootSniffer::RegisterObject ( const char *  subfolder,
TObject obj 
)

Register object in subfolder structure.

Parameters
subfoldercan have many levels like:
TRootSniffer* sniff = new TRootSniffer("sniff");
sniff->RegisterObject("my/sub/subfolder", h1);
Such objects can be later found in "Objects" folder of sniffer like
auto h1 = sniff->FindTObjectInHierarchy("/Objects/my/sub/subfolder/h1");
If subfolder name starts with '/', object will be registered starting from top folder.

One could provide additional fields for registered objects For instance, setting "_more" field to true let browser explore objects members. For instance:

TEvent* ev = new TEvent("ev");
sniff->RegisterObject("Events", ev);
sniff->SetItemField("Events/ev", "_more", "true"); 

Definition at line 1631 of file TRootSniffer.cxx.

◆ Restrict()

void TRootSniffer::Restrict ( const char *  path,
const char *  options 
)

Restrict access to the specified location.

Hides or provides read-only access to different parts of the hierarchy Restriction done base on user-name specified with http requests Options can be specified in URL style (separated with &) Following parameters can be specified:

visible = [all|user(s)] - make item visible for all users or only specified user
hidden = [all|user(s)] - make item hidden from all users or only specified user
readonly = [all|user(s)] - make item read-only for all users or only specified user
allow = [all|user(s)] - make full access for all users or only specified user
allow_method = method(s)  - allow method(s) execution even when readonly flag specified for the object

Like make command seen by all but can be executed only by admin

sniff->Restrict("/CmdReset","allow=admin");

Or fully hide command from guest account

sniff->Restrict("/CmdRebin","hidden=guest"); 

Definition at line 464 of file TRootSniffer.cxx.

◆ ScanCollection()

void TRootSniffer::ScanCollection ( TRootSnifferScanRec rec,
TCollection lst,
const char *  foldername = nullptr,
TCollection keys_lst = nullptr 
)
protected

Scan collection content.

Definition at line 776 of file TRootSniffer.cxx.

◆ ScanHierarchy()

void TRootSniffer::ScanHierarchy ( const char *  topname,
const char *  path,
TRootSnifferStore store,
Bool_t  only_fields = kFALSE 
)

Method scans normal objects, registered in ROOT.

scan ROOT hierarchy with provided store object

Definition at line 1002 of file TRootSniffer.cxx.

◆ ScanKeyProperties()

void TRootSniffer::ScanKeyProperties ( TRootSnifferScanRec rec,
TKey key,
TObject *&  obj,
TClass *&  obj_class 
)
protectedvirtual

Scans TKey properties in special cases load objects from the file.

Reimplemented in TRootSnifferFull.

Definition at line 741 of file TRootSniffer.cxx.

◆ ScanObjectChilds()

void TRootSniffer::ScanObjectChilds ( TRootSnifferScanRec rec,
TObject obj 
)
protectedvirtual

scans object childs (if any) here one scans collection, branches, trees and so on

Reimplemented in TRootSnifferFull.

Definition at line 761 of file TRootSniffer.cxx.

◆ ScanObjectMembers()

void TRootSniffer::ScanObjectMembers ( TRootSnifferScanRec rec,
TClass cl,
char *  ptr 
)
protected

scan object data members some members like enum or static members will be excluded

Definition at line 607 of file TRootSniffer.cxx.

◆ ScanObjectProperties()

void TRootSniffer::ScanObjectProperties ( TRootSnifferScanRec rec,
TObject obj 
)
protectedvirtual

Scans object properties here such fields as _autoload or _icon properties depending on class or object name could be assigned By default properties, coded in the Class title are scanned.

Example:

ClassDef(UserClassName, 1) //  class comments *SNIFF*  _field1=value _field2="string value"

Here SNIFF mark is important. After it all expressions like field=value are parsed One could use double quotes to code string values with spaces. Fields separated from each other with spaces

Reimplemented in TRootSnifferFull.

Definition at line 700 of file TRootSniffer.cxx.

◆ ScanRoot()

void TRootSniffer::ScanRoot ( TRootSnifferScanRec rec)
protectedvirtual

scan complete ROOT objects hierarchy For the moment it includes objects in gROOT directory and list of canvases and files Also all registered objects are included.

One could re-implement this method to provide alternative scan methods or to extend some collection kinds

Definition at line 966 of file TRootSniffer.cxx.

◆ SetAutoLoad()

void TRootSniffer::SetAutoLoad ( const char *  scripts = "")

When specified, _autoload attribute will be always add to top element of h.json/h.hml requests Used to instruct browser automatically load special code.

Definition at line 480 of file TRootSniffer.cxx.

◆ SetCurrentCallArg()

void TRootSniffer::SetCurrentCallArg ( THttpCallArg arg)

set current http arguments, which then used in different process methods For instance, if user authorized with some user name, depending from restrictions some objects will be invisible or user get full access to the element

Definition at line 435 of file TRootSniffer.cxx.

◆ SetItemField()

Bool_t TRootSniffer::SetItemField ( const char *  fullname,
const char *  name,
const char *  value 
)

Set field for specified item.

Definition at line 1776 of file TRootSniffer.cxx.

◆ SetReadOnly()

void TRootSniffer::SetReadOnly ( Bool_t  on = kTRUE)
inline

When readonly on (default), sniffer is not allowed to change ROOT structures For instance, it is not allowed to read new objects from files.

Definition at line 186 of file TRootSniffer.h.

◆ SetScanGlobalDir()

void TRootSniffer::SetScanGlobalDir ( Bool_t  on = kTRUE)
inline

When enabled (default), sniffer scans gROOT for files, canvases, histograms.

Definition at line 202 of file TRootSniffer.h.

◆ Streamer()

void TRootSniffer::Streamer ( TBuffer R__b)
overridevirtual

Stream an object of class TObject.

Reimplemented from TNamed.

◆ StreamerNVirtual()

void TRootSniffer::StreamerNVirtual ( TBuffer ClassDef_StreamerNVirtual_b)
inline

Definition at line 245 of file TRootSniffer.h.

◆ UnregisterObject()

Bool_t TRootSniffer::UnregisterObject ( TObject obj)

Unregister (remove) object from folders structures.

Folder itself will remain even when it will be empty

Definition at line 1650 of file TRootSniffer.cxx.

◆ WithCurrentUserName()

Int_t TRootSniffer::WithCurrentUserName ( const char *  option)
protected

return 2 when option match to current user name return 1 when option==all return 0 when option does not match user name

Definition at line 510 of file TRootSniffer.cxx.

Member Data Documentation

◆ fAutoLoad

TString TRootSniffer::fAutoLoad
protected

! scripts names, which are add as _autoload parameter to h.json request

Definition at line 129 of file TRootSniffer.h.

◆ fCurrentAllowedMethods

TString TRootSniffer::fCurrentAllowedMethods
protected

! list of allowed methods, extracted when analyzed object restrictions

Definition at line 127 of file TRootSniffer.h.

◆ fCurrentArg

THttpCallArg* TRootSniffer::fCurrentArg {nullptr}
protected

! current http arguments (if any)

Definition at line 125 of file TRootSniffer.h.

◆ fCurrentRestrict

Int_t TRootSniffer::fCurrentRestrict {0}
protected

! current restriction for last-found object

Definition at line 126 of file TRootSniffer.h.

◆ fObjectsPath

TString TRootSniffer::fObjectsPath
protected

! default path for registered objects

Definition at line 121 of file TRootSniffer.h.

◆ fReadOnly

Bool_t TRootSniffer::fReadOnly {kTRUE}
protected

! indicate if sniffer allowed to change ROOT structures - like read objects from file

Definition at line 122 of file TRootSniffer.h.

◆ fRestrictions

TList TRootSniffer::fRestrictions
protected

! list of restrictions for different locations

Definition at line 128 of file TRootSniffer.h.

◆ fScanGlobalDir

Bool_t TRootSniffer::fScanGlobalDir {kTRUE}
protected

! when enabled (default), scan gROOT for histograms, canvases, open files

Definition at line 123 of file TRootSniffer.h.

◆ fTopFolder

std::unique_ptr<TFolder> TRootSniffer::fTopFolder
protected

! own top TFolder object, used for registering objects

Definition at line 124 of file TRootSniffer.h.

Libraries for TRootSniffer:

The documentation for this class was generated from the following files: