From be604b1d680ab74d15f6e65f22d8d5fec03ca124 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sat, 26 Jan 2008 00:42:39 +0000 Subject: [PATCH] added transformableAutoModel-class which is not used yet but might be helpful in some cases in the future git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/branches/lmms-mv@672 0778d3d1-df1d-0410-868b-ea421aaaa00d --- include/transformable_auto_model.h | 91 ++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 include/transformable_auto_model.h diff --git a/include/transformable_auto_model.h b/include/transformable_auto_model.h new file mode 100644 index 000000000..b8ffb8985 --- /dev/null +++ b/include/transformable_auto_model.h @@ -0,0 +1,91 @@ +/* + * transformable_auto_model.h - template transformableAutoModel + * + * Copyright (c) 2008 Tobias Doerffel + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + + +#ifndef _TRANSFORMABLE_AUTO_MODEL_H +#define _TRANSFORMABLE_AUTO_MODEL_H + +#include "automatable_model.h" +//#include "automatable_model_templates.h" + + +template +struct AutoModelTransformer +{ + inline virtual T transform( const T & _val ) const + { + return( _val ); + } +} ; + + +template +class transformableAutoModel : public automatableModel +{ +public: + transformableAutoModel( const AutoModelTransformer * _transformer, + const T _val = 0, + const T _min = 0, + const T _max = 0, + const T _step = defaultRelStep(), + ::model * _parent = NULL, + bool _default_constructed = FALSE ) : + automatableModel( _val, _min, _max, _step, _parent, + _default_constructed ), + m_transformer( _transformer ) + { + } + + inline virtual ~transformableAutoModel() + { + } + + inline virtual void setValue( const T _value ) + { + autoModel::setValue( _value ); + if( m_transformer != NULL ) + { + m_transformedValue = m_transformer->transform( + autoModel::value() ); + } + else + { + m_transformedValue = autoModel::value(); + } + } + + inline virtual T value( void ) const + { + return( m_transformedValue ); + } + +private: + T m_transformedValue; + const AutoModelTransformer * m_transformer; + +} ; + + +#endif +