Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-13 10:26:50

0001 // Author: Sergey Linev <S.Linev@gsi.de>
0002 // Date: 2019-10-14
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT7_RBrowserData
0013 #define ROOT7_RBrowserData
0014 
0015 #include <ROOT/Browsable/RElement.hxx>
0016 
0017 #include <ROOT/RBrowserRequest.hxx>
0018 #include <ROOT/RBrowserReply.hxx>
0019 
0020 #include <memory>
0021 #include <string>
0022 #include <vector>
0023 #include <utility>
0024 
0025 namespace ROOT {
0026 
0027 class RLogChannel;
0028 
0029 /// Log channel for Browser diagnostics.
0030 ROOT::RLogChannel &BrowserLog();
0031 
0032 class RBrowserDataCleanup;
0033 
0034 class RBrowserData {
0035 
0036    friend class RBrowserDataCleanup;
0037 
0038    std::shared_ptr<Browsable::RElement> fTopElement;    ///<! top element
0039 
0040    Browsable::RElementPath_t  fWorkingPath;             ///<! path showed in Breadcrumb
0041 
0042    std::vector<std::pair<Browsable::RElementPath_t, std::shared_ptr<Browsable::RElement>>> fCache; ///<! already requested elements
0043 
0044    Browsable::RElementPath_t fLastPath;                  ///<! path to last used element
0045    std::shared_ptr<Browsable::RElement> fLastElement;    ///<! last element used in request
0046    std::vector<std::unique_ptr<Browsable::RItem>> fLastItems; ///<! created browser items - used in requests
0047    bool fLastAllChilds{false};                           ///<! if all chlds were extracted
0048    std::vector<const Browsable::RItem *> fLastSortedItems;   ///<! sorted child items, used in requests
0049    std::string fLastSortMethod;                          ///<! last sort method
0050    bool fLastSortReverse{false};                         ///<! last request reverse order
0051    std::unique_ptr<RBrowserDataCleanup> fCleanupHandle;  ///<! cleanup handle for RecursiveRemove
0052 
0053    void ResetLastRequestData(bool with_element);
0054 
0055    bool ProcessBrowserRequest(const RBrowserRequest &request, RBrowserReply &reply);
0056 
0057 public:
0058    RBrowserData();
0059 
0060    RBrowserData(std::shared_ptr<Browsable::RElement> elem) : RBrowserData()  { SetTopElement(elem); }
0061 
0062    virtual ~RBrowserData();
0063 
0064    void SetTopElement(std::shared_ptr<Browsable::RElement> elem);
0065 
0066    void SetWorkingPath(const Browsable::RElementPath_t &path);
0067 
0068    void CreateDefaultElements();
0069 
0070    const Browsable::RElementPath_t &GetWorkingPath() const { return fWorkingPath; }
0071 
0072    std::string ProcessRequest(const RBrowserRequest &request);
0073 
0074    std::shared_ptr<Browsable::RElement> GetElement(const std::string &str);
0075    std::shared_ptr<Browsable::RElement> GetElementFromTop(const Browsable::RElementPath_t &path);
0076 
0077    Browsable::RElementPath_t DecomposePath(const std::string &path, bool relative_to_work_element);
0078    std::shared_ptr<Browsable::RElement> GetSubElement(const Browsable::RElementPath_t &path);
0079 
0080    void ClearCache();
0081 
0082    bool RemoveFromCache(void *obj);
0083 
0084    bool RemoveFromCache(const Browsable::RElementPath_t &path);
0085 
0086 };
0087 
0088 
0089 } // namespace ROOT
0090 
0091 #endif