DIOS.Dev.IODevice.Detail.hpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 <nDev::RET_STATUS, std::string, std::string, std::string &> Add;
  31. CXXHelper::Dispatch <nDev::RET_STATUS, std::string, std::string, std::string &> Delete;
  32. CXXHelper::Dispatch <nDev::RET_STATUS, std::string, std::string, std::string &> Update;
  33. CXXHelper::Dispatch <nDev::RET_STATUS, std::string, std::string, std::string &> Action;
  34. CXXHelper::Dispatch <nDev::RET_STATUS, std::string, std::string&> Get;
  35. CXXHelper::Dispatch <nDev::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);
  50. virtual ~IODeviceDetail ();
  51. virtual std::string GetGUID () const = 0;
  52. std::string GetResource () const;
  53. virtual bool Prepare();
  54. RET_STATUS Add (const std::string funcName, JSONString In, JSONString & Out);
  55. RET_STATUS Delete (const std::string funcName, JSONString In, JSONString & Out);
  56. RET_STATUS Update (const std::string funcName, JSONString In, JSONString & Out);
  57. RET_STATUS Action (const std::string funcName, JSONString In, JSONString & Out);
  58. RET_STATUS Get (const std::string funcName, JSONString& Out);
  59. RET_STATUS Set (const std::string funcName, JSONString In);
  60. public:
  61. std::shared_ptr <IOEventCenter> EventCenter;
  62. protected:
  63. // struct Dispatch Dispatch;
  64. ExclusiveHolder <Dispatch> Dispatch;
  65. };
  66. //-----------------------------------------------------------------------------
  67. // IOLogicUnit
  68. // The root / base class for any IOLogicUnit
  69. //-----------------------------------------------------------------------------
  70. class _DIOSLogicDevice_API IOLogicUnit
  71. {
  72. public:
  73. IOLogicUnit () {}
  74. virtual ~IOLogicUnit () {}
  75. };
  76. }