Skip to content

Commit

Permalink
ControllerEngine: more const
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Mar 30, 2022
1 parent fbba731 commit 984b893
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
17 changes: 9 additions & 8 deletions src/controllers/controllerengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1373,10 +1373,10 @@ void ControllerEngine::scratchTick(int deck, int interval) {
Input: ID of timer for this deck
Output: -
-------- ------------------------------------------------------ */
void ControllerEngine::scratchProcess(int timerId) {
int deck = m_scratchTimers[timerId];
void ControllerEngine::scratchProcess(const int timerId) {
const int deck = m_scratchTimers[timerId];
// PlayerManager::groupForDeck is 0-indexed.
QString group = PlayerManager::groupForDeck(deck - 1);
const QString group = PlayerManager::groupForDeck(deck - 1);
AlphaBetaFilter* filter = m_scratchFilters[deck];
if (!filter) {
qWarning() << "Scratch filter pointer is null on deck" << deck;
Expand Down Expand Up @@ -1549,7 +1549,8 @@ void ControllerEngine::softTakeoverIgnoreNextValue(
rate (optional)
Output: -
-------- ------------------------------------------------------ */
void ControllerEngine::spinback(int deck, bool activate, double factor, double rate) {
void ControllerEngine::spinback(
const int deck, bool activate, const double factor, const double rate) {
qDebug() << " init spinback";
brake(deck, activate, -factor, rate);
}
Expand All @@ -1560,10 +1561,10 @@ void ControllerEngine::spinback(int deck, bool activate, double factor, double r
rate (optional, necessary for spinback)
Output: -
-------- ------------------------------------------------------ */
void ControllerEngine::brake(int deck, bool activate, double factor, double rate) {
void ControllerEngine::brake(const int deck, bool activate, double factor, const double rate) {
qDebug() << " init brake";
// PlayerManager::groupForDeck is 0-indexed.
QString group = PlayerManager::groupForDeck(deck - 1);
const QString group = PlayerManager::groupForDeck(deck - 1);
// enable/disable scratch2 mode
ControlObjectScript* pScratch2Enable = getControlObjectScript(group, "scratch2_enable");
if (pScratch2Enable != nullptr) {
Expand Down Expand Up @@ -1651,10 +1652,10 @@ void ControllerEngine::brake(int deck, bool activate, double factor, double rate
Input: deck, activate/deactivate, factor (optional)
Output: -
-------- ------------------------------------------------------ */
void ControllerEngine::softStart(int deck, bool activate, double factor) {
void ControllerEngine::softStart(const int deck, bool activate, double factor) {
qDebug() << " init softStart";
// PlayerManager::groupForDeck is 0-indexed.
QString group = PlayerManager::groupForDeck(deck - 1);
const QString group = PlayerManager::groupForDeck(deck - 1);

// kill timer when both enabling or disabling
int timerId = m_scratchTimers.key(deck);
Expand Down
14 changes: 10 additions & 4 deletions src/controllers/controllerengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,15 @@ class ControllerEngine : public QObject {
Q_INVOKABLE bool isScratching(int deck);
Q_INVOKABLE void softTakeover(const QString& group, const QString& name, bool set);
Q_INVOKABLE void softTakeoverIgnoreNextValue(const QString& group, const QString& name);
Q_INVOKABLE void brake(int deck, bool activate, double factor=1.0, double rate=1.0);
Q_INVOKABLE void spinback(int deck, bool activate, double factor=1.8, double rate=-10.0);
Q_INVOKABLE void softStart(int deck, bool activate, double factor=1.0);
Q_INVOKABLE void brake(const int deck,
bool activate,
double factor = 1.0,
const double rate = 1.0);
Q_INVOKABLE void spinback(const int deck,
bool activate,
double factor = 1.8,
const double rate = -10.0);
Q_INVOKABLE void softStart(const int deck, bool activate, double factor = 1.0);

// Handler for timers that scripts set.
virtual void timerEvent(QTimerEvent *event);
Expand Down Expand Up @@ -192,7 +198,7 @@ class ControllerEngine : public QObject {
ControlObjectScript* getControlObjectScript(const QString& group, const QString& name);

// Scratching functions & variables
void scratchProcess(int timerId);
void scratchProcess(const int timerId);
void stopScratchTimer(const int timerId);

bool isDeckPlaying(const QString& group);
Expand Down

0 comments on commit 984b893

Please sign in to comment.