aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2019-05-25 22:40:15 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2019-05-25 22:40:15 +0800
commit3f72121ac41741d53e4916f1275cbd4f93259c4d (patch)
tree15bba079c86de0e241812cd657ad190eb0c2c41a /include
parenteba45fdf11a98113b439db0510b55f14845db8fb (diff)
downloadQMidiPlayer-3f72121ac41741d53e4916f1275cbd4f93259c4d.tar.xz
Massive code refactor en cours!
Less complain from compilers: - use nullptr instead of NULL - use types for event fields - explicit type casting added Stop saving parameters of meta events in p1/p2 fields of SEvent. callback_t now uses std::function, deprecating ICallback. Not recommended for daily usage, or even testing: the code refactor is still a work in progress.
Diffstat (limited to 'include')
-rw-r--r--include/qmpcorepublic.hpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/include/qmpcorepublic.hpp b/include/qmpcorepublic.hpp
index 0994865..67a39e0 100644
--- a/include/qmpcorepublic.hpp
+++ b/include/qmpcorepublic.hpp
@@ -1,6 +1,7 @@
#ifndef QMPCOREPUBLIC_HPP
#define QMPCOREPUBLIC_HPP
#include <cstdint>
+#include <functional>
#include <vector>
#include <string>
#ifdef _WIN32
@@ -8,15 +9,15 @@
#else
#define EXPORTSYM __attribute__ ((visibility ("default")))
#endif
-#define QMP_PLUGIN_API_REV "1+indev7"
+#define QMP_PLUGIN_API_REV "1+indev8"
//MIDI Event structure
struct SEvent
{
- uint32_t iid,time,p1,p2;
- uint8_t type;
+ uint32_t iid,time;
+ uint8_t type,p1,p2;
std::string str;
SEvent(){time=p1=p2=0;type=0;str="";}
- SEvent(uint32_t _iid,uint32_t _t,char _tp,uint32_t _p1,uint32_t _p2,const char* s=NULL)
+ SEvent(uint32_t _iid,uint32_t _t,uint8_t _tp,uint8_t _p1,uint8_t _p2,const char* s=nullptr)
{
iid=_iid;time=_t;type=_tp;
p1=_p1;p2=_p2;
@@ -24,13 +25,6 @@ struct SEvent
}
friend bool operator <(const SEvent& a,const SEvent& b){return a.time-b.time?a.time<b.time:a.iid<b.iid;}
};
-//This struct is used by event reader callbacks and event handler callbacks
-//as caller data struct
-struct SEventCallBackData
-{
- uint32_t time,type,p1,p2;
- SEventCallBackData(uint32_t _t,uint32_t _p1,uint32_t _p2,uint32_t _tm){type=_t;p1=_p1;p2=_p2;time=_tm;}
-};
//MIDI Track class
class CMidiTrack{
public:
@@ -53,15 +47,16 @@ class CMidiFile{
};
//Generic callback function that can be used for hooking the core.
//"userdata" is set when you register the callback function.
+//Deprecated. Removing in 0.9.x.
class ICallBack
{
public:
ICallBack(){}
- virtual void callBack(void* callerdata,void* userdata)=0;
+ virtual void callBack(const void* callerdata,void* userdata)=0;
virtual ~ICallBack(){}
};
//alternative callback function type
-typedef void (*callback_t)(void*,void*);
+typedef std::function<void(const void*,void*)> callback_t;
//MIDI file reader interface. Use this to implement your file importer.
class qmpFileReader
{
@@ -70,7 +65,7 @@ class qmpFileReader
virtual ~qmpFileReader(){}
virtual CMidiFile* readFile(const char* fn)=0;
virtual void discardCurrentEvent()=0;
- virtual void commitEventChange(SEventCallBackData d)=0;
+ virtual void commitEventChange(SEvent d)=0;
};
//Functionality interface.
class qmpFuncBaseIntf
@@ -138,6 +133,7 @@ class qmpPluginAPI
virtual std::wstring getWTitle();
virtual std::string getChannelPresetString(int ch);
virtual bool isDarkTheme();
+ virtual void* getMainWindow();
//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
@@ -146,9 +142,9 @@ class qmpPluginAPI
//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(SEventCallBackData d);
+ virtual void commitEventChange(SEvent d);
//This function should be called from a file reader when it has read a new event
- virtual void callEventReaderCB(SEventCallBackData d);
+ virtual void callEventReaderCB(SEvent d);
virtual void setFuncState(std::string name,bool state);
virtual void setFuncEnabled(std::string name,bool enable);
@@ -165,6 +161,12 @@ class qmpPluginAPI
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);
+ 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);