ins_module.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * @Description:
  3. * @Version: 1.0
  4. * @Autor: lishengyin
  5. * @Date: 2022-04-01 15:07:56
  6. * @LastEditors: lishengyin
  7. * @LastEditTime: 2022-04-11 10:57:16
  8. */
  9. #ifndef __ISNS_MODEL_HPP_
  10. #define __ISNS_MODEL_HPP_
  11. #include <string.h>
  12. #include <unistd.h>
  13. #include <string>
  14. #include <vector>
  15. #include <iostream>
  16. #include "private/ins_module_private.hpp"
  17. using namespace std;
  18. namespace ins{
  19. class ModelCenter:private NonCopyable
  20. {
  21. private:
  22. ModelCenter(){}
  23. public:
  24. using Ptr = std::shared_ptr<ModelCenter>;
  25. ~ModelCenter(){}
  26. /**
  27. * @description: 注册
  28. * @param {string} ModelName
  29. * @param {Ptr&} ptr
  30. * @return {*}
  31. */
  32. static int8_t Register(std::string ModelName);
  33. /**
  34. * @description: 注销
  35. * @param {string} ModelName
  36. * @return {*}
  37. */
  38. static int8_t Cancel(std::string ModelName);
  39. /**
  40. * @description: 获取getModels
  41. * @param {*}
  42. * @return {*}
  43. */
  44. static vector<std::string> getModels();
  45. };
  46. class Module: private NonCopyable
  47. {
  48. public:
  49. using Ptr = std::shared_ptr<Module>;
  50. Module(std::string name): name_(name) {
  51. ins::ModelCenter::Register(name);
  52. }
  53. virtual ~Module(){
  54. ins::ModelCenter::Cancel(name_);
  55. }
  56. /**
  57. * @description: 初始化
  58. * @param {*}
  59. * @return {*}
  60. */
  61. virtual int8_t Init() = 0;
  62. /**
  63. * @description: 销毁
  64. * @param {*}
  65. * @return {*}
  66. */
  67. virtual void Destroy() = 0;
  68. /**
  69. * @description: 是否正常
  70. * @param {*}
  71. * @return {*}
  72. */
  73. virtual bool isNormally() = 0;
  74. /**
  75. * @description: 返回名字
  76. * @param {*}
  77. * @return {*}
  78. */
  79. virtual std::string getName(){
  80. return this->name_;
  81. }
  82. protected:
  83. bool valid = false;
  84. std::string name_;
  85. };
  86. };
  87. #endif