19using namespace std::string_literals;
105 if (cl && (bmap.find(cl) != bmap.end()))
119 if (cl && (bmap.find(cl) != bmap.end()))
132 if (cl && (bmap.find(cl) != bmap.end()))
151 const std::string &browselib,
const std::string &draw6lib,
const std::string &draw7lib)
155 if (!clname.empty() && (bmap.find(clname) != bmap.end()))
158 std::string blib = browselib;
159 bool can_have_childs = !browselib.empty();
160 if ((blib ==
"dflt") || (blib ==
"TObject")) blib =
"";
162 bmap.emplace(clname,
StructClass{
this, can_have_childs, iconname, blib, draw6lib, draw7lib});
172 if (iter != bmap.end())
175 if (!cl.
name.empty()) {
176 for (
auto &elem : bmap)
177 if (cl.
name.compare(0, elem.first.length(), elem.first) == 0)
180 auto bases =
const_cast<TClass *
>(cl.
cl)->GetListOfBases();
181 const TClass *basecl = bases && (bases->GetSize() > 0) ?
dynamic_cast<TBaseClass *
>(bases->First())->GetClassPointer() :
nullptr;
200 return fmap.find(
extension) != fmap.end();
212 if (iter != fmap.end())
213 return iter->second.func(fullname);
221template<
class Map_t,
class Func_t>
230 auto iter = fmap.find(testcl);
231 if (iter != fmap.end())
232 if (!check_func || check_func(iter->second.func))
237 testcl = bases && (bases->GetSize() > 0) ?
dynamic_cast<TBaseClass *
>(bases->First())->GetClassPointer() :
nullptr;
240 for (
auto &entry : fmap) {
241 if (!entry.first)
continue;
242 std::string
name = entry.first->GetName();
248 if (check_func(entry.second.func))
254 if (test_all && check_func) {
255 for (
auto &entry : fmap)
256 if (!entry.first && check_func(entry.second.func))
270 std::shared_ptr<RElement> res;
272 if (!
object)
return res;
276 return (res || !
object) ? true :
false;
280 if (ScanProviderMap<BrowseMap_t,BrowseFunc_t>(
GetBrowseMap(),
object->GetClass(),
false, browse_func))
284 if (!entry.dummy() && !entry.browselib.empty())
288 ScanProviderMap<BrowseMap_t,BrowseFunc_t>(
GetBrowseMap(),
object->GetClass(),
true, browse_func);
301 if (entry.browselib.empty())
319 if (!
object || !
object->GetClass())
323 return func(subpad,
object, opt);
326 if (ScanProviderMap<Draw6Map_t,Draw6Func_t>(
GetDraw6Map(),
object->GetClass(),
false, draw_func))
330 if (!entry.dummy() && !entry.draw6lib.empty())
333 return ScanProviderMap<Draw6Map_t,Draw6Func_t>(
GetDraw6Map(),
object->GetClass(),
true, draw_func);
340bool RProvider::Draw7(std::shared_ptr<ROOT::Experimental::RPadBase> &subpad, std::unique_ptr<RHolder> &
object,
const std::string &opt)
342 if (!
object || !
object->GetClass())
346 return func(subpad,
object, opt);
349 if (ScanProviderMap<Draw7Map_t,Draw7Func_t>(
GetDraw7Map(),
object->GetClass(),
false, draw_func))
353 if (!entry.dummy() && !entry.draw7lib.empty())
356 return ScanProviderMap<Draw7Map_t,Draw7Func_t>(
GetDraw7Map(),
object->GetClass(),
true, draw_func);
365 if (!entry.iconname.empty())
366 return entry.iconname;
368 return is_folder ?
"sap-icon://folder-blank"s :
"sap-icon://electronic-medical-record"s;
385 if (ScanProviderMap<Draw6Map_t,Draw6Func_t>(
GetDraw6Map(), arg))
399 if (ScanProviderMap<Draw7Map_t,Draw7Func_t>(
GetDraw7Map(), arg))
417 RegisterClass(
"ROOT::Experimental::RH1D",
"sap-icon://bar-chart",
"",
"",
"libROOTHistDrawProvider");
418 RegisterClass(
"ROOT::Experimental::RH2D",
"sap-icon://pixelate",
"",
"",
"libROOTHistDrawProvider");
419 RegisterClass(
"ROOT::Experimental::RH3D",
"sap-icon://product",
"",
"",
"libROOTHistDrawProvider");
420 RegisterClass(
"ROOT::Experimental::RCanvas",
"sap-icon://business-objects-experience",
"",
"",
"libROOTHistDrawProvider");
421 RegisterClass(
"ROOT::Experimental::RNTuple",
"sap-icon://table-chart",
"libROOTNTupleBrowseProvider",
"libROOTNTupleDraw6Provider",
"libROOTNTupleDraw7Provider");
#define R__LOG_ERROR(...)
RDefaultProvider newRDefaultProvider
bool ScanProviderMap(Map_t &fmap, const RProvider::ClassArg &cl, bool test_all=false, std::function< bool(Func_t &)> check_func=nullptr)
R__EXTERN TSystem * gSystem
const TClass * GetClass() const
const std::string & GetName() const
Provider of different browsing methods for supported classes.
void RegisterDraw7(const TClass *cl, Draw7Func_t func)
static std::shared_ptr< RElement > BrowseNTuple(const std::string &tuplename, const std::string &filename)
Start browsing of RNTuple.
std::function< bool(std::shared_ptr< ROOT::Experimental::RPadBase > &, std::unique_ptr< RHolder > &, const std::string &)> Draw7Func_t
static bool CanDraw6(const ClassArg &)
Return true if provided class can be drawn on the TCanvas.
static ClassMap_t & GetClassMap()
static FileMap_t & GetFileMap()
void RegisterDraw6(const TClass *cl, Draw6Func_t func)
static std::shared_ptr< RElement > Browse(std::unique_ptr< RHolder > &obj)
Create browsable element for the object Created element may take ownership over the object.
static bool CanDraw7(const ClassArg &)
Return true if provided class can be drawn on the RCanvas.
static BrowseNTupleFunc_t gNTupleFunc
static bool Draw6(TVirtualPad *subpad, std::unique_ptr< RHolder > &obj, const std::string &opt="")
Invoke drawing of object on TCanvas sub-pad All existing providers are checked, first checked are cla...
virtual ~RProvider()
Automatically unregister provider from all maps.
std::multimap< std::string, StructClass > ClassMap_t
static std::string GetClassIcon(const ClassArg &, bool=false)
Return icon name for the given class - either class name or TClass *.
std::multimap< std::string, StructFile > FileMap_t
static bool Draw7(std::shared_ptr< ROOT::Experimental::RPadBase > &subpad, std::unique_ptr< RHolder > &obj, const std::string &opt="")
Invoke drawing of object on RCanvas sub-pad All existing providers are checked, first checked are cla...
void RegisterFile(const std::string &extension, FileFunc_t func)
static bool IsFileFormatSupported(const std::string &extension)
static Draw7Map_t & GetDraw7Map()
std::function< std::shared_ptr< RElement >(const std::string &, const std::string &)> BrowseNTupleFunc_t
std::function< std::shared_ptr< RElement >(std::unique_ptr< RHolder > &)> BrowseFunc_t
std::multimap< const TClass *, StructBrowse > BrowseMap_t
void RegisterBrowse(const TClass *cl, BrowseFunc_t func)
void RegisterNTupleFunc(BrowseNTupleFunc_t func)
void RegisterClass(const std::string &clname, const std::string &iconname, const std::string &browselib="", const std::string &draw6lib="", const std::string &draw7lib="")
std::function< std::shared_ptr< RElement >(const std::string &)> FileFunc_t
static bool CanHaveChilds(const ClassArg &)
Return true if provided class can have childs.
std::function< bool(TVirtualPad *, std::unique_ptr< RHolder > &, const std::string &)> Draw6Func_t
static BrowseMap_t & GetBrowseMap()
static std::shared_ptr< RElement > OpenFile(const std::string &extension, const std::string &fullname)
std::multimap< const TClass *, StructDraw7 > Draw7Map_t
static Draw6Map_t & GetDraw6Map()
void CleanThis(Map_t &fmap)
std::multimap< const TClass *, StructDraw6 > Draw6Map_t
static const StructClass & GetClassEntry(const ClassArg &)
Each class (see TClass) has a linked list of its base class(es).
TClass instances represent classes, structs and namespaces in the ROOT type system.
TList * GetListOfBases()
Return list containing the TBaseClass(es) of a class.
virtual const char * GetName() const
Returns name of object.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
RLogChannel & BrowsableLog()
Log channel for Browsable diagnostics.