Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // @(#)root/eve7:$Id$
0002 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2018
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_REveTableInfo
0013 #define ROOT7_REveTableInfo
0014 
0015 #include <ROOT/REveElement.hxx>
0016 #include <ROOT/REveDataCollection.hxx>
0017 #include <ROOT/REveDataTable.hxx>
0018 
0019 namespace ROOT {
0020 namespace Experimental {
0021 
0022 ///////////////////////////////////////////////////////////////////////////////
0023 /// REveTableEntry
0024 ///////////////////////////////////////////////////////////////////////////////
0025 
0026 class REveTableEntry {
0027 public:
0028    std::string    fName;
0029    int            fPrecision;
0030    std::string    fExpression;
0031    REveDataColumn::FieldType_e fType;
0032 
0033    REveTableEntry() : fName("unknown"), fPrecision(2), fType(REveDataColumn::FT_Double) {}
0034 
0035    REveTableEntry(const std::string &name, int precision, const std::string &expression)
0036       : fName(name), fPrecision(precision), fExpression(expression), fType(REveDataColumn::FT_Double)
0037    {
0038    }
0039 
0040    void Print() const
0041    {
0042       printf("TableEntry\n");
0043       printf("name: %s expression: %s\n", fName.c_str(), fExpression.c_str());
0044    }
0045 };
0046 
0047 ///////////////////////////////////////////////////////////////////////////////
0048 /// REveTableHandle
0049 ///////////////////////////////////////////////////////////////////////////////
0050 
0051 class REveTableHandle
0052 {
0053    friend class REveTableViewInfo;
0054 
0055 public:
0056    typedef std::vector<REveTableEntry> Entries_t;
0057    typedef std::map<std::string, Entries_t> Specs_t;
0058 
0059    // REveTableHandle() {}
0060 
0061    REveTableHandle&
0062    column(const std::string &name, int precision, const std::string &expression)
0063    {
0064       fSpecs[fClassName].emplace_back(name, precision, expression);
0065       return *this;
0066    }
0067 
0068    REveTableHandle &column(const std::string &label, int precision)
0069    {
0070       return column(label, precision, label);
0071    }
0072 
0073    void clearColumnDefinitions(){
0074       fSpecs[fClassName].clear();
0075    }
0076 
0077    REveTableHandle(std::string className, Specs_t &specs)
0078       :fClassName(className), fSpecs(specs)
0079    {
0080    }
0081 
0082 protected:
0083    std::string  fClassName;
0084    Specs_t&  fSpecs;
0085 };
0086 
0087 ///////////////////////////////////////////////////////////////////////////////
0088 /// REveTableViewInfo
0089 ///////////////////////////////////////////////////////////////////////////////
0090 
0091 class REveTableViewInfo : public REveElement
0092 {
0093 public:
0094    REveTableViewInfo(const std::string &name = "TableViewManager", const std::string &title = "");
0095 
0096    typedef std::function<void ()> Delegate_t;
0097 
0098    void SetDisplayedCollection(ElementId_t);
0099    ElementId_t GetDisplayedCollection() const  { return fDisplayedCollection; }
0100 
0101    void AddNewColumnToCurrentCollection(const char* expr, const char* title, int prec = 2);
0102 
0103    void AddDelegate(Delegate_t d) { fDelegates.push_back(d); }
0104 
0105    Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override;
0106 
0107    // read
0108    REveTableHandle::Entries_t &RefTableEntries(std::string cname);
0109 
0110    // filling
0111    REveTableHandle table(std::string className)
0112    {
0113       REveTableHandle handle(className, fSpecs);
0114       return handle;
0115    }
0116 
0117    bool GetConfigChanged() const { return fConfigChanged; }
0118 
0119    REveTableHandle::Specs_t& RefSpecs() { return fSpecs; }
0120 private:
0121    int fDisplayedCollection{0};
0122    std::vector<Delegate_t> fDelegates;
0123    REveTableHandle::Specs_t  fSpecs;
0124    bool                      fConfigChanged{false};
0125 };
0126 
0127 
0128 }
0129 }
0130 
0131 #endif