Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:46

0001 #ifndef Fireworks_FWInterface_FWPSetTableManager_h
0002 #define Fireworks_FWInterface_FWPSetTableManager_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     FWInterface
0006 // Class  :     FWPSetTableManager
0007 //
0008 /**\class FWPSetTableManager FWPSetTableManager.h Fireworks/FWInterface/interface/FWPSetTableManager.h
0009 
0010  Description: [one line class summary]
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Original Author:
0018 //         Created:  Mon Feb 28 17:06:50 CET 2011
0019 //
0020 
0021 // system include files
0022 
0023 #include <sigc++/sigc++.h>
0024 #include "Fireworks/TableWidget/interface/FWTableManagerBase.h"
0025 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0026 #include "Fireworks/TableWidget/interface/FWTextTreeCellRenderer.h"
0027 
0028 class FWPSetCellEditor;
0029 namespace edm {
0030   class ScheduleInfo;
0031 }
0032 
0033 class FWPSetTableManager : public FWTableManagerBase {
0034   friend class FWPathsPopup;
0035 
0036 public:
0037   /** Custom structure for holding the table contents */
0038   struct PSetData {
0039     PSetData()
0040         : level(-1),
0041           tracked(false),
0042 
0043           type(-1),
0044 
0045           parent(-1),
0046 
0047           module(-1),
0048           path(-1),
0049 
0050           expandedUser(false),
0051           expandedFilter(false),
0052 
0053           visible(false),
0054 
0055           matches(false),
0056           childMatches(false),
0057 
0058           editable(false),
0059           pset(nullptr) {}
0060 
0061     std::string label;
0062     std::string value;
0063 
0064     int level;
0065     bool tracked;
0066     char type;
0067     size_t parent;
0068 
0069     size_t module;
0070     size_t path;
0071 
0072     bool expandedUser;
0073     bool expandedFilter;
0074 
0075     bool visible;
0076     bool matches;
0077     bool childMatches;
0078     bool editable;
0079 
0080     edm::ParameterSet *pset;
0081   };
0082 
0083   FWPSetTableManager();
0084   ~FWPSetTableManager() override;
0085   FWPSetTableManager(const FWPSetTableManager &) = delete;                   // stop default
0086   const FWPSetTableManager &operator=(const FWPSetTableManager &) = delete;  // stop default
0087 
0088   int unsortedRowNumber(int unsorted) const override;
0089   int numberOfRows() const override;
0090   int numberOfColumns() const override;
0091   std::vector<std::string> getTitles() const override;
0092   virtual const std::string title() const;
0093   FWTableCellRendererBase *cellRenderer(int iSortedRowNumber, int iCol) const override;
0094 
0095   int selectedRow() const;
0096   int selectedColumn() const;
0097   virtual bool rowIsSelected(int row) const;
0098 
0099   void implSort(int, bool) override;
0100   bool cellDataIsSortable() const override { return false; }
0101 
0102   virtual void updateFilter(const char *filter);
0103 
0104   std::vector<unsigned int> maxWidthForColumns() const override;
0105 
0106   std::vector<PSetData> &data() { return m_entries; }
0107   std::vector<int> &rowToIndex() { return m_row_to_index; }
0108 
0109   //______________________________________________________________________________
0110 
0111 protected:
0112   struct ModuleInfo {
0113     /** The path this info is associated to, as ordered in
0114           availablePath(); 
0115       */
0116     size_t pathIndex;
0117     size_t path;
0118     size_t entry;
0119     bool passed;
0120     /** Whether or not the pset was modified since last time the 
0121           looper reloaded. 
0122       */
0123     bool dirty;
0124 
0125     edm::ParameterSet *orig_pset;
0126     edm::ParameterSet *current_pset;
0127   };
0128 
0129   /** Datum for updating the path status information */
0130   struct PathUpdate {
0131     std::string pathName;
0132     bool passed;
0133     size_t choiceMaker;
0134   };
0135 
0136   void setExpanded(int row);
0137   void updateSchedule(const edm::ScheduleInfo *info);
0138   void update(std::vector<PathUpdate> &pathUpdates);
0139 
0140   bool applyEditor();
0141   void cancelEditor();
0142 
0143   std::vector<ModuleInfo> &modules() { return m_modules; }
0144   std::vector<PSetData> &entries() { return m_entries; }
0145 
0146   void setSelection(int row, int column, int mask);
0147   //______________________________________________________________________________
0148 
0149 private:
0150   /** Model for additional path information */
0151   struct PathInfo {
0152     std::string pathName;
0153     size_t entryId;
0154     int modulePassed;
0155     size_t moduleStart;
0156     size_t moduleEnd;
0157     bool passed;
0158   };
0159 
0160   void recalculateVisibility();
0161 
0162   template <class T>
0163   void createScalarString(PSetData &data, T v);
0164   template <typename T>
0165   void createVectorString(FWPSetTableManager::PSetData &data, const T &v, bool quotes);
0166 
0167   void setCellValueEditor(FWPSetCellEditor *editor);
0168 
0169   void handleEntry(const edm::Entry &entry, const std::string &key);
0170   void handlePSetEntry(edm::ParameterSetEntry &entry, const std::string &key);
0171   void handleVPSetEntry(edm::VParameterSetEntry &entry, const std::string &key);
0172   void handlePSet(edm::ParameterSet *psp);
0173 
0174   std::vector<PSetData> m_entries;
0175   /** Index in m_entries where to find paths */
0176   std::vector<PathInfo> m_paths;
0177   std::vector<ModuleInfo> m_modules;
0178   std::map<std::string, size_t> m_pathIndex;
0179   std::vector<size_t> m_parentStack;
0180   std::vector<int> m_row_to_index;
0181   int m_selectedRow;
0182   int m_selectedColumn;
0183   std::string m_filter;
0184   FWPSetCellEditor *m_editor;
0185   std::vector<std::string> m_availablePaths;
0186 
0187   mutable FWTextTreeCellRenderer m_renderer;
0188 };
0189 
0190 #endif