Skip to content
Snippets Groups Projects
Commit 732158b6 authored by Sergey Linev's avatar Sergey Linev Committed by Bertrand Bellenot
Browse files

http: let configure global _autoload atribute in sniffer

parent ae49da1e
No related branches found
No related tags found
No related merge requests found
......@@ -124,6 +124,7 @@ protected:
Int_t fCurrentRestrict; //! current restriction for last-found object
TString fCurrentAllowedMethods; //! list of allowed methods, extracted when analyzed object restrictions
TList fRestrictions; //! list of restrictions for different locations
TString fAutoLoad; //! scripts names, which are add as _autoload parameter to h.json request
void ScanObjectMemebers(TRootSnifferScanRec &rec, TClass *cl, char *ptr, unsigned long int cloffset);
......@@ -189,6 +190,10 @@ public:
fScanGlobalDir = on;
}
void SetAutoLoad(const char* scripts = "");
const char* GetAutoLoad() const;
Bool_t IsScanGlobalDir() const { return fScanGlobalDir; }
......
......@@ -47,6 +47,7 @@ const char *item_prop_typename = "_typename";
const char *item_prop_arraydim = "_arraydim";
const char *item_prop_realname = "_realname"; // real object name
const char *item_prop_user = "_username";
const char *item_prop_autoload = "_autoload";
// ============================================================================
......@@ -325,6 +326,7 @@ Bool_t TRootSnifferScanRec::GoInside(TRootSnifferScanRec &super, TObject *obj,
fSearchPath = super.fSearchPath;
fMask = super.fMask & kActions;
if (fRestriction==0) fRestriction = super.fRestriction; // get restriction from parent
Bool_t topelement(kFALSE);
if (fMask & kScan) {
// if scanning only fields, ignore all childs
......@@ -348,6 +350,7 @@ Bool_t TRootSnifferScanRec::GoInside(TRootSnifferScanRec &super, TObject *obj,
if (*separ == 0) {
fSearchPath = 0;
if (fMask & kExpand) {
topelement = kTRUE;
fMask = (fMask & kOnlyFields) | kScan;
fHasMore = (fMask & kOnlyFields) == 0;
}
......@@ -365,6 +368,9 @@ Bool_t TRootSnifferScanRec::GoInside(TRootSnifferScanRec &super, TObject *obj,
if (full_name != 0)
SetField("_fullname", full_name);
if (topelement && sniffer->GetAutoLoad())
SetField(item_prop_autoload, sniffer->GetAutoLoad());
return kTRUE;
}
......@@ -398,7 +404,8 @@ TRootSniffer::TRootSniffer(const char *name, const char *objpath) :
fCurrentArg(0),
fCurrentRestrict(0),
fCurrentAllowedMethods(0),
fRestrictions()
fRestrictions(),
fAutoLoad()
{
fRestrictions.SetOwner(kTRUE);
}
......@@ -458,6 +465,24 @@ void TRootSniffer::Restrict(const char* path, const char* options)
fRestrictions.Add(new TNamed(rslash, TString::Format("%s%s%s", path,"%%%",options).Data()));
}
////////////////////////////////////////////////////////////////////////////////
/// 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 TRootSniffer::SetAutoLoad(const char* scripts)
{
fAutoLoad = scripts!=0 ? scripts : "";
}
////////////////////////////////////////////////////////////////////////////////
/// return name of configured autoload scripts (or 0)
const char* TRootSniffer::GetAutoLoad() const
{
return fAutoLoad.Length() > 0 ? fAutoLoad.Data() : 0;
}
////////////////////////////////////////////////////////////////////////////////
/// Made fast check if item with specified name is in restriction list
/// If returns true, requires precise check with CheckRestriction() method
......@@ -897,6 +922,8 @@ void TRootSniffer::ScanHierarchy(const char *topname, const char *path,
rec.fStore = store;
rec.CreateNode(topname);
if ((rec.fSearchPath == 0) && (GetAutoLoad() != 0))
rec.SetField(item_prop_autoload, GetAutoLoad());
ScanRoot(rec);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment