diff options
author | Kazumasa Mitsunari <knimitz@witz-inc.co.jp> | 2018-01-12 19:02:44 +0900 |
---|---|---|
committer | Kazumasa Mitsunari <knimitz@witz-inc.co.jp> | 2018-06-28 15:16:51 +0900 |
commit | de22d2c202af9a4074a1d2e120b971488eac649a (patch) | |
tree | b109c710b4d78c995bb76d60cc997051a7906593 /src | |
parent | ed8817e3aced55cfc07fe34f6a4335f769d22ceb (diff) |
Use inherit instead of using private variable
Change-Id: Ibd4d0d3295538589ba38df42938acd546fc62f9d
Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
Diffstat (limited to 'src')
-rw-r--r-- | src/qlibsoundmanager.cpp | 25 | ||||
-rw-r--r-- | src/qlibsoundmanager.h | 5 |
2 files changed, 11 insertions, 19 deletions
diff --git a/src/qlibsoundmanager.cpp b/src/qlibsoundmanager.cpp index 39fb871..c9e002c 100644 --- a/src/qlibsoundmanager.cpp +++ b/src/qlibsoundmanager.cpp @@ -47,27 +47,22 @@ static void cbReply_static(struct json_object* replyContents) QSoundmanager::QSoundmanager(QObject *parent) : QObject(parent) { - libsm = new Soundmanager(); } QSoundmanager::~QSoundmanager() { - delete libsm; } int QSoundmanager::init(int port, const QString& token) { - if(libsm == nullptr){ - return -1; - } string ctoken = token.toStdString(); - int rc = libsm->init(port, ctoken); + int rc = Soundmanager::init(port, ctoken); if(rc != 0){ return rc; } me = this; - libsm->registerCallback( + Soundmanager::registerCallback( cbEvent_static, cbReply_static); return rc; @@ -82,27 +77,27 @@ int QSoundmanager::call(const QString &verb, const QJsonObject &arg) { return -1; } - return libsm->call(verb.toStdString().c_str(), jobj); + return Soundmanager::call(verb.toStdString().c_str(), jobj); } int QSoundmanager::connect(int sourceID, const QString& sinkName){ string str = sinkName.toStdString(); - return libsm->connect(sourceID, str); + return Soundmanager::connect(sourceID, str); } int QSoundmanager::connect(int sourceID, int sinkID){ - return libsm->connect(sourceID, sinkID); + return Soundmanager::connect(sourceID, sinkID); } int QSoundmanager::disconnect(int connectionID){ - return libsm->disconnect(connectionID); + return Soundmanager::disconnect(connectionID); } int QSoundmanager::ackSetSourceState(int handle, int errorcode){ - return libsm->ackSetSourceState(handle, errorcode); + return Soundmanager::ackSetSourceState(handle, errorcode); } int QSoundmanager::registerSource(const QString& name){ string str = name.toStdString(); - return libsm->registerSource(str); + return Soundmanager::registerSource(str); } static int create_json_object(const QJsonObject& obj, struct json_object* jobj) @@ -148,11 +143,11 @@ static bool put_val_to_jobj(const char* key, const QJsonValue& val, struct json_ void QSoundmanager::subscribe(const QString event_name) { std::string str = event_name.toStdString(); - libsm->subscribe(str); + Soundmanager::subscribe(str); } void QSoundmanager::unsubscribe(const QString event_name) { std::string str = event_name.toStdString(); - libsm->unsubscribe(str); + Soundmanager::unsubscribe(str); } diff --git a/src/qlibsoundmanager.h b/src/qlibsoundmanager.h index aefe175..36b477b 100644 --- a/src/qlibsoundmanager.h +++ b/src/qlibsoundmanager.h @@ -25,7 +25,7 @@ // Note: This wrapper library will be integrated to libqtappfw -class QSoundmanager : public QObject +class QSoundmanager : public QObject, Soundmanager { Q_OBJECT public: // method @@ -47,9 +47,6 @@ public: signals: void reply(const QVariant &msg); void event(const QVariant &event, const QVariant &msg); - -private: - Soundmanager* libsm; }; |