Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-03 04:09:59

0001 #ifndef Fireworks_Core_FWSimpleProxyBuilderTemplate_h
0002 #define Fireworks_Core_FWSimpleProxyBuilderTemplate_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     Core
0006 // Class  :     FWSimpleProxyBuilderTemplate
0007 //
0008 /**\class FWSimpleProxyBuilderTemplate FWSimpleProxyBuilderTemplate.h Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h
0009 
0010    Description: <one line class summary>
0011 
0012    Usage:
0013     <usage>
0014 
0015  */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Tue Dec  2 11:20:00 EST 2008
0019 //
0020 
0021 // system include files
0022 
0023 // user include files
0024 #include "Fireworks/Core/interface/FWSimpleProxyBuilder.h"
0025 #include "Fireworks/Core/interface/FWEventItem.h"
0026 
0027 // forward declarations
0028 
0029 template <typename T>
0030 class FWSimpleProxyBuilderTemplate : public FWSimpleProxyBuilder {
0031 public:
0032   FWSimpleProxyBuilderTemplate() : FWSimpleProxyBuilder(typeid(T)) {}
0033 
0034   //virtual ~FWSimpleProxyBuilderTemplate();
0035 
0036   // ---------- const member functions ---------------------
0037 
0038   // ---------- static member functions --------------------
0039 
0040   // ---------- member functions ---------------------------
0041 
0042 protected:
0043   const T& modelData(int index) { return *reinterpret_cast<const T*>(m_helper.offsetObject(item()->modelData(index))); }
0044 
0045   using FWSimpleProxyBuilder::build;
0046   void build(const void* iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext* context) override {
0047     if (nullptr != iData) {
0048       build(*reinterpret_cast<const T*>(iData), iIndex, oItemHolder, context);
0049     }
0050   }
0051 
0052   using FWSimpleProxyBuilder::buildViewType;
0053   void buildViewType(const void* iData,
0054                      unsigned int iIndex,
0055                      TEveElement& oItemHolder,
0056                      FWViewType::EType viewType,
0057                      const FWViewContext* context) override {
0058     if (nullptr != iData) {
0059       buildViewType(*reinterpret_cast<const T*>(iData), iIndex, oItemHolder, viewType, context);
0060     }
0061   }
0062   /**iIndex is the index where iData is found in the container from which it came
0063       iItemHolder is the object to which you add your own objects which inherit from TEveElement
0064    */
0065   virtual void build(const T& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) {
0066     throw std::runtime_error(
0067         "virtual build(const T&, unsigned int, TEveElement&, const FWViewContext*) not implemented by inherited "
0068         "class.");
0069   }
0070 
0071   virtual void buildViewType(
0072       const T& iData, unsigned int iIndex, TEveElement& oItemHolder, FWViewType::EType viewType, const FWViewContext*) {
0073     throw std::runtime_error(
0074         "virtual buildViewType(const T&, unsigned int, TEveElement&, FWViewType::EType, const FWViewContext*) not "
0075         "implemented by inherited class");
0076   };
0077 
0078 public:
0079   FWSimpleProxyBuilderTemplate(const FWSimpleProxyBuilderTemplate&) = delete;  // stop default
0080 
0081   const FWSimpleProxyBuilderTemplate& operator=(const FWSimpleProxyBuilderTemplate&) = delete;  // stop default
0082 
0083   // ---------- member data --------------------------------
0084 };
0085 
0086 #endif