IniConfiguration.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include "native/utilities/IniConfiguration.h"
  9. #include "native/utilities/assetUtils.h"
  10. namespace
  11. {
  12. // singleton Pattern
  13. IniConfiguration* s_iniConfigurationSingleton = nullptr;
  14. }
  15. IniConfiguration::IniConfiguration(QObject* pParent)
  16. : QObject(pParent)
  17. , m_listeningPort(0)
  18. {
  19. AZ_Assert(s_iniConfigurationSingleton == nullptr, "Duplicate singleton installation detected.");
  20. s_iniConfigurationSingleton = this;
  21. }
  22. IniConfiguration::~IniConfiguration()
  23. {
  24. AZ_Assert(s_iniConfigurationSingleton == this, "There should always be a single singleton!");
  25. s_iniConfigurationSingleton = nullptr;
  26. }
  27. const IniConfiguration* IniConfiguration::Get()
  28. {
  29. return s_iniConfigurationSingleton;
  30. }
  31. void IniConfiguration::parseCommandLine(QStringList args)
  32. {
  33. for (QString arg : args)
  34. {
  35. if (arg.startsWith("--port="))
  36. {
  37. bool converted = false;
  38. quint16 port = arg.replace("--port=", "").toUShort(&converted);
  39. m_listeningPort = converted ? port : m_listeningPort;
  40. }
  41. }
  42. }
  43. void IniConfiguration::readINIConfigFile(QDir dir)
  44. {
  45. m_userConfigFilePath = dir.filePath("AssetProcessorConfiguration.ini");
  46. // if AssetProcessorProxyInformation.ini file exists then delete it
  47. // we used to store proxy info in this file
  48. if (QFile::exists(m_userConfigFilePath))
  49. {
  50. QFile::remove(m_userConfigFilePath);
  51. }
  52. m_listeningPort = AssetUtilities::ReadListeningPortFromSettingsRegistry();
  53. }
  54. quint16 IniConfiguration::listeningPort() const
  55. {
  56. return m_listeningPort;
  57. }
  58. void IniConfiguration::SetListeningPort(quint16 port)
  59. {
  60. m_listeningPort = port;
  61. }