CCOS.Dev.IODevice.Detail.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #pragma once
  2. #include <memory>
  3. #include <string>
  4. //#include "AppLog.Interface.hpp"
  5. #include "CCOS.Dev.IODevice.hpp"
  6. #include "ExclusiveHolder.h"
  7. #include "Dispatch.h"
  8. #define _CCOSLogicDevice_API
  9. namespace CCOS::Dev::Detail
  10. {
  11. #if 0
  12. class _CCOSLogicDevice_API IOLog
  13. {
  14. public:
  15. static auto GetLog ()->ECOM::Log::ShareLog;
  16. };
  17. #endif
  18. //-----------------------------------------------------------------------------
  19. // Dispatch
  20. //-----------------------------------------------------------------------------
  21. namespace nDev = CCOS::Dev;
  22. struct _CCOSLogicDevice_API Dispatch
  23. {
  24. CXXHelper::Dispatch <RET_STATUS, std::string, std::string, std::string &> Add;
  25. CXXHelper::Dispatch <RET_STATUS, std::string, std::string, std::string &> Delete;
  26. CXXHelper::Dispatch <RET_STATUS, std::string, std::string, std::string &> Update;
  27. CXXHelper::Dispatch <RET_STATUS, std::string, std::string, std::string &> Action;
  28. CXXHelper::Dispatch <RET_STATUS, std::string, std::string&> Get;
  29. CXXHelper::Dispatch <RET_STATUS, std::string, std::string> Set;
  30. };
  31. //-----------------------------------------------------------------------------
  32. // IODeviceDetail
  33. // The root / base class for any IODeviceDetail
  34. //-----------------------------------------------------------------------------
  35. class _CCOSLogicDevice_API IODeviceDetail
  36. {
  37. using JSONString = std::string;
  38. IODeviceDetail (const IODeviceDetail &) = delete;
  39. IODeviceDetail (IODeviceDetail &&) = delete;
  40. IODeviceDetail & operator = (const IODeviceDetail &) = delete;
  41. IODeviceDetail & operator = (IODeviceDetail &&) = delete;
  42. public:
  43. IODeviceDetail (std::shared_ptr <IOEventCenter> center = nullptr);
  44. virtual ~IODeviceDetail ();
  45. virtual std::string GetGUID () const = 0;
  46. std::string GetResource () const;
  47. virtual bool Prepare();
  48. virtual void SubscribeSelf(ccos_mqtt_connection* conn) ;
  49. RET_STATUS Add (const std::string funcName, JSONString In, JSONString & Out);
  50. RET_STATUS Delete (const std::string funcName, JSONString In, JSONString & Out);
  51. RET_STATUS Update (const std::string funcName, JSONString In, JSONString & Out);
  52. RET_STATUS Action (const std::string funcName, JSONString In, JSONString & Out);
  53. RET_STATUS Get (const std::string funcName, JSONString& Out);
  54. RET_STATUS Set (const std::string funcName, JSONString In);
  55. public:
  56. std::shared_ptr <IOEventCenter> EventCenter;
  57. protected:
  58. // struct Dispatch Dispatch;
  59. ExclusiveHolder <Dispatch> m_Dispatch;
  60. string m_strIODevicePath;
  61. };
  62. //-----------------------------------------------------------------------------
  63. // IOLogicUnit
  64. // The root / base class for any IOLogicUnit
  65. //-----------------------------------------------------------------------------
  66. class _CCOSLogicDevice_API IOLogicUnit
  67. {
  68. public:
  69. IOLogicUnit () {}
  70. virtual ~IOLogicUnit () {}
  71. };
  72. }