-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5927: Introduce auxiliary classes to deal with version-specific sett…
…ings files.
- Loading branch information
1 parent
c5deae2
commit 2b7db90
Showing
8 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
namespace settings | ||
{ | ||
|
||
// Represents an application version tag with Major and Minor numbers | ||
class MajorMinorVersion | ||
{ | ||
private: | ||
int _majorVersion; | ||
int _minorVersion; | ||
|
||
public: | ||
MajorMinorVersion(const std::string& versionString) | ||
{ | ||
// Extract the version from the given string | ||
_majorVersion = 0; | ||
_minorVersion = 0; | ||
} | ||
|
||
// Compare this version to the other one, returning true if this is instance is smaller | ||
bool operator<(const MajorMinorVersion& other) const | ||
{ | ||
if (_majorVersion < other._majorVersion) | ||
{ | ||
return true; | ||
} | ||
|
||
// If major version matches, minor version decides | ||
if (_majorVersion == other._majorVersion) | ||
{ | ||
return _minorVersion < other._minorVersion; | ||
} | ||
|
||
// Major version is larger | ||
return false; | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include "version.h" | ||
#include "imodule.h" | ||
|
||
#include "MajorMinorVersion.h" | ||
|
||
namespace settings | ||
{ | ||
|
||
class SettingsManager | ||
{ | ||
private: | ||
const IApplicationContext& _context; | ||
MajorMinorVersion _currentVersion; | ||
|
||
public: | ||
SettingsManager(const IApplicationContext& context) : | ||
SettingsManager(context, RADIANT_VERSION) | ||
{} | ||
|
||
SettingsManager(const SettingsManager& other) = delete; | ||
SettingsManager& operator=(const SettingsManager& other) = delete; | ||
|
||
// Construct a settings manager instance with a specific version | ||
// string in the format "Major.Minor.Micro[BuildSuffix]", or "2.14.0pre1". | ||
// Mainly used for unit test purposes, regular code should use the default constructor. | ||
SettingsManager(const IApplicationContext& context, const std::string& currentVersion) : | ||
_context(context), | ||
_currentVersion(currentVersion) | ||
{} | ||
|
||
// TODO | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include "gtest/gtest.h" | ||
|
||
#include "settings/MajorMinorVersion.h" | ||
|
||
namespace test | ||
{ | ||
|
||
TEST(MajorMinorVersion, ParseFromString) | ||
{ | ||
// TODO | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters