-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduced ControlObjectSlave and converted some controls to this. #38
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0627433
Removed unnecessary Control Object() use
daschuer 9da8144
added connectValueChanged to ControlObjectThread
daschuer db5f79a
Introduced ControlObjectSlave a successor of ControlObjectThread.
daschuer 069458d
Added default constructor, Connect to ControlObjectPrivate only if
daschuer 792e5e0
changed EnigineBuffer::m_pSampleRate to ControObjectSlave
daschuer 9c1b203
changed addition COs to COSs in ClockControl and BpmControl
daschuer 2c96134
Merge branch 'master' into atomic-co
daschuer 6fe155e
added some usage comments to controlobjectslave.h
daschuer 316c067
Merge branch 'master' into atomic-co
daschuer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#include <QApplication> | ||
#include <QtDebug> | ||
|
||
#include "controlobjectslave.h" | ||
#include "control/control.h" | ||
|
||
ControlObjectSlave::ControlObjectSlave(QObject* pParent) | ||
: QObject(pParent), | ||
m_pControl(NULL) { | ||
} | ||
|
||
ControlObjectSlave::ControlObjectSlave(const QString& g, const QString& i, QObject* pParent) | ||
: QObject(pParent) { | ||
initialize(ConfigKey(g, i)); | ||
} | ||
|
||
ControlObjectSlave::ControlObjectSlave(const char* g, const char* i, QObject* pParent) | ||
: QObject(pParent) { | ||
initialize(ConfigKey(g, i)); | ||
} | ||
|
||
ControlObjectSlave::ControlObjectSlave(const ConfigKey& key, QObject* pParent) | ||
: QObject(pParent) { | ||
initialize(key); | ||
} | ||
|
||
void ControlObjectSlave::initialize(const ConfigKey& key) { | ||
m_pControl = ControlDoublePrivate::getControl(key, false); | ||
} | ||
|
||
ControlObjectSlave::~ControlObjectSlave() { | ||
} | ||
|
||
bool ControlObjectSlave::connectValueChanged(const QObject* receiver, | ||
const char* method, Qt::ConnectionType type) { | ||
bool ret = false; | ||
if (m_pControl) { | ||
ret = connect((QObject*)this, SIGNAL(valueChanged(double)), | ||
receiver, method, type); | ||
if (ret) { | ||
// connect to ControlObjectPrivate only if required | ||
ret = connect(m_pControl, SIGNAL(valueChanged(double, QObject*)), | ||
this, SLOT(slotValueChanged(double, QObject*)), | ||
Qt::DirectConnection); | ||
} | ||
} | ||
return ret; | ||
} | ||
|
||
bool ControlObjectSlave::connectValueChanged( | ||
const char* method, Qt::ConnectionType type) { | ||
return connectValueChanged(parent(), method, type); | ||
} | ||
|
||
|
||
double ControlObjectSlave::get() { | ||
return m_pControl ? m_pControl->get() : 0.0; | ||
} | ||
|
||
void ControlObjectSlave::slotSet(double v) { | ||
set(v); | ||
} | ||
|
||
void ControlObjectSlave::set(double v) { | ||
if (m_pControl) { | ||
m_pControl->set(v, this); | ||
} | ||
} | ||
|
||
void ControlObjectSlave::reset() { | ||
if (m_pControl) { | ||
// NOTE(rryan): This is important. The originator of this action does | ||
// not know the resulting value so it makes sense that we should emit a | ||
// general valueChanged() signal even though the change originated from | ||
// us. For this reason, we provide NULL here so that the change is | ||
// broadcast as valueChanged() and not valueChangedByThis(). | ||
m_pControl->reset(); | ||
} | ||
} | ||
|
||
void ControlObjectSlave::emitValueChanged() { | ||
emit(valueChanged(get())); | ||
} | ||
|
||
void ControlObjectSlave::slotValueChanged(double v, QObject* pSetter) { | ||
if (pSetter != this) { | ||
// This is base implementation of this function without scaling | ||
emit(valueChanged(v)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#ifndef CONTROLOBJECTSLAVE_H | ||
#define CONTROLOBJECTSLAVE_H | ||
|
||
#include <qmutex.h> | ||
#include <qobject.h> | ||
#include <qmutex.h> | ||
#include <qwaitcondition.h> | ||
#include <QQueue> | ||
|
||
#include "configobject.h" | ||
|
||
class ControlDoublePrivate; | ||
|
||
class ControlObjectSlave : public QObject { | ||
Q_OBJECT | ||
public: | ||
ControlObjectSlave(QObject* pParent=NULL); | ||
ControlObjectSlave(const QString& g, const QString& i, QObject* pParent=NULL); | ||
ControlObjectSlave(const char* g, const char* i, QObject* pParent=NULL); | ||
ControlObjectSlave(const ConfigKey& key, QObject* pParent=NULL); | ||
virtual ~ControlObjectSlave(); | ||
|
||
void initialize(const ConfigKey& key); | ||
|
||
bool connectValueChanged(const QObject* receiver, | ||
const char* method, Qt::ConnectionType type = Qt::AutoConnection); | ||
bool connectValueChanged( | ||
const char* method, Qt::ConnectionType type = Qt::AutoConnection ); | ||
|
||
|
||
/** Called from update(); */ | ||
void emitValueChanged(); | ||
|
||
inline bool valid() const { return m_pControl != NULL; } | ||
|
||
// Returns the value of the object. Thread safe, non-blocking. | ||
virtual double get(); | ||
|
||
public slots: | ||
// Set the control to a new value. Non-blocking. | ||
virtual void slotSet(double v); | ||
// Sets the control value to v. Thread safe, non-blocking. | ||
virtual void set(double v); | ||
// Resets the control to its default value. Thread safe, non-blocking. | ||
virtual void reset(); | ||
|
||
signals: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a comment that you must not connect directly but instead should use connectValueChanged. |
||
void valueChanged(double); | ||
|
||
protected slots: | ||
// Receives the value from the master control and re-emits either | ||
// valueChanged(double) or valueChangedByThis(double) based on pSetter. | ||
virtual void slotValueChanged(double v, QObject* pSetter); | ||
|
||
protected: | ||
// Pointer to connected control. | ||
ControlDoublePrivate* m_pControl; | ||
}; | ||
|
||
#endif // CONTROLOBJECTSLAVE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The class could use a comment that describes what it is and why you would use it as opposed to ControlObjectThread.