Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:36

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