You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Singleton.cpp 1.1 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "Singleton.h"
  2. Singleton* Singleton::m_pInstance = nullptr;
  3. QMutex Singleton::m_mutex;
  4. Singleton::Singleton() : m_strExePath(""), m_strModelType("")
  5. {}
  6. Singleton::~Singleton()
  7. {}
  8. Singleton* Singleton::CreateInstance()
  9. {
  10. if (m_pInstance == nullptr) {
  11. QMutexLocker locker(&m_mutex);
  12. if (m_pInstance == nullptr) {
  13. m_pInstance = new Singleton();
  14. }
  15. }
  16. return m_pInstance;
  17. }
  18. bool Singleton::setExePath(QString path)
  19. {
  20. if (path == "") {
  21. return false;
  22. }
  23. m_strExePath = path;
  24. return true;
  25. }
  26. QString Singleton::getExePath()
  27. {
  28. return m_strExePath;
  29. }
  30. void Singleton::setConfigInfo(std::map<QString, ConfigInfo*>& mapStrConfigInfo)
  31. {
  32. m_mapStrConfigInfo = mapStrConfigInfo;
  33. }
  34. std::map<QString, ConfigInfo*>& Singleton::getConfigInfo()
  35. {
  36. return m_mapStrConfigInfo;
  37. }
  38. void Singleton::setModelType(QString modeltype)
  39. {
  40. m_strModelType = modeltype;
  41. }
  42. QString Singleton::getModelType()
  43. {
  44. return m_strModelType;
  45. }
  46. void Singleton::setDataPath(QString path)
  47. {
  48. m_strDataPath = path;
  49. }
  50. QString Singleton::getDataPath()
  51. {
  52. return m_strDataPath;
  53. }