| 22 | std::unique_ptr<Configuration> GSDKInternal::testConfiguration = nullptr; |
| 23 | |
| 24 | GSDKInternal::GSDKInternal() : m_transitionToActiveEvent(), m_signalHeartbeatEvent(), m_initialPlayers() |
| 25 | { |
| 26 | // Need to setup the config first, as that tells us where to log |
| 27 | Configuration* config = nullptr; |
| 28 | |
| 29 | // Creating the smart ptr outside the if/else so the object is still alive when we access it below |
| 30 | std::unique_ptr<Configuration> configSmrtPtr = nullptr; |
| 31 | |
| 32 | // If they specified a particular config, use that, otherwise create our default |
| 33 | if (testConfiguration != nullptr) |
| 34 | { |
| 35 | // Using .get() instead of std::move so that the object doesn't get destroyed after this constructor |
| 36 | config = testConfiguration.get(); |
| 37 | } |
| 38 | else |
| 39 | { |
| 40 | std::string file_name = cGSDKUtils::getEnvironmentVariable("GSDK_CONFIG_FILE"); |
| 41 | std::ifstream is(file_name, std::ifstream::in); |
| 42 | |
| 43 | // If the configuration file is not there, we'll get our config from environment variables |
| 44 | if (is.fail()) |
| 45 | { |
| 46 | configSmrtPtr = std::make_unique<EnvironmentVariableConfiguration>(); |
| 47 | } |
| 48 | else |
| 49 | { |
| 50 | configSmrtPtr = std::make_unique<JsonFileConfiguration>(file_name); |
| 51 | } |
| 52 | config = configSmrtPtr.get(); |
| 53 | } |
| 54 | |
| 55 | std::unordered_map<std::string, std::string> gameCerts = config->getGameCertificates(); |
| 56 | for (auto it = gameCerts.begin(); it != gameCerts.end(); ++it) |
| 57 | { |
| 58 | m_configSettings[it->first] = it->second; |
| 59 | } |
| 60 | |
| 61 | std::unordered_map<std::string, std::string> metadata = config->getBuildMetadata(); |
| 62 | for (auto it = metadata.begin(); it != metadata.end(); ++it) |
| 63 | { |
| 64 | m_configSettings[it->first] = it->second; |
| 65 | } |
| 66 | |
| 67 | std::unordered_map<std::string, std::string> ports = config->getGamePorts(); |
| 68 | for (auto it = ports.begin(); it != ports.end(); ++it) |
| 69 | { |
| 70 | m_configSettings[it->first] = it->second; |
| 71 | } |
| 72 | |
| 73 | m_configSettings[GSDK::HEARTBEAT_ENDPOINT_KEY] = config->getHeartbeatEndpoint(); |
| 74 | m_configSettings[GSDK::SERVER_ID_KEY] = config->getServerId(); |
| 75 | m_configSettings[GSDK::LOG_FOLDER_KEY] = config->getLogFolder(); |
| 76 | m_configSettings[GSDK::SHARED_CONTENT_FOLDER_KEY] = config->getSharedContentFolder(); |
| 77 | m_configSettings[GSDK::CERTIFICATE_FOLDER_KEY] = config->getCertificateFolder(); |
| 78 | m_configSettings[GSDK::TITLE_ID_KEY] = config->getTitleId(); |
| 79 | m_configSettings[GSDK::BUILD_ID_KEY] = config->getBuildId(); |
| 80 | m_configSettings[GSDK::REGION_KEY] = config->getRegion(); |
| 81 | m_configSettings[GSDK::VM_ID_KEY] = config->getVmId(); |
nothing calls this directly
no test coverage detected