CCOS.Dev.IODevice.Detail.hpp 2.8 KB

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