diff --git a/include/AutomatableModel.h b/include/AutomatableModel.h index 37796177e..9c24fd9bb 100644 --- a/include/AutomatableModel.h +++ b/include/AutomatableModel.h @@ -372,32 +372,35 @@ signals: +template class EXPORT TypedAutomatableModel : public AutomatableModel +{ +public: + using AutomatableModel::AutomatableModel; + T value( int frameOffset = 0 ) const + { + return AutomatableModel::value( frameOffset ); + } -#define defaultTypedMethods(type) \ - type value( int frameOffset = 0 ) const \ - { \ - return AutomatableModel::value( frameOffset ); \ - } \ - \ - type initValue() const \ - { \ - return AutomatableModel::initValue(); \ - } \ - \ - type minValue() const \ - { \ - return AutomatableModel::minValue(); \ - } \ - \ - type maxValue() const \ - { \ - return AutomatableModel::maxValue(); \ - } \ + T initValue() const + { + return AutomatableModel::initValue(); + } + + T minValue() const + { + return AutomatableModel::minValue(); + } + + T maxValue() const + { + return AutomatableModel::maxValue(); + } +}; // some typed AutomatableModel-definitions -class EXPORT FloatModel : public AutomatableModel +class EXPORT FloatModel : public TypedAutomatableModel { Q_OBJECT public: @@ -405,17 +408,15 @@ public: Model * parent = NULL, const QString& displayName = QString(), bool defaultConstructed = false ) : - AutomatableModel( Float, val, min, max, step, parent, displayName, defaultConstructed ) + TypedAutomatableModel( Float, val, min, max, step, parent, displayName, defaultConstructed ) { } float getRoundedValue() const; int getDigitCount() const; - defaultTypedMethods(float); - } ; -class EXPORT IntModel : public AutomatableModel +class EXPORT IntModel : public TypedAutomatableModel { Q_OBJECT public: @@ -423,16 +424,13 @@ public: Model* parent = NULL, const QString& displayName = QString(), bool defaultConstructed = false ) : - AutomatableModel( Integer, val, min, max, 1, parent, displayName, defaultConstructed ) + TypedAutomatableModel( Integer, val, min, max, 1, parent, displayName, defaultConstructed ) { } - - defaultTypedMethods(int); - } ; -class EXPORT BoolModel : public AutomatableModel +class EXPORT BoolModel : public TypedAutomatableModel { Q_OBJECT public: @@ -440,12 +438,9 @@ public: Model* parent = NULL, const QString& displayName = QString(), bool defaultConstructed = false ) : - AutomatableModel( Bool, val, false, true, 1, parent, displayName, defaultConstructed ) + TypedAutomatableModel( Bool, val, false, true, 1, parent, displayName, defaultConstructed ) { } - - defaultTypedMethods(bool); - } ; typedef QMap AutomatedValueMap;