From 45f9fc03c21368d24d27b49b46611b09753c8c9a Mon Sep 17 00:00:00 2001 From: Colin Wallace Date: Tue, 13 Mar 2018 20:17:00 -0700 Subject: [PATCH] Make *ModelView a templated type instead of macro-based class. Among other things, this makes it easier to grep for FloatModelView, BoolModelView, IntModelView in the code base. --- include/AutomatableModelView.h | 44 ++++++++++++++++------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/include/AutomatableModelView.h b/include/AutomatableModelView.h index e24d895cb..81e466da5 100644 --- a/include/AutomatableModelView.h +++ b/include/AutomatableModelView.h @@ -1,5 +1,6 @@ /* - * AutomatableModelView.h - class AutomatableModelView + * AutomatableModelView.h - provides AutomatableModelView base class and + * provides BoolModelView, FloatModelView, IntModelView subclasses. * * Copyright (c) 2008-2014 Tobias Doerffel * @@ -101,31 +102,26 @@ protected: +template class EXPORT TypedModelView : public AutomatableModelView +{ +public: + TypedModelView( Model* model, QWidget* _this) : + AutomatableModelView( model, _this ) + {} -#define generateTypedModelView(type) \ -class EXPORT type##ModelView : public AutomatableModelView \ -{ \ -public: \ - type##ModelView( Model* model, QWidget* _this ) : \ - AutomatableModelView( model, _this ) \ - { \ - } \ - \ - type##Model* model() \ - { \ - return castModel(); \ - } \ - \ - const type##Model* model() const \ - { \ - return castModel(); \ - } \ -} + ModelType* model() + { + return castModel(); + } + const ModelType* model() const + { + return castModel(); + } +}; - -generateTypedModelView(Float); -generateTypedModelView(Int); -generateTypedModelView(Bool); +using FloatModelView = TypedModelView; +using IntModelView = TypedModelView; +using BoolModelView = TypedModelView; #endif