Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 #ifndef Fireworks_Core_FWTableViewManager_h
0003 #define Fireworks_Core_FWTableViewManager_h
0004 //
0005 // Package:     Core
0006 // Class  :     FWTableViewManager
0007 //
0008 /**\class FWTableViewManager FWTableViewManager.h Fireworks/Core/interface/FWTableViewManager.h
0009 
0010    Description: Base class for a Manger for a specific type of View
0011 
0012    Usage:
0013    <usage>
0014 
0015 */
0016 //
0017 // Original Author:
0018 //         Created:  Sat Jan  5 10:29:00 EST 2008
0019 //
0020 
0021 // system include files
0022 #include <string>
0023 #include <vector>
0024 #include <set>
0025 #include <map>
0026 #include "FWCore/Reflection/interface/TypeWithDict.h"
0027 
0028 // user include files
0029 
0030 #include "Fireworks/Core/interface/FWViewManagerBase.h"
0031 #include "Fireworks/Core/interface/FWTableView.h"
0032 #include "Fireworks/Core/interface/FWConfigurable.h"
0033 
0034 class FWViewBase;
0035 class FWGUIManager;
0036 class TEveWindowSlot;
0037 
0038 class FWTableViewManager : public FWViewManagerBase, public FWConfigurable {
0039   friend class FWTableView;
0040   friend class FWTableViewTableManager;
0041 
0042 public:
0043   struct TableEntry {
0044     enum { INT = 0, INT_HEX = -1, BOOL = -2 };
0045     std::string expression;
0046     std::string name;
0047     int precision;
0048   };
0049 
0050   /** Container for the event items which have a table. */
0051   typedef std::vector<const FWEventItem *> Items;
0052   /** Container for the description of the columns of a given table. */
0053   typedef std::vector<TableEntry> TableEntries;
0054   /** Type for the collection specific (i.e. those that do not use
0055        default) table definition. */
0056   typedef std::map<std::string, TableEntries> TableSpecs;
0057 
0058   FWTableViewManager(FWGUIManager *);
0059   ~FWTableViewManager() override;
0060 
0061   // ---------- const member functions ---------------------
0062   FWTypeToRepresentations supportedTypesAndRepresentations() const override;
0063   // ---------- static member functions --------------------
0064 
0065   // ---------- member functions ---------------------------
0066   void newItem(const FWEventItem *) override;
0067   void destroyItem(const FWEventItem *item);
0068   void removeAllItems(void);
0069   FWViewBase *buildView(TEveWindowSlot *iParent, const std::string &type);
0070   const Items &items() const { return m_items; }
0071   TableSpecs::iterator tableFormats(const edm::TypeWithDict &key);
0072   TableSpecs::iterator tableFormats(const TClass &key);
0073   void addTo(FWConfiguration &) const override;
0074   void addToImpl(FWConfiguration &) const;
0075   void setFrom(const FWConfiguration &) override;
0076 
0077   void notifyViews();
0078 
0079   static const std::string kConfigTypeNames;
0080   static const std::string kConfigColumns;
0081 
0082 protected:
0083   FWTableViewManager();
0084 
0085   /** Called when models have changed and so the display must be updated. */
0086   void modelChangesComing() override;
0087   void modelChangesDone() override;
0088   void colorsChanged() override;
0089   void dataChanged();
0090 
0091   typedef std::vector<std::shared_ptr<FWTableView> > Views;
0092 
0093   Views m_views;
0094   Items m_items;
0095   TableSpecs m_tableFormats;
0096 
0097 private:
0098   TableSpecs::iterator tableFormatsImpl(const edm::TypeWithDict &key);
0099   FWTableViewManager(const FWTableViewManager &);                   // stop default
0100   const FWTableViewManager &operator=(const FWTableViewManager &);  // stop default
0101 
0102   void beingDestroyed(const FWViewBase *);
0103 
0104   class TableHandle {
0105   public:
0106     TableHandle &column(const char *formula, int precision, const char *name);
0107     TableHandle &column(const char *label, int precision) { return column(label, precision, label); }
0108 
0109     TableHandle(const char *name, TableSpecs &specs) : m_name(name), m_specs(specs) { m_specs[name].clear(); }
0110 
0111   private:
0112     std::string m_name;
0113     TableSpecs &m_specs;
0114   };
0115 
0116   TableHandle table(const char *collection);
0117 };
0118 
0119 #endif