config.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * @Author: lishengyin lishengyin@sz-sunwin.com
  3. * @Date: 2022-09-04 20:42:45
  4. * @LastEditors: lishengyin
  5. * @LastEditTime: 2022-09-08 10:24:21
  6. * @FilePath: /gsd_check/models/config.cpp
  7. * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  8. */
  9. #include "config.hpp"
  10. namespace gsd
  11. {
  12. // 获取单例
  13. shared_ptr<config> config::getPtr(){
  14. static std::shared_ptr<config> m_config = nullptr;
  15. if(m_config == nullptr) m_config = std::shared_ptr<config>(new config);
  16. return m_config;
  17. }
  18. /**
  19. * @description: 获取版本号
  20. * @return {*}
  21. */
  22. std::string config::getVersion(){
  23. std::string version;
  24. version = std::to_string(GSD_MAJOR_VERSION) + "." + std::to_string(GSD_MINOR_VERSION) + "." + std::to_string(GSD_PATCH_VERSION);
  25. return version;
  26. }
  27. /**
  28. * @description: getApp
  29. * @return {*}
  30. */
  31. std::string config::getApp(){
  32. ifstream fin;
  33. fin.open("/etc/gsd/gsdApp", ios::in);
  34. if (!fin.is_open()){
  35. ErrorL << "无法找到这个文件!" << endl;
  36. return "";
  37. }
  38. char buff[1024] = { 0 };
  39. while (fin >> buff);
  40. fin.close();
  41. std::string str = buff;
  42. return str;
  43. }
  44. /**
  45. * @description: 获取
  46. * @return {*}
  47. */
  48. vector<int> config::getInferTargets(){
  49. unique_lock<std::mutex> lk(this->m_mtx);
  50. return this->InferTargets;
  51. }
  52. /**
  53. * @description: InferTargets
  54. * @param {vector<int>} data
  55. * @return {*}
  56. */
  57. void config::setInferTargets(vector<int> data){
  58. unique_lock<std::mutex> lk(this->m_mtx);
  59. this->InferTargets = data;
  60. }
  61. /**
  62. * @description: getAlienLabels
  63. * @return {*}
  64. */
  65. vector<int> config::getAlienLabels(){
  66. return this->AlienLabels;
  67. }
  68. /**
  69. * @description: setAlienLabels
  70. * @return {*}
  71. */
  72. void config::setAlienLabels(vector<int> data){
  73. this->AlienLabels = data;
  74. }
  75. } // namespace gsd