diff options
author | Chris Xiong <chirs241097@gmail.com> | 2020-04-29 17:54:55 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2020-04-29 17:54:55 +0800 |
commit | 8766f3b12e13d40b65eca23a850f687b0043d022 (patch) | |
tree | ffa27c96238bdade1ec097d8a1eba0239207ae35 | |
parent | 65a8bde4e4beca860a13491e94631dc16b5e71af (diff) | |
download | QMidiPlayer-8766f3b12e13d40b65eca23a850f687b0043d022.tar.xz |
Make all methods in the API pure virtual.
Finally, creating multiple implementations of the API is now much easier.
-rw-r--r-- | include/qmpcorepublic.hpp | 132 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmpplugin.cpp | 138 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmpplugin.hpp | 78 |
3 files changed, 211 insertions, 137 deletions
diff --git a/include/qmpcorepublic.hpp b/include/qmpcorepublic.hpp index 963eff1..bebde30 100644 --- a/include/qmpcorepublic.hpp +++ b/include/qmpcorepublic.hpp @@ -120,84 +120,84 @@ extern "C"{ class qmpPluginAPI { public: - virtual ~qmpPluginAPI(); - virtual uint32_t getDivision(); - virtual uint32_t getRawTempo(); - virtual double getRealTempo(); - virtual uint32_t getTimeSig(); - virtual int getKeySig(); - virtual uint32_t getNoteCount(); - virtual uint32_t getMaxTick(); - virtual uint32_t getCurrentPolyphone(); - virtual uint32_t getMaxPolyphone(); - virtual uint32_t getCurrentTimeStamp(); - virtual uint32_t getCurrentPlaybackPercentage(); - virtual int getChannelCC(int ch,int cc); - virtual int getChannelPreset(int ch); - virtual void playerSeek(uint32_t percentage); - virtual double getPitchBend(int ch); - virtual bool getChannelMask(int ch); - virtual std::string getTitle(); - virtual std::wstring getWTitle(); - virtual std::string getChannelPresetString(int ch); - virtual bool isDarkTheme(); - virtual void* getMainWindow(); + virtual ~qmpPluginAPI(){} + virtual uint32_t getDivision()=0; + virtual uint32_t getRawTempo()=0; + virtual double getRealTempo()=0; + virtual uint32_t getTimeSig()=0; + virtual int getKeySig()=0; + virtual uint32_t getNoteCount()=0; + virtual uint32_t getMaxTick()=0; + virtual uint32_t getCurrentPolyphone()=0; + virtual uint32_t getMaxPolyphone()=0; + virtual uint32_t getCurrentTimeStamp()=0; + virtual uint32_t getCurrentPlaybackPercentage()=0; + virtual int getChannelCC(int ch,int cc)=0; + virtual int getChannelPreset(int ch)=0; + virtual void playerSeek(uint32_t percentage)=0; + virtual double getPitchBend(int ch)=0; + virtual bool getChannelMask(int ch)=0; + virtual std::string getTitle()=0; + virtual std::wstring getWTitle()=0; + virtual std::string getChannelPresetString(int ch)=0; + virtual bool isDarkTheme()=0; + virtual void* getMainWindow()=0; //WARNING!!: This function should be called from event reader callbacks only and //it is somehow dangerous -- other plugins might be unaware of the removal of the //event. The design might be modified afterward. - virtual void discardCurrentEvent(); + virtual void discardCurrentEvent()=0; //WARNING!!: This function should be called from event reader callbacks only and //it is somehow dangerous -- other plugins might be unaware of the event change. //The design might be modified afterward. - virtual void commitEventChange(SEvent d); + virtual void commitEventChange(SEvent d)=0; //This function should be called from a file reader when it has read a new event - virtual void callEventReaderCB(SEvent d); - virtual void setFuncState(std::string name,bool state); - virtual void setFuncEnabled(std::string name,bool enable); + virtual void callEventReaderCB(SEvent d)=0; + virtual void setFuncState(std::string name,bool state)=0; + virtual void setFuncEnabled(std::string name,bool enable)=0; - virtual void registerFunctionality(qmpFuncBaseIntf* i,std::string name,std::string desc,const char* icon,int iconlen,bool checkable); - virtual void unregisterFunctionality(std::string name); - virtual int registerUIHook(std::string e,ICallBack* cb,void* userdat); - virtual int registerUIHook(std::string e,callback_t cb,void* userdat); - virtual void unregisterUIHook(std::string e,int hook); - virtual void registerMidiOutDevice(qmpMidiOutDevice* dev,std::string name); - virtual void unregisterMidiOutDevice(std::string name); - virtual int registerEventReaderIntf(ICallBack* cb,void* userdata); - virtual void unregisterEventReaderIntf(int intfhandle); - virtual int registerEventHandlerIntf(ICallBack* cb,void* userdata); - virtual void unregisterEventHandlerIntf(int intfhandle); - virtual int registerFileReadFinishedHandlerIntf(ICallBack* cb,void* userdata); - virtual void unregisterFileReadFinishedHandlerIntf(int intfhandle); - virtual int registerEventHandler(callback_t cb,void *userdata,bool post=false); - virtual void unregisterEventHandler(int id); - virtual int registerEventReadHandler(callback_t cb,void *userdata); - virtual void unregisterEventReadHandler(int id); - virtual int registerFileReadFinishHook(callback_t cb,void *userdata); - virtual void unregisterFileReadFinishHook(int id); - virtual void registerFileReader(qmpFileReader* reader,std::string name); - virtual void unregisterFileReader(std::string name); + virtual void registerFunctionality(qmpFuncBaseIntf* i,std::string name,std::string desc,const char* icon,int iconlen,bool checkable)=0; + virtual void unregisterFunctionality(std::string name)=0; + virtual int registerUIHook(std::string e,ICallBack* cb,void* userdat)=0; + virtual int registerUIHook(std::string e,callback_t cb,void* userdat)=0; + virtual void unregisterUIHook(std::string e,int hook)=0; + virtual void registerMidiOutDevice(qmpMidiOutDevice* dev,std::string name)=0; + virtual void unregisterMidiOutDevice(std::string name)=0; + virtual int registerEventReaderIntf(ICallBack* cb,void* userdata)=0; + virtual void unregisterEventReaderIntf(int intfhandle)=0; + virtual int registerEventHandlerIntf(ICallBack* cb,void* userdata)=0; + virtual void unregisterEventHandlerIntf(int intfhandle)=0; + virtual int registerFileReadFinishedHandlerIntf(ICallBack* cb,void* userdata)=0; + virtual void unregisterFileReadFinishedHandlerIntf(int intfhandle)=0; + virtual int registerEventHandler(callback_t cb,void *userdata,bool post=false)=0; + virtual void unregisterEventHandler(int id)=0; + virtual int registerEventReadHandler(callback_t cb,void *userdata)=0; + virtual void unregisterEventReadHandler(int id)=0; + virtual int registerFileReadFinishHook(callback_t cb,void *userdata)=0; + virtual void unregisterFileReadFinishHook(int id)=0; + virtual void registerFileReader(qmpFileReader* reader,std::string name)=0; + virtual void unregisterFileReader(std::string name)=0; //if desc=="", the option won't be visible in the settings form. //it will only show up in the configuration file. - virtual void registerOptionInt(std::string tab,std::string desc,std::string key,int min,int max,int defaultval); - virtual int getOptionInt(std::string key); - virtual void setOptionInt(std::string key,int val); - virtual void registerOptionUint(std::string tab,std::string desc,std::string key,unsigned min,unsigned max,unsigned defaultval); - virtual unsigned getOptionUint(std::string key); - virtual void setOptionUint(std::string key,unsigned val); - virtual void registerOptionBool(std::string tab,std::string desc,std::string key,bool defaultval); - virtual bool getOptionBool(std::string key); - virtual void setOptionBool(std::string key,bool val); - virtual void registerOptionDouble(std::string tab,std::string desc,std::string key,double min,double max,double defaultval); - virtual double getOptionDouble(std::string key); - virtual void setOptionDouble(std::string key,double val); - virtual void registerOptionString(std::string tab,std::string desc,std::string key,std::string defaultval,bool ispath=false); - virtual std::string getOptionString(std::string key); - virtual void setOptionString(std::string key,std::string val); - virtual void registerOptionEnumInt(std::string tab,std::string desc,std::string key,std::vector<std::string> options,int defaultval); - virtual int getOptionEnumInt(std::string key); - virtual void setOptionEnumInt(std::string key,int val); + virtual void registerOptionInt(std::string tab,std::string desc,std::string key,int min,int max,int defaultval)=0; + virtual int getOptionInt(std::string key)=0; + virtual void setOptionInt(std::string key,int val)=0; + virtual void registerOptionUint(std::string tab,std::string desc,std::string key,unsigned min,unsigned max,unsigned defaultval)=0; + virtual unsigned getOptionUint(std::string key)=0; + virtual void setOptionUint(std::string key,unsigned val)=0; + virtual void registerOptionBool(std::string tab,std::string desc,std::string key,bool defaultval)=0; + virtual bool getOptionBool(std::string key)=0; + virtual void setOptionBool(std::string key,bool val)=0; + virtual void registerOptionDouble(std::string tab,std::string desc,std::string key,double min,double max,double defaultval)=0; + virtual double getOptionDouble(std::string key)=0; + virtual void setOptionDouble(std::string key,double val)=0; + virtual void registerOptionString(std::string tab,std::string desc,std::string key,std::string defaultval,bool ispath=false)=0; + virtual std::string getOptionString(std::string key)=0; + virtual void setOptionString(std::string key,std::string val)=0; + virtual void registerOptionEnumInt(std::string tab,std::string desc,std::string key,std::vector<std::string> options,int defaultval)=0; + virtual int getOptionEnumInt(std::string key)=0; + virtual void setOptionEnumInt(std::string key,int val)=0; }; #ifdef QMP_MAIN } diff --git a/qmidiplayer-desktop/qmpplugin.cpp b/qmidiplayer-desktop/qmpplugin.cpp index 6e53302..4785b16 100644 --- a/qmidiplayer-desktop/qmpplugin.cpp +++ b/qmidiplayer-desktop/qmpplugin.cpp @@ -9,7 +9,7 @@ #include "qmpplugin.hpp" #include "qmpmainwindow.hpp" #include "qmpsettingswindow.hpp" -qmpPluginAPI* qmpPluginManager::pluginAPI=nullptr; +qmpPluginAPIImpl* qmpPluginManager::pluginAPI=nullptr; qmpMainWindow* qmpPluginManager::mainwindow=nullptr; #ifdef _WIN32 #include <codecvt> @@ -93,7 +93,7 @@ void qmpPluginManager::scanPlugins(const std::vector<std::string> &pp) qmpPluginManager::qmpPluginManager() { mainwindow=qmpMainWindow::getInstance(); - pluginAPI=new qmpPluginAPI(); + pluginAPI=new qmpPluginAPIImpl(); } qmpPluginManager::~qmpPluginManager() { @@ -126,34 +126,34 @@ void qmpPluginManager::deinitPlugins() } } -qmpPluginAPI::~qmpPluginAPI(){} - +qmpPluginAPIImpl::qmpPluginAPIImpl(){} +qmpPluginAPIImpl::~qmpPluginAPIImpl(){} #define qmw qmpPluginManager::mainwindow -uint32_t qmpPluginAPI::getDivision() +uint32_t qmpPluginAPIImpl::getDivision() {return qmw&&qmw->getPlayer()?qmw->getPlayer()->getDivision():0;} -uint32_t qmpPluginAPI::getRawTempo() +uint32_t qmpPluginAPIImpl::getRawTempo() {return qmw&&qmw->getPlayer()?qmw->getPlayer()->getRawTempo():0;} -double qmpPluginAPI::getRealTempo() +double qmpPluginAPIImpl::getRealTempo() {return qmw&&qmw->getPlayer()?qmw->getPlayer()->getTempo():0;} -uint32_t qmpPluginAPI::getTimeSig() +uint32_t qmpPluginAPIImpl::getTimeSig() {int n,d=0,t;qmw&&qmw->getPlayer()?qmw->getPlayer()->getCurrentTimeSignature(&n,&t):void(0);for(;t>>=1;++d);return n<<8|d;} -int qmpPluginAPI::getKeySig() +int qmpPluginAPIImpl::getKeySig() {return qmw&&qmw->getPlayer()?qmw->getPlayer()->getCurrentKeySignature():0;} -uint32_t qmpPluginAPI::getNoteCount() +uint32_t qmpPluginAPIImpl::getNoteCount() {return qmw&&qmw->getPlayer()?qmw->getPlayer()->getFileNoteCount():0;} -uint32_t qmpPluginAPI::getMaxTick() +uint32_t qmpPluginAPIImpl::getMaxTick() {return qmw&&qmw->getPlayer()?qmw->getPlayer()->getMaxTick():0;} -uint32_t qmpPluginAPI::getCurrentPolyphone() +uint32_t qmpPluginAPIImpl::getCurrentPolyphone() {return qmw&&qmw->getPlayer()?qmw->getFluid()->getPolyphone():0;} -uint32_t qmpPluginAPI::getMaxPolyphone() +uint32_t qmpPluginAPIImpl::getMaxPolyphone() {return qmw&&qmw->getPlayer()?qmw->getFluid()->getMaxPolyphone():0;} -uint32_t qmpPluginAPI::getCurrentTimeStamp() +uint32_t qmpPluginAPIImpl::getCurrentTimeStamp() {return qmw&&qmw->getPlayer()?qmw->getPlayer()->getTick():0;} -uint32_t qmpPluginAPI::getCurrentPlaybackPercentage() +uint32_t qmpPluginAPIImpl::getCurrentPlaybackPercentage() {return qmw?qmw->getPlaybackPercentage():0;} -int qmpPluginAPI::getChannelCC(int ch,int cc) +int qmpPluginAPIImpl::getChannelCC(int ch,int cc) {return qmw&&qmw->getPlayer()?qmw->getPlayer()->getCC(ch,cc):0;} -int qmpPluginAPI::getChannelPreset(int ch) +int qmpPluginAPIImpl::getChannelPreset(int ch) { uint16_t b;uint8_t p;std::string nm; if(qmw&&qmw->getPlayer()) @@ -163,17 +163,17 @@ int qmpPluginAPI::getChannelPreset(int ch) } return 0; } -void qmpPluginAPI::playerSeek(uint32_t percentage) +void qmpPluginAPIImpl::playerSeek(uint32_t percentage) {if(qmw)qmw->playerSeek(percentage);} -double qmpPluginAPI::getPitchBend(int ch) +double qmpPluginAPIImpl::getPitchBend(int ch) {return qmw&&qmw->getPlayer()?qmw->getPlayer()->getPitchBend(ch):0;} -bool qmpPluginAPI::getChannelMask(int ch) +bool qmpPluginAPIImpl::getChannelMask(int ch) {return qmw&&qmw->getPlayer()?qmw->getPlayer()->getChannelMask(ch):false;} -std::string qmpPluginAPI::getTitle() +std::string qmpPluginAPIImpl::getTitle() {return qmw?qmw->getTitle():"";} -std::wstring qmpPluginAPI::getWTitle() +std::wstring qmpPluginAPIImpl::getWTitle() {return qmw?qmw->getWTitle():L"";} -std::string qmpPluginAPI::getChannelPresetString(int ch) +std::string qmpPluginAPIImpl::getChannelPresetString(int ch) { uint16_t b;uint8_t p;char ret[320];ret[0]=0; std::string nm; @@ -190,79 +190,79 @@ std::string qmpPluginAPI::getChannelPresetString(int ch) } return std::string(ret); } -bool qmpPluginAPI::isDarkTheme(){return qmw?qmw->isDarkTheme():false;} -void* qmpPluginAPI::getMainWindow(){return (void*)qmw;} +bool qmpPluginAPIImpl::isDarkTheme(){return qmw?qmw->isDarkTheme():false;} +void* qmpPluginAPIImpl::getMainWindow(){return (void*)qmw;} -void qmpPluginAPI::discardCurrentEvent(){if(qmw&&qmw->getPlayer())qmw->getPlayer()->discardCurrentEvent();} -void qmpPluginAPI::commitEventChange(SEvent d){if(qmw&&qmw->getPlayer())qmw->getPlayer()->commitEventChange(d);} -void qmpPluginAPI::callEventReaderCB(SEvent d){if(qmw&&qmw->getPlayer())qmw->getPlayer()->callEventReaderCB(d);} -void qmpPluginAPI::setFuncState(std::string name,bool state){if(qmw)qmw->setFuncState(name,state);} -void qmpPluginAPI::setFuncEnabled(std::string name,bool enable){if(qmw)qmw->setFuncEnabled(name,enable);} +void qmpPluginAPIImpl::discardCurrentEvent(){if(qmw&&qmw->getPlayer())qmw->getPlayer()->discardCurrentEvent();} +void qmpPluginAPIImpl::commitEventChange(SEvent d){if(qmw&&qmw->getPlayer())qmw->getPlayer()->commitEventChange(d);} +void qmpPluginAPIImpl::callEventReaderCB(SEvent d){if(qmw&&qmw->getPlayer())qmw->getPlayer()->callEventReaderCB(d);} +void qmpPluginAPIImpl::setFuncState(std::string name,bool state){if(qmw)qmw->setFuncState(name,state);} +void qmpPluginAPIImpl::setFuncEnabled(std::string name,bool enable){if(qmw)qmw->setFuncEnabled(name,enable);} -void qmpPluginAPI::registerMidiOutDevice(qmpMidiOutDevice *dev, std::string name) +void qmpPluginAPIImpl::registerMidiOutDevice(qmpMidiOutDevice *dev, std::string name) {qmw->getPlayer()->registerMidiOutDevice(dev,name);} -void qmpPluginAPI::unregisterMidiOutDevice(std::string name) +void qmpPluginAPIImpl::unregisterMidiOutDevice(std::string name) {qmw->getPlayer()->unregisterMidiOutDevice(name);} -int qmpPluginAPI::registerEventHandlerIntf(ICallBack *cb,void *userdata) +int qmpPluginAPIImpl::registerEventHandlerIntf(ICallBack *cb,void *userdata) {return qmw->getPlayer()->setEventHandlerCB(cb,userdata);} -void qmpPluginAPI::unregisterEventHandlerIntf(int intfhandle) +void qmpPluginAPIImpl::unregisterEventHandlerIntf(int intfhandle) {qmw->getPlayer()->unsetEventHandlerCB(intfhandle);} -int qmpPluginAPI::registerEventReaderIntf(ICallBack *cb,void *userdata) +int qmpPluginAPIImpl::registerEventReaderIntf(ICallBack *cb,void *userdata) {return qmw->getPlayer()->setEventReaderCB(cb,userdata);} -void qmpPluginAPI::unregisterEventReaderIntf(int intfhandle) +void qmpPluginAPIImpl::unregisterEventReaderIntf(int intfhandle) {qmw->getPlayer()->unsetEventReaderCB(intfhandle);} -int qmpPluginAPI::registerUIHook(std::string e,ICallBack* cb,void* userdat) +int qmpPluginAPIImpl::registerUIHook(std::string e,ICallBack* cb,void* userdat) {return qmw->registerUIHook(e,cb,userdat);} -int qmpPluginAPI::registerUIHook(std::string e,callback_t cb,void* userdat) +int qmpPluginAPIImpl::registerUIHook(std::string e,callback_t cb,void* userdat) {return qmw->registerUIHook(e,cb,userdat);} -void qmpPluginAPI::unregisterUIHook(std::string e,int hook) +void qmpPluginAPIImpl::unregisterUIHook(std::string e,int hook) {qmw->unregisterUIHook(e,hook);} -void qmpPluginAPI::registerFunctionality(qmpFuncBaseIntf *i,std::string name,std::string desc,const char *icon,int iconlen,bool checkable) +void qmpPluginAPIImpl::registerFunctionality(qmpFuncBaseIntf *i,std::string name,std::string desc,const char *icon,int iconlen,bool checkable) {qmw->registerFunctionality(i,name,desc,icon,iconlen,checkable);} -void qmpPluginAPI::unregisterFunctionality(std::string name) +void qmpPluginAPIImpl::unregisterFunctionality(std::string name) {qmw->unregisterFunctionality(name);} -int qmpPluginAPI::registerFileReadFinishedHandlerIntf(ICallBack* cb,void* userdata) +int qmpPluginAPIImpl::registerFileReadFinishedHandlerIntf(ICallBack* cb,void* userdata) {return qmw->getPlayer()->setFileReadFinishedCB(cb,userdata);} -void qmpPluginAPI::unregisterFileReadFinishedHandlerIntf(int intfhandle) +void qmpPluginAPIImpl::unregisterFileReadFinishedHandlerIntf(int intfhandle) {qmw->getPlayer()->unsetFileReadFinishedCB(intfhandle);} -void qmpPluginAPI::registerFileReader(qmpFileReader* reader,std::string name) +void qmpPluginAPIImpl::registerFileReader(qmpFileReader* reader,std::string name) {qmw->getPlayer()->registerReader(reader,name);} -void qmpPluginAPI::unregisterFileReader(std::string name) +void qmpPluginAPIImpl::unregisterFileReader(std::string name) {qmw->getPlayer()->unregisterReader(name);} -int qmpPluginAPI::registerEventHandler(callback_t cb,void *userdata,bool post) +int qmpPluginAPIImpl::registerEventHandler(callback_t cb,void *userdata,bool post) {return qmw->getPlayer()->registerEventHandler(cb,userdata,post);} -void qmpPluginAPI::unregisterEventHandler(int id) +void qmpPluginAPIImpl::unregisterEventHandler(int id) {qmw->getPlayer()->unregisterEventHandler(id);} -int qmpPluginAPI::registerEventReadHandler(callback_t cb,void *userdata) +int qmpPluginAPIImpl::registerEventReadHandler(callback_t cb,void *userdata) {return qmw->getPlayer()->registerEventReadHandler(cb,userdata);} -void qmpPluginAPI::unregisterEventReadHandler(int id) +void qmpPluginAPIImpl::unregisterEventReadHandler(int id) {qmw->getPlayer()->unregisterEventReadHandler(id);} -int qmpPluginAPI::registerFileReadFinishHook(callback_t cb,void *userdata) +int qmpPluginAPIImpl::registerFileReadFinishHook(callback_t cb,void *userdata) {return qmw->getPlayer()->registerFileReadFinishHook(cb,userdata);} -void qmpPluginAPI::unregisterFileReadFinishHook(int id) +void qmpPluginAPIImpl::unregisterFileReadFinishHook(int id) {qmw->getPlayer()->unregisterFileReadFinishHook(id);} -void qmpPluginAPI::registerOptionInt(std::string tab,std::string desc,std::string key,int min,int max,int defaultval) +void qmpPluginAPIImpl::registerOptionInt(std::string tab,std::string desc,std::string key,int min,int max,int defaultval) {qmw->getSettings()->registerOptionInt(tab,desc,key,min,max,defaultval);} -int qmpPluginAPI::getOptionInt(std::string key){return qmw->getSettings()->getOptionInt(key);} -void qmpPluginAPI::setOptionInt(std::string key,int val){qmw->getSettings()->setOptionInt(key,val);} -void qmpPluginAPI::registerOptionUint(std::string tab,std::string desc,std::string key,unsigned min,unsigned max,unsigned defaultval) +int qmpPluginAPIImpl::getOptionInt(std::string key){return qmw->getSettings()->getOptionInt(key);} +void qmpPluginAPIImpl::setOptionInt(std::string key,int val){qmw->getSettings()->setOptionInt(key,val);} +void qmpPluginAPIImpl::registerOptionUint(std::string tab,std::string desc,std::string key,unsigned min,unsigned max,unsigned defaultval) {qmw->getSettings()->registerOptionUint(tab,desc,key,min,max,defaultval);} -unsigned qmpPluginAPI::getOptionUint(std::string key){return qmw->getSettings()->getOptionUint(key);} -void qmpPluginAPI::setOptionUint(std::string key,unsigned val){qmw->getSettings()->setOptionUint(key,val);} -void qmpPluginAPI::registerOptionBool(std::string tab,std::string desc,std::string key,bool defaultval) +unsigned qmpPluginAPIImpl::getOptionUint(std::string key){return qmw->getSettings()->getOptionUint(key);} +void qmpPluginAPIImpl::setOptionUint(std::string key,unsigned val){qmw->getSettings()->setOptionUint(key,val);} +void qmpPluginAPIImpl::registerOptionBool(std::string tab,std::string desc,std::string key,bool defaultval) {qmw->getSettings()->registerOptionBool(tab,desc,key,defaultval);} -bool qmpPluginAPI::getOptionBool(std::string key){return qmw->getSettings()->getOptionBool(key);} -void qmpPluginAPI::setOptionBool(std::string key,bool val){qmw->getSettings()->setOptionBool(key,val);} -void qmpPluginAPI::registerOptionDouble(std::string tab,std::string desc,std::string key,double min,double max,double defaultval) +bool qmpPluginAPIImpl::getOptionBool(std::string key){return qmw->getSettings()->getOptionBool(key);} +void qmpPluginAPIImpl::setOptionBool(std::string key,bool val){qmw->getSettings()->setOptionBool(key,val);} +void qmpPluginAPIImpl::registerOptionDouble(std::string tab,std::string desc,std::string key,double min,double max,double defaultval) {qmw->getSettings()->registerOptionDouble(tab,desc,key,min,max,defaultval);} -double qmpPluginAPI::getOptionDouble(std::string key){return qmw->getSettings()->getOptionDouble(key);} -void qmpPluginAPI::setOptionDouble(std::string key,double val){qmw->getSettings()->setOptionDouble(key,val);} -void qmpPluginAPI::registerOptionString(std::string tab,std::string desc,std::string key,std::string defaultval,bool ispath) +double qmpPluginAPIImpl::getOptionDouble(std::string key){return qmw->getSettings()->getOptionDouble(key);} +void qmpPluginAPIImpl::setOptionDouble(std::string key,double val){qmw->getSettings()->setOptionDouble(key,val);} +void qmpPluginAPIImpl::registerOptionString(std::string tab,std::string desc,std::string key,std::string defaultval,bool ispath) {qmw->getSettings()->registerOptionString(tab,desc,key,defaultval,ispath);} -std::string qmpPluginAPI::getOptionString(std::string key){return qmw->getSettings()->getOptionString(key);} -void qmpPluginAPI::setOptionString(std::string key,std::string val){return qmw->getSettings()->setOptionString(key,val);} -void qmpPluginAPI::registerOptionEnumInt(std::string tab,std::string desc,std::string key,std::vector<std::string> options,int defaultval) +std::string qmpPluginAPIImpl::getOptionString(std::string key){return qmw->getSettings()->getOptionString(key);} +void qmpPluginAPIImpl::setOptionString(std::string key,std::string val){return qmw->getSettings()->setOptionString(key,val);} +void qmpPluginAPIImpl::registerOptionEnumInt(std::string tab,std::string desc,std::string key,std::vector<std::string> options,int defaultval) {qmw->getSettings()->registerOptionEnumInt(tab,desc,key,options,defaultval);} -int qmpPluginAPI::getOptionEnumInt(std::string key){return qmw->getSettings()->getOptionEnumInt(key);} -void qmpPluginAPI::setOptionEnumInt(std::string key,int val){return qmw->getSettings()->setOptionEnumInt(key,val);} +int qmpPluginAPIImpl::getOptionEnumInt(std::string key){return qmw->getSettings()->getOptionEnumInt(key);} +void qmpPluginAPIImpl::setOptionEnumInt(std::string key,int val){return qmw->getSettings()->setOptionEnumInt(key,val);} diff --git a/qmidiplayer-desktop/qmpplugin.hpp b/qmidiplayer-desktop/qmpplugin.hpp index 0020530..08343cd 100644 --- a/qmidiplayer-desktop/qmpplugin.hpp +++ b/qmidiplayer-desktop/qmpplugin.hpp @@ -15,11 +15,85 @@ struct qmpPlugin }; class qmpMainWindow; class qmpSettings; +class qmpPluginAPIImpl:public qmpPluginAPI +{ +public: + qmpPluginAPIImpl(); + ~qmpPluginAPIImpl(); + uint32_t getDivision(); + uint32_t getRawTempo(); + double getRealTempo(); + uint32_t getTimeSig(); + int getKeySig(); + uint32_t getNoteCount(); + uint32_t getMaxTick(); + uint32_t getCurrentPolyphone(); + uint32_t getMaxPolyphone(); + uint32_t getCurrentTimeStamp(); + uint32_t getCurrentPlaybackPercentage(); + int getChannelCC(int ch,int cc); + int getChannelPreset(int ch); + void playerSeek(uint32_t percentage); + double getPitchBend(int ch); + bool getChannelMask(int ch); + std::string getTitle(); + std::wstring getWTitle(); + std::string getChannelPresetString(int ch); + bool isDarkTheme(); + void* getMainWindow(); + + void discardCurrentEvent(); + void commitEventChange(SEvent d); + void callEventReaderCB(SEvent d); + void setFuncState(std::string name,bool state); + void setFuncEnabled(std::string name,bool enable); + + void registerFunctionality(qmpFuncBaseIntf* i,std::string name,std::string desc,const char* icon,int iconlen,bool checkable); + void unregisterFunctionality(std::string name); + int registerUIHook(std::string e,ICallBack* cb,void* userdat); + int registerUIHook(std::string e,callback_t cb,void* userdat); + void unregisterUIHook(std::string e,int hook); + void registerMidiOutDevice(qmpMidiOutDevice* dev,std::string name); + void unregisterMidiOutDevice(std::string name); + int registerEventReaderIntf(ICallBack* cb,void* userdata); + void unregisterEventReaderIntf(int intfhandle); + int registerEventHandlerIntf(ICallBack* cb,void* userdata); + void unregisterEventHandlerIntf(int intfhandle); + int registerFileReadFinishedHandlerIntf(ICallBack* cb,void* userdata); + void unregisterFileReadFinishedHandlerIntf(int intfhandle); + int registerEventHandler(callback_t cb,void *userdata,bool post=false); + void unregisterEventHandler(int id); + int registerEventReadHandler(callback_t cb,void *userdata); + void unregisterEventReadHandler(int id); + int registerFileReadFinishHook(callback_t cb,void *userdata); + void unregisterFileReadFinishHook(int id); + void registerFileReader(qmpFileReader* reader,std::string name); + void unregisterFileReader(std::string name); + + void registerOptionInt(std::string tab,std::string desc,std::string key,int min,int max,int defaultval); + int getOptionInt(std::string key); + void setOptionInt(std::string key,int val); + void registerOptionUint(std::string tab,std::string desc,std::string key,unsigned min,unsigned max,unsigned defaultval); + unsigned getOptionUint(std::string key); + void setOptionUint(std::string key,unsigned val); + void registerOptionBool(std::string tab,std::string desc,std::string key,bool defaultval); + bool getOptionBool(std::string key); + void setOptionBool(std::string key,bool val); + void registerOptionDouble(std::string tab,std::string desc,std::string key,double min,double max,double defaultval); + double getOptionDouble(std::string key); + void setOptionDouble(std::string key,double val); + void registerOptionString(std::string tab,std::string desc,std::string key,std::string defaultval,bool ispath=false); + std::string getOptionString(std::string key); + void setOptionString(std::string key,std::string val); + void registerOptionEnumInt(std::string tab,std::string desc,std::string key,std::vector<std::string> options,int defaultval); + int getOptionEnumInt(std::string key); + void setOptionEnumInt(std::string key,int val); +}; class qmpPluginManager { private: std::vector<qmpPlugin> plugins; - static qmpPluginAPI* pluginAPI; + static qmpPluginAPIImpl* pluginAPI; static qmpMainWindow* mainwindow; static qmpSettings* settings; public: @@ -29,7 +103,7 @@ class qmpPluginManager void scanPlugins(const std::vector<std::string> &pp); void initPlugins(); void deinitPlugins(); - friend class qmpPluginAPI; + friend class qmpPluginAPIImpl; friend class qmpMainWindow; }; #endif // QMPPLUGIN_H |