DIOS.Dev.IODevice.Detail.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #pragma once
  2. #include <memory>
  3. #include <string>
  4. //#include "AppLog.Interface.hpp"
  5. #include "ExclusiveHolder.tlh"
  6. #include "ExclusiveHolder.tli"
  7. #include "Dispatch.tlh"
  8. #include "DIOS.Dev.IODevice.hpp"
  9. #pragma warning (disable:4251) // warning C4251: “DIOS::Dev::Detail::Dispatch::Add”: class“CXXHelper::Dispatch<int,std::string,std::string,std::string &>”需要有 dll 接口由 struct“DIOS::Dev::Detail::Dispatch”的客户端使用
  10. #ifdef DIOSLOGICDEVICE_EXPORTS
  11. #define _DIOSLogicDevice_API __declspec(dllexport)
  12. #else
  13. #define _DIOSLogicDevice_API __declspec(dllimport)
  14. #endif
  15. namespace DIOS::Dev::Detail
  16. {
  17. #if 0
  18. class _DIOSLogicDevice_API IOLog
  19. {
  20. public:
  21. static auto GetLog ()->ECOM::Log::ShareLog;
  22. };
  23. #endif
  24. //-----------------------------------------------------------------------------
  25. // Dispatch
  26. //-----------------------------------------------------------------------------
  27. namespace nDev = DIOS::Dev;
  28. struct _DIOSLogicDevice_API Dispatch
  29. {
  30. CXXHelper::Dispatch <RET_STATUS, std::string, std::string, std::string &> Add;
  31. CXXHelper::Dispatch <RET_STATUS, std::string, std::string, std::string &> Delete;
  32. CXXHelper::Dispatch <RET_STATUS, std::string, std::string, std::string &> Update;
  33. CXXHelper::Dispatch <RET_STATUS, std::string, std::string, std::string &> Action;
  34. CXXHelper::Dispatch <RET_STATUS, std::string, std::string&> Get;
  35. CXXHelper::Dispatch <RET_STATUS, std::string, std::string> Set;
  36. };
  37. //-----------------------------------------------------------------------------
  38. // IODeviceDetail
  39. // The root / base class for any IODeviceDetail
  40. //-----------------------------------------------------------------------------
  41. class _DIOSLogicDevice_API IODeviceDetail
  42. {
  43. using JSONString = std::string;
  44. IODeviceDetail (const IODeviceDetail &) = delete;
  45. IODeviceDetail (IODeviceDetail &&) = delete;
  46. IODeviceDetail & operator = (const IODeviceDetail &) = delete;
  47. IODeviceDetail & operator = (IODeviceDetail &&) = delete;
  48. public:
  49. IODeviceDetail (std::shared_ptr <IOEventCenter> center = nullptr);
  50. virtual ~IODeviceDetail ();
  51. virtual std::string GetGUID () const = 0;
  52. std::string GetResource ();
  53. virtual bool Prepare();
  54. virtual void SubscribeSelf(dios_mqtt_connection* conn) ;
  55. RET_STATUS Add (const std::string funcName, JSONString In, JSONString & Out);
  56. RET_STATUS Delete (const std::string funcName, JSONString In, JSONString & Out);
  57. RET_STATUS Update (const std::string funcName, JSONString In, JSONString & Out);
  58. RET_STATUS Action (const std::string funcName, JSONString In, JSONString & Out);
  59. RET_STATUS Get (const std::string funcName, JSONString& Out);
  60. RET_STATUS Set (const std::string funcName, JSONString In);
  61. public:
  62. std::shared_ptr <IOEventCenter> EventCenter;
  63. string GetDevicePath() {
  64. return m_strIODevicePath;
  65. }
  66. protected:
  67. struct Dispatch Dispatch;
  68. // ExclusiveHolder <Dispatch> Dispatch;
  69. string m_strIODevicePath;
  70. };
  71. //-----------------------------------------------------------------------------
  72. // IOLogicUnit
  73. // The root / base class for any IOLogicUnit
  74. //-----------------------------------------------------------------------------
  75. class _DIOSLogicDevice_API IOLogicUnit
  76. {
  77. public:
  78. IOLogicUnit () {}
  79. virtual ~IOLogicUnit () {}
  80. };
  81. }