8
#include <QAtomicPointer>
10
#include "control/controlbehavior.h"
11
#include "control/controlvalue.h"
12
#include "configobject.h"
14
class ControlDoublePrivate : public QObject {
17
ControlDoublePrivate();
18
ControlDoublePrivate(ConfigKey key, bool bIgnoreNops, bool bTrack);
19
virtual ~ControlDoublePrivate();
21
// Gets the ControlDoublePrivate matching the given ConfigKey. If bCreate
22
// is true, allocates a new ControlDoublePrivate for the ConfigKey if one
24
static ControlDoublePrivate* getControl(
26
bool bCreate, bool bIgnoreNops=true, bool bTrack=false);
27
static inline ControlDoublePrivate* getControl(
28
const QString& group, const QString& item,
29
bool bCreate, bool bIgnoreNops=true, bool bTrack=false) {
30
ConfigKey key(group, item);
31
return getControl(key, bCreate, bIgnoreNops, bTrack);
34
// Sets the control value.
35
void set(const double& value, QObject* pSetter);
36
// Gets the control value.
38
// Resets the control value to its default.
39
void reset(QObject* pSetter);
41
// Set the behavior to be used when setting values and translating between
42
// parameter and value space. Returns the previously set behavior (if any).
43
// Caller must handle appropriate destruction of the previous behavior or
45
ControlNumericBehavior* setBehavior(ControlNumericBehavior* pBehavior);
47
void setWidgetParameter(double dParam, QObject* pSetter);
48
double getWidgetParameter() const;
50
void setMidiParameter(MidiOpCode opcode, double dParam);
51
double getMidiParameter() const;
53
inline bool ignoreNops() const {
57
inline void setDefaultValue(double dValue) {
58
m_defaultValue.setValue(dValue);
60
inline double defaultValue() const {
61
double default_value = m_defaultValue.getValue();
62
return m_pBehavior ? m_pBehavior->defaultValue(default_value) : default_value;
66
// Emitted when the ControlDoublePrivate value changes. pSetter is a
67
// pointer to the setter of the value (potentially NULL).
68
void valueChanged(double value, QObject* pSetter);
72
// Whether to ignore sets which would have no effect.
75
// Whether to track value changes with the stats framework.
82
ControlValueAtomic<double> m_value;
83
// The default control value.
84
ControlValueAtomic<double> m_defaultValue;
86
QAtomicPointer<ControlNumericBehavior> m_pBehavior;
88
// Hash of ControlDoublePrivate instantiations.
89
static QHash<ConfigKey,ControlDoublePrivate*> m_sqCOHash;
90
// Mutex guarding access to the ControlDoublePrivate hash.
91
static QMutex m_sqCOHashMutex;
95
#endif /* CONTROL_H */