EffectSettingValue.h 2.63 KB
Newer Older
1 2 3 4 5
/*****************************************************************************
 * EffectSettingValue.h: Handle an effect instance.
 *****************************************************************************
 * Copyright (C) 2008-2010 VideoLAN
 *
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
6
 * Authors: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
 *
 * 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; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#ifndef EFFECTSETTINGVALUE_H
#define EFFECTSETTINGVALUE_H

#include "SettingValue.h"
#include "frei0r.h"

class   EffectInstance;

class EffectSettingValue : public SettingValue
{
    Q_OBJECT

    public:
        EffectSettingValue( Type type, EffectInstance* instance, quint32 index,
37
                            const char* name, const char* desc, Flags flags = Nothing );
38
        virtual ~EffectSettingValue();
39 40 41

        f0r_param_t     getFrei0rParameter() const;
        virtual void    set( const QVariant& val );
42
        const QVariant  &get();
43
        quint32         index() const;
44 45 46 47 48 49 50 51
        /**
         *  \brief      Force the parameter to apply, even if no change is detected
         *              from VLMC side.
         *
         *  This is usefull when the instance had been destroyed, and the params should
         *  be applied again.
         */
        void            apply();
52 53 54 55 56 57 58 59 60 61
        static Type     frei0rToVlmc( int type );

    private:
        template <typename T>
        void            copyToFrei0rBuff( const T* ptr, quint32 size = sizeof( T ) )
        {
            if ( m_buffSize != size || m_paramBuff == NULL )
            {
                delete[] m_paramBuff; //Won't hurt if paramBuff is NULL
                m_paramBuff = new qint8[size];
62
                m_buffSize = size;
63 64 65 66 67 68 69
            }
            memcpy( m_paramBuff, ptr, size );
        }

    private:
        qint8           *m_paramBuff;
        quint32         m_buffSize;
70
        EffectInstance  *m_effectInstance;
71 72 73 74
        quint32         m_index;
};

#endif // EFFECTSETTINGVALUE_H