CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/Fireworks/FWInterface/src/FWPSetTableManager.h

Go to the documentation of this file.
00001 #ifndef Fireworks_FWInterface_FWPSetTableManager_h
00002 #define Fireworks_FWInterface_FWPSetTableManager_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     FWInterface
00006 // Class  :     FWPSetTableManager
00007 // 
00016 //
00017 // Original Author:  
00018 //         Created:  Mon Feb 28 17:06:50 CET 2011
00019 // $Id: FWPSetTableManager.h,v 1.11 2012/09/08 06:13:57 amraktad Exp $
00020 //
00021 
00022 // system include files
00023 
00024 
00025 #include <sigc++/sigc++.h>
00026 #include "Fireworks/TableWidget/interface/FWTableManagerBase.h"
00027 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00028 #include "Fireworks/TableWidget/interface/FWTextTreeCellRenderer.h"
00029 
00030 class FWPSetCellEditor;
00031 namespace edm 
00032 {
00033    class ScheduleInfo;
00034 }
00035 
00036 
00037 
00038 class FWPSetTableManager : public FWTableManagerBase 
00039 {
00040    friend class FWPathsPopup;
00041 
00042 public: 
00044    struct PSetData
00045    {
00046       PSetData() :level(-1),
00047          tracked(false),
00048 
00049          type(-1),
00050    
00051          parent(-1),
00052 
00053          module(-1),
00054          path(-1),
00055 
00056          expandedUser(false),
00057          expandedFilter(false),
00058 
00059          visible(false),
00060 
00061          matches(false),
00062          childMatches(false),
00063 
00064        editable(false) , pset(0){}
00065 
00066       std::string label;
00067       std::string value;
00068 
00069       int         level;
00070       bool        tracked;
00071       char        type;
00072       size_t      parent;
00073    
00074       size_t      module;
00075       size_t      path;
00076 
00077       bool        expandedUser;
00078       bool        expandedFilter;
00079 
00080       bool        visible;
00081       bool        matches;
00082       bool        childMatches;
00083       bool        editable;
00084 
00085       edm::ParameterSet *pset;
00086    };
00087 
00088    FWPSetTableManager();
00089    virtual ~FWPSetTableManager();
00090 
00091 
00092    virtual int unsortedRowNumber(int unsorted) const ;
00093    virtual int numberOfRows() const;
00094    virtual int numberOfColumns() const;
00095    virtual std::vector<std::string> getTitles() const;
00096    virtual const std::string title() const;
00097    virtual FWTableCellRendererBase* cellRenderer(int iSortedRowNumber, int iCol) const;
00098 
00099    int selectedRow() const;
00100    int selectedColumn() const;
00101    virtual bool rowIsSelected(int row) const;
00102 
00103    virtual void implSort(int, bool);
00104    virtual bool cellDataIsSortable() const { return false ; }
00105 
00106    virtual void updateFilter(const char *filter);
00107 
00108    virtual std::vector<unsigned int> maxWidthForColumns() const;
00109 
00110    std::vector<PSetData> &data()  { return m_entries; }
00111    std::vector<int> &rowToIndex() { return m_row_to_index; }
00112   
00113    //______________________________________________________________________________
00114 
00115 protected:
00116    struct ModuleInfo
00117    {
00121       size_t            pathIndex;
00122       size_t            path;
00123       size_t            entry;
00124       bool              passed;
00128       bool              dirty;
00129 
00130      edm::ParameterSet *orig_pset;
00131      edm::ParameterSet *current_pset;
00132    };
00133 
00135    struct PathUpdate
00136    {
00137       std::string pathName;
00138       bool passed;
00139       size_t  choiceMaker;
00140    };
00141 
00142 
00143    void setExpanded(int row);
00144    void updateSchedule(const edm::ScheduleInfo *info);
00145    void update(std::vector<PathUpdate> &pathUpdates);
00146 
00147    bool applyEditor();
00148    void cancelEditor();
00149 
00150    std::vector<ModuleInfo> &modules() { return m_modules; }
00151    std::vector<PSetData>   &entries() { return m_entries; }
00152 
00153    void  setSelection (int row, int column, int mask);
00154    //______________________________________________________________________________
00155 
00156 private: 
00157 
00159    struct PathInfo
00160    {
00161       std::string pathName;
00162       size_t      entryId;
00163       int         modulePassed;
00164       size_t      moduleStart;
00165       size_t      moduleEnd;
00166       bool        passed;
00167    };
00168 
00169    FWPSetTableManager(const FWPSetTableManager&); // stop default
00170    const FWPSetTableManager& operator=(const FWPSetTableManager&); // stop default
00171 
00172    void recalculateVisibility();
00173 
00174    template <class T> void createScalarString(PSetData &data, T v);
00175    template <typename T> void createVectorString(FWPSetTableManager::PSetData &data, const T &v, bool quotes);
00176 
00177    void setCellValueEditor(FWPSetCellEditor *editor);
00178 
00179    void handleEntry(const edm::Entry &entry,const std::string &key);
00180    void handlePSetEntry(edm::ParameterSetEntry& entry, const std::string& key);
00181    void handleVPSetEntry(edm::VParameterSetEntry& entry, const std::string& key);
00182    void handlePSet(edm::ParameterSet *psp);
00183 
00184    std::vector<PSetData>           m_entries;
00186    std::vector<PathInfo>           m_paths;
00187    std::vector<ModuleInfo>         m_modules;
00188    std::map<std::string, size_t>   m_pathIndex;
00189    std::vector<size_t>             m_parentStack;
00190    std::vector<int>                m_row_to_index;
00191    int                             m_selectedRow;
00192    int                             m_selectedColumn;
00193    std::string                     m_filter;
00194    FWPSetCellEditor               *m_editor;
00195    std::vector<std::string>        m_availablePaths;
00196 
00197    mutable FWTextTreeCellRenderer m_renderer;  
00198 };
00199 
00200 
00201 #endif