Mixxx

/home/maxime/Projets/Mixxx/1.10/mixxx/src/controlobject.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           controlobject.h  -  description
00003                              -------------------
00004     begin                : Wed Feb 20 2002
00005     copyright            : (C) 2002 by Tue and Ken Haste Andersen
00006     email                :
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef CONTROLOBJECT_H
00019 #define CONTROLOBJECT_H
00020 
00021 #include <QObject>
00022 #include <QEvent>
00023 #include <QMutex>
00024 #include "midi/midimessage.h"
00025 #include "configobject.h"
00026 #include "controlobjectthread.h"
00027 
00028 class QWidget;
00029 class ConfigKey;
00030 
00031 struct QueueObjectThread
00032 {
00033     ControlObjectThread *pControlObjectThread;
00034     ControlObject *pControlObject;
00035     double value;
00036 };
00037 
00038 struct QueueObjectMidi
00039 {
00040     ControlObject *pControlObject;
00041     MidiCategory category;
00042     double value;
00043 };
00044 
00058 class ControlObject : public QObject
00059 {
00060     Q_OBJECT
00061 public:
00062     ControlObject();
00063     ControlObject(ConfigKey key, bool bIgnoreNops=true);
00064     virtual ~ControlObject();
00066     static bool connectControls(ConfigKey src, ConfigKey dest);
00068     static bool disconnectControl(ConfigKey key);
00070     static ControlObject *getControl(ConfigKey key);
00071 
00072     // Adds all ControlObjects that currently exist to pControlList
00073     static void getControls(QList<ControlObject*>* pControlsList);
00074 
00076     void addProxy(ControlObjectThread *pControlObjectThread);
00077     // To get rid of a proxy when the corresponding object is being deleted for example
00078     void removeProxy(ControlObjectThread *pControlObjectThread);
00081     bool updateProxies(ControlObjectThread *pProxyNoUpdate=0);
00083     inline ConfigKey getKey() { return m_Key; }
00085     inline double get() { return m_dValue; }
00087     void add(double dValue);
00089     void sub(double dValue);
00091     static void sync();
00093     void queueFromThread(double dValue, ControlObjectThread *pControlObjectThread=0);
00095     void queueFromMidi(MidiCategory c, double v);
00097     virtual double getValueFromWidget(double dValue);
00099     virtual double getValueToWidget(double dValue);
00101     virtual double GetMidiValue();
00102 
00103 public slots:
00105     void set(double dValue);
00106 
00107 signals:
00108     void valueChanged(double);
00109     void valueChangedFromEngine(double);
00110 
00111 protected:
00113     virtual void setValueFromEngine(double dValue);
00115     virtual void setValueFromMidi(MidiCategory, double v);
00117     virtual void setValueFromThread(double dValue);
00118 
00119 protected:
00121     double m_dValue;
00123     ConfigKey m_Key;
00124 
00125 private:
00126     // Whether to ignore set/add/sub()'s which would have no effect
00127     bool m_bIgnoreNops;
00129     QList<ControlObjectThread*> m_qProxyList;
00131     QMutex m_qProxyListMutex;
00132 
00134     static QHash<ConfigKey,ControlObject*> m_sqCOHash;
00136     static QMutex m_sqCOHashMutex;
00138     static QMutex m_sqQueueMutexMidi, m_sqQueueMutexThread, m_sqQueueMutexChanges;
00140     static QQueue<QueueObjectMidi*> m_sqQueueMidi;
00142     static QQueue<QueueObjectThread*> m_sqQueueThread;
00145     static QQueue<ControlObject*> m_sqQueueChanges;
00146 };
00147 
00148 
00149 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines