From c93a293ef89ba6e3ec916e6276a23fe7d74d18c2 Mon Sep 17 00:00:00 2001 From: Joachim Wuttke <j.wuttke@fz-juelich.de> Date: Sat, 20 Jul 2024 11:36:48 +0200 Subject: [PATCH] use it --- GUI/Model/Beam/BeamDistributionItem.h | 11 ++++------- GUI/Model/Detector/DetectorItem.h | 11 ++++------- GUI/Model/Sim/InstrumentItems.h | 16 +++++----------- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/GUI/Model/Beam/BeamDistributionItem.h b/GUI/Model/Beam/BeamDistributionItem.h index faa043b65d8..f4862706b51 100644 --- a/GUI/Model/Beam/BeamDistributionItem.h +++ b/GUI/Model/Beam/BeamDistributionItem.h @@ -36,7 +36,10 @@ public: virtual double scaleFactor() const; - template <typename T> T* setDistributionItemType(); + template <typename T> T* setDistributionItemType() + { + return m_distribution.createCertainItem<T>(); + } DistributionItem* distributionItem() const { return m_distribution.certainItem(); } PolyItem<DistributionsCatalog>& distributionSelection() { return m_distribution; } @@ -46,10 +49,4 @@ protected: PolyItem<DistributionsCatalog> m_distribution; }; -template <typename T> T* BeamDistributionItem::setDistributionItemType() -{ - m_distribution.createCertainItem<T>(); - return dynamic_cast<T*>(m_distribution.certainItem()); -} - #endif // BORNAGAIN_GUI_MODEL_BEAM_BEAMDISTRIBUTIONITEM_H diff --git a/GUI/Model/Detector/DetectorItem.h b/GUI/Model/Detector/DetectorItem.h index dc7869e488b..1027d33551e 100644 --- a/GUI/Model/Detector/DetectorItem.h +++ b/GUI/Model/Detector/DetectorItem.h @@ -38,7 +38,10 @@ public: return m_resolution_function; } - template <typename T> T* setResolutionFunctionType(); + template <typename T> T* setResolutionFunctionType() + { + return m_resolution_function.createCertainItem<T>(); + } void writeTo(QXmlStreamWriter* w) const; void readFrom(QXmlStreamReader* r); @@ -63,10 +66,4 @@ private: std::unique_ptr<MasksSet> m_prjns; //!< projections }; -template <typename T> T* DetectorItem::setResolutionFunctionType() -{ - m_resolution_function.createCertainItem<T>(); - return dynamic_cast<T*>(m_resolution_function.certainItem()); -} - #endif // BORNAGAIN_GUI_MODEL_DETECTOR_DETECTORITEM_H diff --git a/GUI/Model/Sim/InstrumentItems.h b/GUI/Model/Sim/InstrumentItems.h index abe8900b0a2..b391b2a9cef 100644 --- a/GUI/Model/Sim/InstrumentItems.h +++ b/GUI/Model/Sim/InstrumentItems.h @@ -66,7 +66,11 @@ public: template <typename T> bool is() const { return dynamic_cast<const T*>(this) != nullptr; } - template <typename T> T* setBackgroundItemType(); + template <typename T> T* setBackgroundItemType() + { + return m_background.createCertainItem<T>(); + } + PolyItem<BackgroundItemCatalog>& backgroundSelection() { return m_background; } BackgroundItem* backgroundItem() const { return m_background.certainItem(); } @@ -197,14 +201,4 @@ private: AxisProperty m_z_axis; }; - -// ************************************************************************************************ -// templated functions implementation -// ************************************************************************************************ - -template <typename T> T* InstrumentItem::setBackgroundItemType() -{ - return m_background.createCertainItem<T>(); -} - #endif // BORNAGAIN_GUI_MODEL_SIM_INSTRUMENTITEMS_H -- GitLab