123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- #pragma once
- #include <string>
- #include <list>
- #include <vector>
- #include <functional>
- #pragma warning (disable:4251) // “Mediator::OnXX”: class“CXXHelper::Event<int>”需要有 dll 接口由 class“Mediator”的客户端使用
- #include "TmplEvent.tlh"
- #ifdef MEDIATOR_EXPORTS
- #define _DeviceMediator_API __declspec(dllexport)
- #else
- #define _DeviceMediator_API __declspec(dllimport)
- #endif
- namespace DIOS
- {
- namespace Dev
- {
- using JSONString = std::string;
- struct tIODeviceGUID
- {
- using IODeviceGUID = std::function <std::string ()>;
- DWORD ID;
- IODeviceGUID funDeviceGUID;
- };
- class tIOAction
- {
- public:
- using IOAction = std::function <int (JSONString, JSONString &)>;
- DWORD ID;
- std::string ProtoFuncName;
- IOAction funAction;
- };
- struct tIOAttribute
- {
- using IOAttribute = std::function <int (JSONString &)>;
- DWORD ID;
- std::string ProtoFuncName;
- IOAttribute funAttribute;
- };
- //-----------------------------------------------------------------------------
- // Mediator
- //-----------------------------------------------------------------------------
- class _DeviceMediator_API Mediator
- {
- public:
- Mediator ();
- virtual ~Mediator ();
- public:
- bool Unregister (DWORD ID);
- //< Used by Driver or host
- public:
- int Action (std::string FuncName, JSONString, JSONString &);
- int Get (std::string FuncName, JSONString &);
- std::string GetDeviceType ();
- std::string GetDeviceResource ();
- //>
- //< Used by Device module
- public:
- DWORD RegistDeviceGUID (tIODeviceGUID::IODeviceGUID fun);
- DWORD RegistAction (std::string FuncName, tIOAction::IOAction fun);
- DWORD RegistAttribute (std::string FuncName, tIOAttribute::IOAttribute fun);
- //>
- //< Notify (callback) interface
- public:
- CXXHelper::Event <int, std::string, JSONString> OnNotify;
- CXXHelper::Event <int, std::string, JSONString, JSONString, char *, int> OnDataNotify;
- CXXHelper::Event <std::string, DWORD, DWORD, DWORD, DWORD> OnMaxBlockSize;
- //>
- private:
- std::list <tIODeviceGUID> m_DeviceGUID;
- std::list <tIOAction> m_Action;
- std::list <tIOAttribute> m_Attribute;
- };
- }
- }
|