File indexing completed on 2024-04-06 12:11:32
0001 #ifndef Fireworks_Core_FWSimpleProxyBuilderTemplate_h
0002 #define Fireworks_Core_FWSimpleProxyBuilderTemplate_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #include "Fireworks/Core/interface/FWSimpleProxyBuilder.h"
0025 #include "Fireworks/Core/interface/FWEventItem.h"
0026
0027
0028
0029 template <typename T>
0030 class FWSimpleProxyBuilderTemplate : public FWSimpleProxyBuilder {
0031 public:
0032 FWSimpleProxyBuilderTemplate() : FWSimpleProxyBuilder(typeid(T)) {}
0033
0034
0035
0036
0037
0038
0039
0040
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
0063
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;
0080
0081 const FWSimpleProxyBuilderTemplate& operator=(const FWSimpleProxyBuilderTemplate&) = delete;
0082
0083
0084 };
0085
0086 #endif