32using namespace std::string_literals;
70 auto comp = std::make_shared<Browsable::RGroup>(
"top",
"Root browser");
74 std::unique_ptr<Browsable::RHolder> rootfold = std::make_unique<Browsable::TObjectHolder>(
gROOT->GetRootFolder(),
kFALSE);
77 comp->Add(std::make_shared<Browsable::RWrapper>(
"root", elem_root));
79 std::unique_ptr<Browsable::RHolder> rootfiles = std::make_unique<Browsable::TObjectHolder>(
gROOT->GetListOfFiles(),
kFALSE);
82 auto files = std::make_shared<Browsable::RWrapper>(
"ROOT Files", elem_files);
83 files->SetExpandByDefault(
true);
86 if (elem_files->GetNumChilds() > 0)
124 arr.insert(arr.end(), arr2.begin(), arr2.end());
134 path.insert(path.end(), request.
path.begin(), request.
path.end());
139 if (!elem)
return false;
147 }
else if (request.
reload) {
157 if (!iter)
return false;
177 if (request.
sort.empty()) {
180 if (item->IsFolder())
183 if (!item->IsFolder())
190 if (request.
sort !=
"unsorted")
202 const std::regex expr(request.
regex);
208 if (!request.
hidden && item->IsHidden())
211 if (!request.
regex.empty() && !item->IsFolder() && !std::regex_match(item->GetName(), expr))
215 reply.
nodes.emplace_back(item);
269 for (
auto &entry :
fCache)
270 if (entry.first == path)
277 for (
auto &entry :
fCache) {
278 if (entry.first.size() >= path.size())
283 if ((comp > pos) && (comp == (
int) entry.first.size())) {
289 while (pos < (
int) path.size()) {
290 std::string subname = path[pos];
293 auto iter = elem->GetChildsIter();
297 if (!iter->Find(subname, indx)) {
300 iter = elem->GetChildsIter();
301 if (!iter || !iter->Find(subname))
305 elem = iter->GetElement();
311 subpath.resize(pos+1);
312 fCache.emplace_back(subpath, elem);
static int ExtractItemIndex(std::string &name)
Extract index from name Index coded by client with ###<indx>$$$ suffix Such coding used by browser to...
static int ComparePaths(const RElementPath_t &path1, const RElementPath_t &path2)
Compare two paths, Returns number of elements matches in both paths.
static RElementPath_t ParsePath(const std::string &str)
Parse string path to produce RElementPath_t One should avoid to use string pathes as much as possible...
Representation of single item in the browser.
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 RElementPath_t ProvideTopEntries(std::shared_ptr< RGroup > &comp, const std::string &workdir="")
Provide top entries for file system On windows it is list of existing drivers, on Linux it is "Files ...
void SetTopElement(std::shared_ptr< Browsable::RElement > elem)
set top element for browsing
std::string fLastSortMethod
! last sort method
std::shared_ptr< Browsable::RElement > GetSubElement(const Browsable::RElementPath_t &path)
Returns sub-element starting from top, using cached data.
Browsable::RElementPath_t DecomposePath(const std::string &path, bool relative_to_work_element)
Decompose path to elements Returns array of names for each element in the path, first element either ...
bool ProcessBrowserRequest(const RBrowserRequest &request, RBrowserReply &reply)
Process browser request.
std::vector< std::pair< Browsable::RElementPath_t, std::shared_ptr< Browsable::RElement > > > fCache
! already requested elements
std::shared_ptr< Browsable::RElement > GetElementFromTop(const Browsable::RElementPath_t &path)
Returns element with path, specified as Browsable::RElementPath_t.
void ClearCache()
Clear internal objects cache.
std::vector< const Browsable::RItem * > fLastSortedItems
! sorted child items, used in requests
bool fLastAllChilds
! if all chlds were extracted
std::string ProcessRequest(const RBrowserRequest &request)
Process browser request, returns string with JSON of RBrowserReply data.
Browsable::RElementPath_t fWorkingPath
! path showed in Breadcrumb
bool fLastSortReverse
! last request reverse order
Browsable::RElementPath_t fLastPath
! path to last used element
std::shared_ptr< Browsable::RElement > fTopElement
! top element
void SetWorkingPath(const Browsable::RElementPath_t &path)
set working directory relative to top element
std::shared_ptr< Browsable::RElement > fLastElement
! last element used in request
std::shared_ptr< Browsable::RElement > GetElement(const std::string &str)
Returns element with path, specified as string.
std::vector< std::unique_ptr< Browsable::RItem > > fLastItems
! created browser items - used in requests
void ResetLastRequestData(bool with_element)
Reset all data correspondent to last request.
void CreateDefaultElements()
Create default elements shown in the RBrowser.
Reply on browser request.
std::vector< const Browsable::RItem * > nodes
list of pointers, no ownership!
std::vector< std::string > path
reply path
int nchilds
total number of childs in the node
int first
first node in returned list
Request send from client to get content of path element.
bool reverse
reverse item order
bool hidden
show hidden files
std::vector< std::string > path
requested path
bool reload
force items reload
int first
first child to request
int number
number of childs to request, 0 - all childs
std::string sort
kind of sorting
std::string regex
applied regex
A log configuration for a channel, e.g.
static TString ToJSON(const T *obj, Int_t compact=0, const char *member_name=nullptr)
@ kSkipTypeInfo
do not store typenames in JSON
@ kNoSpaces
no new lines plus remove all spaces around "," and ":" symbols
const char * Data() const
std::vector< std::string > RElementPath_t
RLogChannel & BrowserLog()
Log channel for Browser diagnostics.