105 rec.
SetField(
"_player",
"drawLeafPlayer");
106 rec.
SetField(
"_module",
"draw_tree");
120 if (strcmp(key->
GetClassName(),
"TDirectoryFile") == 0) {
129 obj_class = obj->
IsA();
132 rec.
SetField(
"_player",
"drawTreePlayerKey");
133 rec.
SetField(
"_module",
"draw_tree");
150 rec.
SetField(
"_player",
"drawTreePlayer");
151 rec.
SetField(
"_module",
"draw_tree");
176 if (!itemname || (*itemname == 0))
179 return (strcmp(itemname,
"StreamerInfo") == 0) || (strcmp(itemname,
"StreamerInfo/") == 0);
227 l->Add(
gROOT->GetListOfStreamerInfo()->FindObject(
"TGraph"));
228 l->Add(
gROOT->GetListOfStreamerInfo()->FindObject(
"TH1F"));
229 l->Add(
gROOT->GetListOfStreamerInfo()->FindObject(
"TH1"));
230 l->Add(
gROOT->GetListOfStreamerInfo()->FindObject(
"TNamed"));
231 l->Add(
gROOT->GetListOfStreamerInfo()->FindObject(
"TObject"));
274 const char *path_ = path.c_str();
280 if (!obj_ptr || !obj_cl)
284 Info(
"ProduceBinary",
"Non-TObject class not supported");
308 res.resize(sbuf->
Length());
309 std::copy((
const char *)sbuf->
Buffer(), (
const char *)sbuf->
Buffer() + sbuf->
Length(), res.begin());
326 const char *path_ = path.c_str();
332 if (!obj_ptr || !obj_cl)
335 const char *store_name =
"object";
338 const char *obj_name = ((
TNamed *) obj_ptr)->GetName();
339 if (obj_name && *obj_name)
340 store_name = obj_name;
344 struct RestoreGFile {
346 ~RestoreGFile() {
gFile = oldFile; }
350 TMemFile memfile(
"dummy.file",
"RECREATE");
351 gROOT->GetListOfFiles()->Remove(&memfile);
388 const char *path_ = path.c_str();
394 if (!obj_ptr || !obj_cl)
398 Error(
"TRootSniffer",
"Only derived from TObject classes can be drawn");
411 Info(
"TRootSniffer",
"Crate IMAGE directly from pad");
416 Info(
"TRootSniffer",
"Crate IMAGE from object %s", obj->
GetName());
418 Int_t width(300), height(200);
421 if (!options.empty()) {
442 TCanvas *
c1 =
new TCanvas(
"__online_draw_canvas__",
"title", width, height);
458 char *png_buffer =
nullptr;
463 if (png_buffer && (
size > 0)) {
465 memcpy((
void *)res.data(), png_buffer,
size);
500 const char *path_ = path.c_str();
506 if (!obj_ptr || !obj_cl)
526 std::string *debug = (reskind == 0) ? &res_str :
nullptr;
530 debug->append(
"Item name not specified\n");
531 return debug !=
nullptr;
534 const char *path_ = path.c_str();
541 debug->append(
TString::Format(
"Item:%s found:%s\n", path_, obj_ptr ?
"true" :
"false").Data());
542 if (!obj_ptr || !obj_cl)
543 return debug !=
nullptr;
554 if (prototype.
Length() == 0) {
556 debug->append(
TString::Format(
"Search for any method with name \'%s\'\n", method_name).Data());
561 TString::Format(
"Search for method \'%s\' with prototype \'%s\'\n", method_name, prototype.
Data())
571 if (funcname.
Length() > 0) {
572 if (prototype.
Length() == 0) {
574 debug->append(
TString::Format(
"Search for any function with name \'%s\'\n", funcname.
Data()).Data());
575 func =
gROOT->GetGlobalFunction(funcname);
578 debug->append(
TString::Format(
"Search for function \'%s\' with prototype \'%s\'\n", funcname.
Data(),
581 func =
gROOT->GetGlobalFunctionWithPrototype(funcname, prototype);
589 if (!method && !func) {
591 debug->append(
"Method not found\n");
592 return debug !=
nullptr;
598 debug->append(
"Server runs in read-only mode, method cannot be executed\n");
599 return debug !=
nullptr;
602 debug->append(
"Server runs in read-only mode, function cannot be executed\n");
603 return debug !=
nullptr;
606 debug->append(
"For that special method server allows access even read-only mode is specified\n");
618 while (
auto arg =
static_cast<TMethodArg *
>(next())) {
620 if ((strcmp(arg->GetName(),
"rest_url_opt") == 0) && (strcmp(arg->GetFullTypeName(),
"const char*") == 0) &&
624 const char *pos = strstr(options.c_str(),
"method=");
625 if (!pos || (strlen(pos) < strlen(method_name) + 7))
626 return debug !=
nullptr;
627 const char *rest_url = pos + strlen(method_name) + 7;
628 if (*rest_url ==
'&') ++rest_url;
629 call_args.
Form(
"\"%s\"", rest_url);
640 if ((val !=
nullptr) && (strcmp(val,
"_this_") == 0)) {
642 sval.
Form(
"(%s*)0x%zx", obj_cl->
GetName(), (
size_t)obj_ptr);
646 if (strcmp(val,
"_post_object_xml_") == 0) {
652 sval.
Form(
"(%s*)0x%zx", post_obj->
ClassName(), (
size_t)post_obj);
654 garbage.
Add(post_obj);
657 }
else if (strcmp(val,
"_post_object_json_") == 0) {
663 sval.
Form(
"(%s*)0x%zx", post_obj->
ClassName(), (
size_t)post_obj);
665 garbage.
Add(post_obj);
668 }
else if ((strcmp(val,
"_post_object_") == 0) && url.
HasOption(
"_post_class_")) {
673 if (post_obj ==
nullptr) {
675 debug->append(
TString::Format(
"Fail to create object of class %s\n", clname.
Data()).Data());
678 debug->append(
TString::Format(
"Reconstruct object of class %s from POST data\n", clname.
Data()).Data());
683 garbage.
Add(post_obj);
686 sval.
Form(
"(%s*)0x%zx", clname.
Data(), (
size_t)post_obj);
688 }
else if (strcmp(val,
"_post_data_") == 0) {
691 }
else if (strcmp(val,
"_post_length_") == 0) {
698 val = arg->GetDefault();
701 debug->append(
TString::Format(
" Argument:%s Type:%s Value:%s \n", arg->GetName(), arg->GetFullTypeName(),
702 val ? val :
"<missed>")
705 return debug !=
nullptr;
707 if (call_args.
Length() > 0)
710 if ((strcmp(arg->GetFullTypeName(),
"const char*") == 0) || (strcmp(arg->GetFullTypeName(),
"Option_t*") == 0)) {
711 int len = strlen(val);
712 if ((strlen(val) < 2) || (*val !=
'\"') || (val[len - 1] !=
'\"'))
723 if (method !=
nullptr) {
726 debug->append(
TString::Format(
"Calling obj->%s(%s);\n", method_name, call_args.
Data()).Data());
737 debug->append(
"Fail: invalid TMethodCall\n");
738 return debug !=
nullptr;
746 void *ret_obj =
nullptr;
764 res.
Form(
"%zd", (
size_t)
l);
785 if (txt !=
nullptr) {
789 res.
Form(
"\"%s\"", txt);
795 if ((ret_kind.length() > 0) && (ret_kind[ret_kind.length() - 1] ==
'*')) {
796 ret_kind.resize(ret_kind.length() - 1);
800 if (ret_cl !=
nullptr) {
827 if (_ret_object_ !=
nullptr) {
832 debug->append(
TString::Format(
"Return object %s found %s\n", _ret_object_, obj ?
"true" :
"false").Data());
834 if (obj ==
nullptr) {
842 if (ret_obj && ret_cl) {
854 if ((resbuf !=
nullptr) && (resbuf->
Length() > 0)) {
855 res_str.resize(resbuf->
Length());
856 std::copy((
const char *)resbuf->
Buffer(), (
const char *)resbuf->
Buffer() + resbuf->
Length(), res_str.begin());
863 res_str = res.
Data();
865 if (url.
HasOption(
"_destroy_result_") && ret_obj && ret_cl) {
868 debug->append(
"Destroy result object at the end\n");
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int).
long Longptr_t
Integer large enough to hold a pointer (platform-dependent).
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
A TTree is a list of TBranches.
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
void WriteLong(Long_t l) override
void WriteString(const char *s) override
Write string to I/O buffer.
void WriteDouble(Double_t d) override
void MapObject(const TObject *obj, UInt_t offset=1) override
Add object to the fMap container.
static TObject * ConvertFromJSON(const char *str)
Read TObject-based class from JSON, produced by ConvertToJSON() method.
static TString ConvertToJSON(const TObject *obj, Int_t compact=0, const char *member_name=nullptr)
Converts object, inherited from TObject class, to JSON string Lower digit of compact parameter define...
static const char * GetFloatFormat()
return current printf format for float members, default "%e"
static TString ConvertToXML(const TObject *obj, Bool_t GenericLayout=kFALSE, Bool_t UseNamespaces=kFALSE)
Converts object, inherited from TObject class, to XML string GenericLayout defines layout choice for ...
static TObject * ConvertFromXML(const char *str, Bool_t GenericLayout=kFALSE, Bool_t UseNamespaces=kFALSE)
Read object from XML, produced by ConvertToXML() method.
void SetParent(TObject *parent)
Set parent owning this buffer.
TClass instances represent classes, structs and namespaces in the ROOT type system.
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
TMethod * GetMethodWithPrototype(const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Find the method with a given prototype.
void Destructor(void *obj, Bool_t dtorOnly=kFALSE)
Explicitly call destructor for object.
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
Int_t GetBaseClassOffset(const TClass *toBase, void *address=nullptr, bool isDerivedObject=true)
TMethod * GetMethodAllAny(const char *method)
Return pointer to method without looking at parameters.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
All ROOT classes may have RTTI (run time type identification) support added.
Int_t WriteObjectAny(const void *obj, const char *classname, const char *name, Option_t *option="", Int_t bufsize=0) override
TDirectory::TContext keeps track and restore the current directory.
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
void Close(Option_t *option="") override
Close a file.
Global functions class (global functions are obtained from CINT).
virtual const char * GetPrototype() const
Returns the prototype of a function as defined by CINT, or 0 in case of error.
TList * GetListOfMethodArgs()
Return list containing the TMethodArgs of a TFunction.
std::string GetReturnTypeNormalizedName() const
Get the normalized name of the return type.
1-D histogram with a float per channel (see TH1 documentation)
An abstract interface to image processing library.
virtual void FromPad(TVirtualPad *, Int_t=0, Int_t=0, UInt_t=0, UInt_t=0)
static TImage * Create()
Create an image.
virtual void Append(const TImage *, const char *="+", const char *="#00000000")
virtual void GetImageBuffer(char **, int *, EImageFileTypes=TImage::kPng)
Book space in a file, create I/O buffers, to fill them, (un)compress them.
virtual const char * GetClassName() const
virtual TObject * ReadObj()
To read a TObject* from the file.
void Add(TObject *obj) override
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
A TMemFile is like a normal TFile except that it reads and writes only from memory.
Long64_t GetSize() const override
Return the current size of the memory file.
virtual Long64_t CopyTo(void *to, Long64_t maxsize) const
Copy the binary representation of the TMemFile into the memory area starting at 'to' and of length at...
Each ROOT method (see TMethod) has a linked list of its arguments.
Method or function calling interface.
EReturnType ReturnType()
Returns the return type of the method.
static const EReturnType kLong
static const EReturnType kString
static const EReturnType kOther
static const EReturnType kNone
void Execute(const char *, const char *, int *=nullptr) override
Execute method on this object with the given parameter string, e.g.
Bool_t IsValid() const
Return true if the method call has been properly initialized and is usable.
static const EReturnType kDouble
Each ROOT class (see TClass) has a linked list of methods.
virtual TList * GetListOfMethodArgs()
Returns methodarg list and additionally updates fDataMember in TMethod by calling FindDataMember();.
const char * GetName() const override
Returns name of object.
virtual const char * GetName() const
Returns name of object.
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual TClass * IsA() const
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
TObject()
TObject constructor.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
The most important graphics class in the ROOT system.
void * FindInHierarchy(const char *path, TClass **cl=nullptr, TDataMember **member=nullptr, Int_t *chld=nullptr) override
Search element with specified path.
Bool_t IsStreamerInfoItem(const char *itemname) override
Return true if it is streamer info item name.
static Bool_t IsDrawableClass(TClass *cl)
return true if given class can be drawn in JSROOT
Bool_t ProduceExe(const std::string &path, const std::string &options, Int_t reskind, std::string &res) override
Execute command for specified object.
TList * fSinfo
! last produced streamer info
TRootSnifferFull(const char *name="sniff", const char *objpath="Objects")
constructor
Bool_t CanDrawClass(TClass *cl) override
void ScanObjectProperties(TRootSnifferScanRec &rec, TObject *obj) override
Scans object properties.
virtual ~TRootSnifferFull()
destructor
void ScanObjectChilds(TRootSnifferScanRec &rec, TObject *obj) override
Scans object childs (if any).
Bool_t ProduceRootFile(const std::string &path, const std::string &options, std::string &res) override
Produce ROOT file for specified item.
ULong_t GetItemHash(const char *itemname) override
Get hash function for specified item.
Bool_t ProduceImage(Int_t kind, const std::string &path, const std::string &options, std::string &res) override
Method to produce image from specified object.
Bool_t CallProduceImage(const std::string &kind, const std::string &path, const std::string &options, std::string &res) override
Invokes TRootSniffer::ProduceIamge, converting kind into TImage::EImageFileTypes type.
Bool_t ProduceXml(const std::string &path, const std::string &options, std::string &res) override
Produce XML data for specified item.
void CreateMemFile()
Creates TMemFile instance, which used for objects streaming.
Bool_t ProduceBinary(const std::string &path, const std::string &options, std::string &res) override
Produce binary data for specified item.
TMemFile * fMemFile
! file used to manage streamer infos
ULong_t GetStreamerInfoHash() override
Returns hash value for streamer infos.
void ScanKeyProperties(TRootSnifferScanRec &rec, TKey *key, TObject *&obj, TClass *&obj_class) override
Scans TKey properties.
Structure used to scan hierarchies of ROOT objects.
Bool_t CanExpandItem()
Returns true when item can be expanded.
void SetField(const char *name, const char *value, Bool_t with_quotes=kTRUE)
Set item field only when creating is specified.
Bool_t IsReadOnly(Bool_t dflt=kTRUE)
Returns read-only flag for current item.
TRootSniffer(const char *name="sniff", const char *objpath="Objects")
constructor
virtual void ScanObjectChilds(TRootSnifferScanRec &rec, TObject *obj)
scans object childs (if any) here one scans collection, branches, trees and so on
TString fCurrentAllowedMethods
! list of allowed methods, extracted when analyzed object restrictions
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 ScanObjectProperties(TRootSnifferScanRec &rec, TObject *obj)
Scans object properties here such fields as _autoload or _icon properties depending on class or objec...
TString DecodeUrlOptionValue(const char *value, Bool_t remove_quotes=kTRUE)
Method replaces all kind of special symbols, which could appear in URL options.
virtual ULong_t GetItemHash(const char *itemname)
Get hash function for specified item used to detect any changes in the specified object.
Bool_t fReadOnly
! indicate if sniffer allowed to change ROOT structures - like read objects from file
THttpCallArg * fCurrentArg
! current http arguments (if any)
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 cla...
Int_t fCurrentRestrict
! current restriction for last-found object
void ScanCollection(TRootSnifferScanRec &rec, TCollection *lst, const char *foldername=nullptr, TCollection *keys_lst=nullptr)
Scan collection content.
const char * Data() const
TString & Append(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
A TTree represents a columnar dataset.
This class represents a WWW compatible URL.
const char * GetValueFromOptions(const char *key) const
Return a value for a given key from the URL options.
Int_t GetIntValueFromOptions(const char *key) const
Return a value for a given key from the URL options as an Int_t, a missing key returns -1.
void SetOptions(const char *opt)
void ParseOptions() const
Parse URL options into a key/value map.
Bool_t HasOption(const char *key) const
Returns true if the given key appears in the URL options list.
small helper class to store/restore gPad context in TPad methods