Skip to content

Commit

Permalink
Make Controller::send virtual
Browse files Browse the repository at this point in the history
This is needed so BulkController can reuse the JSProxy from Controller and still have a custom implementation of send called from JS.

Rename of send(QByteArray) to sendByteArray was needed because it's private and can't be imported by the using clausule.
  • Loading branch information
ferranpujolcamins committed Nov 27, 2018
1 parent 6f5dfd2 commit e8e25a4
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/controllers/bulk/bulkcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@ void BulkController::send(QList<int> data, unsigned int length) {
foreach (int datum, data) {
temp.append(datum);
}
send(temp);
sendByteArray(temp);
}

void BulkController::send(QByteArray data) {
void BulkController::sendByteArray(QByteArray data) {
int ret;
int transferred;

Expand Down
5 changes: 1 addition & 4 deletions src/controllers/bulk/bulkcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,14 @@ class BulkController : public Controller {

bool matchPreset(const PresetInfo& preset) override;

protected:
Q_INVOKABLE void send(QList<int> data, unsigned int length);

private slots:
int open() override;
int close() override;

private:
// For devices which only support a single report, reportID must be set to
// 0x0.
void send(QByteArray data) override;
void sendByteArray(QByteArray data) override;

// Returns a pointer to the currently loaded controller preset. For internal
// use only.
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void Controller::send(QList<int> data, unsigned int length) {
for (unsigned int i = 0; i < length; ++i) {
msg[i] = data.at(i);
}
send(msg);
sendByteArray(msg);
}

void Controller::triggerActivity()
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class Controller : public QObject, ConstControllerPresetVisitor {
protected:
// The length parameter is here for backwards compatibility for when scripts
// were required to specify it.
void send(QList<int> data, unsigned int length = 0);
virtual void send(QList<int> data, unsigned int length = 0);

// To be called in sub-class' open() functions after opening the device but
// before starting any input polling/processing.
Expand Down Expand Up @@ -148,7 +148,7 @@ class Controller : public QObject, ConstControllerPresetVisitor {
private:
// This must be reimplemented by sub-classes desiring to send raw bytes to a
// controller.
virtual void send(QByteArray data) = 0;
virtual void sendByteArray(QByteArray data) = 0;

// Returns a pointer to the currently loaded controller preset. For internal
// use only.
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/hid/hidcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ void HidController::send(QList<int> data, unsigned int length, unsigned int repo
send(temp, reportID);
}

void HidController::send(QByteArray data) {
void HidController::sendByteArray(QByteArray data) {
send(data, 0);
}

Expand Down
3 changes: 2 additions & 1 deletion src/controllers/hid/hidcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class HidController final : public Controller {
static QString safeDecodeWideString(const wchar_t* pStr, size_t max_length);

protected:
using Controller::send;
void send(QList<int> data, unsigned int length, unsigned int reportID = 0);

private slots:
Expand All @@ -83,7 +84,7 @@ class HidController final : public Controller {
private:
// For devices which only support a single report, reportID must be set to
// 0x0.
void send(QByteArray data) override;
void sendByteArray(QByteArray data) override;
void virtual send(QByteArray data, unsigned int reportID);

// Returns a pointer to the currently loaded controller preset. For internal
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/midi/hss1394controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void Hss1394Controller::sendShortMsg(unsigned char status, unsigned char byte1,
//}
}

void Hss1394Controller::send(QByteArray data) {
void Hss1394Controller::sendByteArray(QByteArray data) {
int bytesSent = m_pChannel->SendChannelBytes(
(unsigned char*)data.constData(), data.size());

Expand Down
2 changes: 1 addition & 1 deletion src/controllers/midi/hss1394controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Hss1394Controller : public MidiController {
private:
// The sysex data must already contain the start byte 0xf0 and the end byte
// 0xf7.
void send(QByteArray data) override;
void sendByteArray(QByteArray data) override;

hss1394::TNodeInfo m_deviceInfo;
int m_iDeviceIndex;
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/midi/portmidicontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void PortMidiController::sendShortMsg(unsigned char status, unsigned char byte1,
}
}

void PortMidiController::send(QByteArray data) {
void PortMidiController::sendByteArray(QByteArray data) {
// PortMidi does not receive a length argument for the buffer we provide to
// Pm_WriteSysEx. Instead, it scans for a MIDI_EOX byte to know when the
// message is over. If one is not provided, it will overflow the buffer and
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/midi/portmidicontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class PortMidiController : public MidiController {
private:
// The sysex data must already contain the start byte 0xf0 and the end byte
// 0xf7.
void send(QByteArray data) override;
void sendByteArray(QByteArray data) override;

bool isPolling() const override {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/test/controller_preset_validation_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class FakeController : public Controller {
}

private:
void send(QByteArray data) override {
void sendByteArray(QByteArray data) override {
Q_UNUSED(data);
}
virtual void send(QByteArray data, unsigned int reportID) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/midicontrollertest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MockMidiController : public MidiController {
MOCK_METHOD3(sendShortMsg, void(unsigned char status,
unsigned char byte1,
unsigned char byte2));
MOCK_METHOD1(send, void(QByteArray data));
MOCK_METHOD1(sendByteArray, void(QByteArray data));
MOCK_CONST_METHOD0(isPolling, bool());
};

Expand Down

0 comments on commit e8e25a4

Please sign in to comment.