30using namespace std::string_literals;
44 std::unique_ptr<TIterator>
fIter;
52 if (!
fDir)
return false;
55 auto lst =
fDir->GetListOfKeys();
56 if (lst->GetSize() == 0) {
57 auto olst =
fDir->GetList();
58 if (olst->GetSize() > 0) {
60 fIter.reset(olst->MakeIterator());
65 fIter.reset(lst->MakeIterator());
72 if (!
fIter)
return false;
80 fIter.reset(
fDir->GetList()->MakeIterator());
90 if (!
fDir->GetListOfKeys()->FindObject(
fObj->GetName()))
117 bool found_newer =
false;
118 while ((key =
dynamic_cast<TKey*
>(iter())) !=
nullptr) {
125 if (!found_newer)
break;
170 std::unique_ptr<RHolder> holder = std::make_unique<TObjectHolder>(
fObj,
kFALSE);
174 return elem ? elem->CreateItem() :
nullptr;
214 if (!
gROOT->GetListOfFiles()->FindObject(
fObj))
257 return fObj->GetName();
271 return fObj->GetTitle();
283 return dir ? std::make_unique<TDirectoryLevelIter>(dir) :
nullptr;
304 if (
f)
return f->GetSize();
311 if (
f)
return f->GetModificationDate().AsSQLString();
389 if (!dir)
return nullptr;
391 auto subdir = dir->GetDirectory(
fKeyName.c_str());
393 subdir = dir->GetDirectory(
GetName().c_str());
394 if (!subdir)
return nullptr;
395 return std::make_unique<TDirectoryLevelIter>(subdir);
419 if (!obj_class->HasDictionary()) {
429 void *obj = dir->GetObjectChecked(namecycle.c_str(), obj_class);
437 bool in_dir = dir->FindObject(tobj) !=
nullptr,
440 if (in_dir && !special_class)
443 return std::make_unique<TObjectHolder>(tobj, !special_class);
446 return std::make_unique<RAnyObjectHolder>(obj_class, obj,
true);
452 return fElement->GetDefaultAction();
508 default:
return false;
521 auto item = std::make_unique<TObjectItem>(
GetName(), is_folder ? -1 : 0);
541 return std::make_shared<TObjectElement>(
fObj);
543 if (
"ROOT::RNTuple"s ==
fKey->GetClassName())
546 std::string key_class =
fKey->GetClassName();
547 if (read_dir && (key_class.find(
"TDirectory") == 0)) {
548 auto subdir =
fDir->GetDirectory(
fKey->GetName());
549 if (subdir)
return std::make_shared<TDirectoryElement>(
"", subdir);
552 return std::make_shared<TKeyElement>(
fDir,
fKey);
570 RegisterFile(
"root", [] (
const std::string &fullname) -> std::shared_ptr<RElement> {
571 auto f =
dynamic_cast<TFile *
> (
gROOT->GetListOfFiles()->FindObject(fullname.c_str()));
573 if (!
f)
return nullptr;
574 return std::make_shared<TDirectoryElement>(fullname,
f,
true);
578 return std::make_shared<TDirectoryElement>(
"",
const_cast<TFile*
>(
object->Get<
TFile>()),
true);
#define R__LOG_ERROR(...)
short Short_t
Signed Short integer 2 bytes (short).
RTFileProvider newRTFileProvider
static bool IsLastKeyCycle()
Is only last cycle from the list of keys is shown.
static EContentKind GetContentKind(const std::string &kind)
Find item with specified name Default implementation, should work for all.
@ kFileName
"filename" - file name if applicable
EActionKind
Possible actions on double-click.
@ kActImage
can be shown in image viewer, can provide image
@ kActDraw6
can be drawn inside ROOT6 canvas
@ kActCanvas
indicate that it is canvas and should be drawn directly
@ kActTree
can be shown in tree viewer
@ kActGeom
can be shown in geometry viewer
@ kActBrowse
just browse (expand) item
@ kActEdit
can provide data for text editor
@ kActDraw7
can be drawn inside ROOT7 canvas
Iterator over single level hierarchy like any array, keys list, ...
Provider of different browsing methods for supported classes.
static std::shared_ptr< RElement > BrowseNTuple(const std::string &tuplename, const std::string &filename)
Start browsing of RNTuple.
static bool CanDraw6(const ClassArg &)
Return true if provided class can be drawn on the TCanvas.
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 std::string GetClassIcon(const ClassArg &, bool=false)
Return icon name for the given class - either class name or TClass *.
void RegisterFile(const std::string &extension, FileFunc_t func)
void RegisterBrowse(const TClass *cl, BrowseFunc_t func)
static bool CanHaveChilds(const ClassArg &)
Return true if provided class can have childs.
TObjectElement(TObject *obj, const std::string &name="", bool _hide_childs=false)
Constructor with plain TObject* as argument - ownership is not defined.
void SetObject(TObject *obj)
Constructor with std::unique_ptr<RHolder> as argument.
virtual const TObject * CheckObject() const
Check if object still exists.
void ForgetObject() const
Forget object, use when it was deleted behind the scene.
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.
~TDirectoryElement() override=default
bool cd() override
Select directory as active.
bool fIsFile
! is TFile instance registered in global list of files
EActionKind GetDefaultAction() const override
Get default action - browsing for the TFile/TDirectory.
Long64_t GetSize() const override
Size of TDirectory.
std::string GetContent(const std::string &kind) override
Returns element content, depends from kind.
TDirectory * GetDir() const
std::unique_ptr< RLevelIter > GetChildsIter() override
Provide iterator over TDirectory.
bool IsFolder() const override
Check if element can have childs.
TDirectoryElement(const std::string &fname, TDirectory *dir=nullptr, bool isfile=false)
std::string GetMTime() const override
std::string GetName() const override
Name of TDirectoryElement.
const TObject * CheckObject() const override
Check if object still exists.
std::string fFileName
! file name
std::string GetTitle() const override
Title of TDirectoryElement.
TDirectoryLevelIter(TDirectory *dir)
std::shared_ptr< RElement > GetElement() override
Returns full information for current element.
~TDirectoryLevelIter() override=default
bool fKeysIter
! iterating over keys list (default)
std::string GetItemName() const override
Returns current entry name.
std::unique_ptr< RItem > CreateItem() override
Create item for the client.
TKey * fKey
! currently selected key
std::shared_ptr< RElement > GetDirElement(bool read_dir)
Return element for current TKey object in TDirectory.
std::string fCurrentName
! current key name
std::unique_ptr< TIterator > fIter
! created iterator
bool CanItemHaveChilds() const override
Returns true if current item can have childs.
TDirectory * fDir
! current directory handle
TObject * fObj
! currently selected object
bool Next() override
Shift to next entry.
Describe directory structure in memory.
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
bool IsCapable(EActionKind action) const override
Check if want to perform action.
EActionKind GetDefaultAction() const override
Get default action - browsing for the TFile/TDirectory.
std::unique_ptr< RLevelIter > GetChildsIter() override
Create iterator for childs elements if any Means we should try to browse inside.
std::string GetTitle() const override
Title of TKeyElement (optional).
std::shared_ptr< RElement > fElement
! holder of read object
std::unique_ptr< RHolder > GetObject() override
Return object associated with the TKey.
std::unique_ptr< RItem > CreateItem() const override
Returns item with element description.
~TKeyElement() override=default
Long64_t GetSize() const override
Size of TDirectory.
bool IsFolder() const override
Check if element can have childs.
TKeyElement(TDirectory *dir, TKey *key)
std::string GetMTime() const override
std::string GetName() const override
Name of TKeyElement, includes key cycle.
Book space in a file, create I/O buffers, to fill them, (un)compress them.
const char * GetTitle() const override
Returns title (title can contain 32x32 xpm thumbnail/icon).
virtual const char * GetClassName() const
const TDatime & GetDatime() const
Short_t GetCycle() const
Return cycle number associated to this key.
const char * GetName() const override
Returns name of object.
Mother of all ROOT objects.
@ kInvalidObject
if object ctor succeeded but object should not be used
ROOT::RLogChannel & BrowsableLog()
Log channel for Browsable diagnostics.