summaryrefslogtreecommitdiffstats
path: root/src/effects/effectparameter.h
blob: f6565258fa10a0b16cda5c842adc4962abbadb60 (plain)
1
2
3
4
5
6
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef EFFECTPARAMETER_H
#define EFFECTPARAMETER_H

#include <QObject>
#include <QVariant>

#include "effects/effectmanifestparameter.h"
#include "util/class.h"

class Effect;
class EffectsManager;

// An EffectParameter is an instance of an EffectManifestParameter, which is in
// charge of keeping track of the instance values for the default, minimum,
// maximum and value for each Effect's parameter, and validating that they are
// always within acceptable ranges. This class is NOT thread-safe and must only
// be used from the main thread.
class EffectParameter : public QObject {
    Q_OBJECT
  public:
    EffectParameter(Effect* pEffect, EffectsManager* pEffectsManager,
                    int iParameterNumber, EffectManifestParameterPointer pParameter);
    virtual ~EffectParameter();

    void addToEngine();
    void removeFromEngine();

    ///////////////////////////////////////////////////////////////////////////
    // Parameter Information
    ///////////////////////////////////////////////////////////////////////////

    EffectManifestParameterPointer manifest() const;
    const QString& id() const;
    const QString& name() const;
    const QString& shortName() const;
    const QString& description() const;

    ///////////////////////////////////////////////////////////////////////////
    // Value Settings
    ///////////////////////////////////////////////////////////////////////////

    EffectManifestParameter::LinkType getDefaultLinkType() const;
    EffectManifestParameter::LinkInversion getDefaultLinkInversion() const;
    double getNeutralPointOnScale() const;

    double getValue() const;

    void setValue(double value);

    double getDefault() const;
    void setDefault(double defaultValue);

    double getMinimum() const;
    void setMinimum(double minimum);

    double getMaximum() const;
    void setMaximum(double maximum);

    EffectManifestParameter::ControlHint getControlHint() const;

    void updateEngineState();

  signals:
    void valueChanged(double value);

  private:
    QString debugString() const {
        return QString("EffectParameter(%1)").arg(m_pParameter->name());
    }

    static bool clampValue(double* pValue,
                           const double& minimum, const double& maximum);
    bool clampValue();
    bool clampDefault();
    bool clampRanges();

    Effect* m_pEffect;
    EffectsManager* m_pEffectsManager;
    int m_iParameterNumber;
    EffectManifestParameterPointer m_pParameter;
    double m_minimum;
    double m_maximum;
    double m_default;
    double m_value;
    bool m_bAddedToEngine;

    DISALLOW_COPY_AND_ASSIGN(EffectParameter);
};


#endif /* EFFECTPARAMETER_H */