TrueReality  v0.1.1912
trUtil::VersionUtil Class Reference

A utility to read and control the engines version numbers. More...

#include <VersionUtil.h>

Collaboration diagram for trUtil::VersionUtil:

Public Member Functions

 VersionUtil ()
 ctor. More...
 
 VersionUtil (std::string fileName)
 Constructor. More...
 
 VersionUtil (std::string fileName, std::string filePath)
 Constructor. More...
 
 VersionUtil (std::string fileName, std::string filePath, std::string repoPath)
 Constructor. More...
 
 ~VersionUtil ()
 dtor. More...
 
void SaveVersionFile ()
 Saves the version file currently in RAM to default location. More...
 
void SetVersion (int maj, int min, std::string yymm, int build)
 Sets the version numbers. More...
 
void SetVersion (int maj, int min, int yymm, int build)
 Sets the version numbers. More...
 
void GenerateVersionStructure ()
 Generates a copy of the version file in RAM. More...
 
void IncrementVersion ()
 Increments the version number of the build by one and sets the YYMM to current date. More...
 
void SetMajorVersion (int maj)
 Sets the Major part of the version string. More...
 
int GetMajorVersion ()
 Gets the Major part of the version string. More...
 
void SetMinorVersion (int min)
 Sets the Minor part of the version string. More...
 
int GetMinorVersion ()
 Gets the Minor part of the version string. More...
 
std::string GetYYMMVersion ()
 Gets the Year/Month part of the version string. More...
 
void SetYYMMVersion (std::string yymm)
 Sets the Year/Month part of the version string. More...
 
void SetYYMMVersion (int yymm)
 Sets the Year/Month part of the version string. More...
 
void SetBuildVersion (int build)
 Sets the Build part of the version string. More...
 
int GetBuildVersion ()
 Gets the Build part of the version string. More...
 
std::string GetVersionString ()
 Returns the full version string. More...
 
void UpdateVersion ()
 Updates the version file to the most recent HG/Git Revision and YTMM. More...
 

Static Public Attributes

static const std::string VERSION_FILE_NAME = std::string("Version.trver")
 
static const std::string MAJ_VERSION = std::string("Major")
 
static const std::string MIN_VERSION = std::string("Minor")
 
static const std::string YYMM_VERSION = std::string("YYMM")
 
static const std::string BUILD_VERSION = std::string("Build")
 

Private Member Functions

std::string GetTodaysVersionDate ()
 Returns todays date in the YYMM format as string. More...
 
int GetCurrentCommitNum ()
 Returns the current system HG/Git revision number. More...
 

Private Attributes

JSON::File mVersion
 
std::string mRepoPath = trUtil::StringUtils::STR_BLANK
 

Detailed Description

A utility to read and control the engines version numbers.

Author
Maxim Serebrennik

Definition at line 45 of file VersionUtil.h.

Constructor & Destructor Documentation

◆ VersionUtil() [1/4]

trUtil::VersionUtil::VersionUtil ( )

ctor.

Definition at line 45 of file VersionUtil.cpp.

◆ VersionUtil() [2/4]

trUtil::VersionUtil::VersionUtil ( std::string  fileName)

Constructor.

Parameters
fileNameFilename of the custom version file.

Definition at line 49 of file VersionUtil.cpp.

◆ VersionUtil() [3/4]

trUtil::VersionUtil::VersionUtil ( std::string  fileName,
std::string  filePath 
)

Constructor.

Parameters
fileNameFilename of the custom version file.
filePathFull path to where the version file is located.

Definition at line 53 of file VersionUtil.cpp.

◆ VersionUtil() [4/4]

trUtil::VersionUtil::VersionUtil ( std::string  fileName,
std::string  filePath,
std::string  repoPath 
)

Constructor.

Parameters
fileNameFilename of the file.
filePathFull pathname of the file.
repoPathFull pathname of the repo.

Definition at line 57 of file VersionUtil.cpp.

References trUtil::JSON::File::FileExists(), GenerateVersionStructure(), trUtil::JSON::File::GetFilePath(), LOG_W, mRepoPath, mVersion, trUtil::JSON::File::ReadFromFile(), SaveVersionFile(), trUtil::JSON::File::SetFileName(), and trUtil::JSON::File::SetFilePath().

Here is the call graph for this function:

◆ ~VersionUtil()

trUtil::VersionUtil::~VersionUtil ( )

dtor.

Definition at line 81 of file VersionUtil.cpp.

Member Function Documentation

◆ GenerateVersionStructure()

void trUtil::VersionUtil::GenerateVersionStructure ( )

Generates a copy of the version file in RAM.

Definition at line 110 of file VersionUtil.cpp.

References GetCurrentCommitNum(), GetTodaysVersionDate(), and SetVersion().

Referenced by VersionUtil().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetBuildVersion()

int trUtil::VersionUtil::GetBuildVersion ( )

Gets the Build part of the version string.

Returns
The build version.

Definition at line 172 of file VersionUtil.cpp.

References BUILD_VERSION, trUtil::JSON::File::GetInt(), and mVersion.

Referenced by GetVersionString(), and IncrementVersion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetCurrentCommitNum()

int trUtil::VersionUtil::GetCurrentCommitNum ( )
private

Returns the current system HG/Git revision number.

Note that the revision number is not the commit hash and could be different on individual systems. The best place to use this is on a build server. This needs TR_ROOT to be set, and .hg or .git folder to be in TR_ROOT.

Returns
The current commit number.

Definition at line 220 of file VersionUtil.cpp.

References BRIGHT_RED, DEFAULT, trUtil::StringUtils::FindAndReplace(), trUtil::FileUtils::GetInstance(), LOG_E, trUtil::Exception::LogException(), mRepoPath, trUtil::FileUtils::RunCommand(), trUtil::StringUtils::STR_BLANK(), and trUtil::Console::TextColor().

Referenced by GenerateVersionStructure(), and UpdateVersion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMajorVersion()

int trUtil::VersionUtil::GetMajorVersion ( )

Gets the Major part of the version string.

Returns
The major version.

Definition at line 130 of file VersionUtil.cpp.

References trUtil::JSON::File::GetInt(), MAJ_VERSION, and mVersion.

Referenced by GetVersionString(), trUtil::Console::Logo(), and UpdateVersion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMinorVersion()

int trUtil::VersionUtil::GetMinorVersion ( )

Gets the Minor part of the version string.

Returns
The minor version.

Definition at line 142 of file VersionUtil.cpp.

References trUtil::JSON::File::GetInt(), MIN_VERSION, and mVersion.

Referenced by GetVersionString(), trUtil::Console::Logo(), and UpdateVersion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTodaysVersionDate()

std::string trUtil::VersionUtil::GetTodaysVersionDate ( )
private

Returns todays date in the YYMM format as string.

Returns
The todays version date.

Definition at line 191 of file VersionUtil.cpp.

References trUtil::DateTime::GetMonth(), and trUtil::DateTime::GetYear().

Referenced by GenerateVersionStructure(), IncrementVersion(), and UpdateVersion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetVersionString()

std::string trUtil::VersionUtil::GetVersionString ( )

Returns the full version string.

Returns
The version string.

Definition at line 177 of file VersionUtil.cpp.

References GetBuildVersion(), GetMajorVersion(), GetMinorVersion(), GetYYMMVersion(), and LOG_E.

Referenced by IncremenetVersion(), trUtil::Console::Logo(), main(), SetVersion(), and UpdateVersion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetYYMMVersion()

std::string trUtil::VersionUtil::GetYYMMVersion ( )

Gets the Year/Month part of the version string.

Returns
The yymm version.

Definition at line 160 of file VersionUtil.cpp.

References trUtil::JSON::File::GetString(), mVersion, and YYMM_VERSION.

Referenced by GetVersionString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IncrementVersion()

void trUtil::VersionUtil::IncrementVersion ( )

Increments the version number of the build by one and sets the YYMM to current date.

Definition at line 117 of file VersionUtil.cpp.

References GetBuildVersion(), GetTodaysVersionDate(), SetBuildVersion(), and SetYYMMVersion().

Referenced by IncremenetVersion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SaveVersionFile()

void trUtil::VersionUtil::SaveVersionFile ( )

Saves the version file currently in RAM to default location.

Definition at line 86 of file VersionUtil.cpp.

References mVersion, and trUtil::JSON::File::WriteToFile().

Referenced by IncremenetVersion(), main(), SetVersion(), UpdateVersion(), and VersionUtil().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetBuildVersion()

void trUtil::VersionUtil::SetBuildVersion ( int  build)

Sets the Build part of the version string.

Parameters
buildThe build.

Definition at line 166 of file VersionUtil.cpp.

References BUILD_VERSION, mVersion, and trUtil::JSON::File::SetInt().

Referenced by IncrementVersion(), main(), and SetVersion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetMajorVersion()

void trUtil::VersionUtil::SetMajorVersion ( int  maj)

Sets the Major part of the version string.

Parameters
majThe maj.

Definition at line 124 of file VersionUtil.cpp.

References MAJ_VERSION, mVersion, and trUtil::JSON::File::SetInt().

Referenced by main(), and SetVersion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetMinorVersion()

void trUtil::VersionUtil::SetMinorVersion ( int  min)

Sets the Minor part of the version string.

Parameters
minThe minimum.

Definition at line 136 of file VersionUtil.cpp.

References MIN_VERSION, mVersion, and trUtil::JSON::File::SetInt().

Referenced by main(), and SetVersion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetVersion() [1/2]

void trUtil::VersionUtil::SetVersion ( int  maj,
int  min,
std::string  yymm,
int  build 
)

Sets the version numbers.

Fills in the version numbers.

Parameters
majThe maj.
minThe minimum.
yymmThe yymm.
buildThe build.

Definition at line 92 of file VersionUtil.cpp.

References SetBuildVersion(), SetMajorVersion(), SetMinorVersion(), and SetYYMMVersion().

Referenced by GenerateVersionStructure(), SetVersion(), and UpdateVersion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetVersion() [2/2]

void trUtil::VersionUtil::SetVersion ( int  maj,
int  min,
int  yymm,
int  build 
)

Sets the version numbers.

Fills in the version numbers.

Parameters
majThe maj.
minThe minimum.
yymmThe yymm.
buildThe build.

Definition at line 101 of file VersionUtil.cpp.

References SetBuildVersion(), SetMajorVersion(), SetMinorVersion(), and SetYYMMVersion().

Here is the call graph for this function:

◆ SetYYMMVersion() [1/2]

void trUtil::VersionUtil::SetYYMMVersion ( std::string  yymm)

Sets the Year/Month part of the version string.

Parameters
yymmThe yymm.

Definition at line 148 of file VersionUtil.cpp.

References mVersion, trUtil::JSON::File::SetString(), and YYMM_VERSION.

Referenced by IncrementVersion(), main(), and SetVersion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetYYMMVersion() [2/2]

void trUtil::VersionUtil::SetYYMMVersion ( int  yymm)

Sets the Year/Month part of the version string.

Parameters
yymmThe yymm.

Definition at line 154 of file VersionUtil.cpp.

References mVersion, trUtil::JSON::File::SetInt(), and YYMM_VERSION.

Here is the call graph for this function:

◆ UpdateVersion()

void trUtil::VersionUtil::UpdateVersion ( )

Updates the version file to the most recent HG/Git Revision and YTMM.

Definition at line 262 of file VersionUtil.cpp.

References GetCurrentCommitNum(), GetMajorVersion(), GetMinorVersion(), GetTodaysVersionDate(), and SetVersion().

Referenced by UpdateVersion().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ BUILD_VERSION

const std::string trUtil::VersionUtil::BUILD_VERSION = std::string("Build")
static

Definition at line 53 of file VersionUtil.h.

Referenced by GetBuildVersion(), and SetBuildVersion().

◆ MAJ_VERSION

const std::string trUtil::VersionUtil::MAJ_VERSION = std::string("Major")
static

Definition at line 50 of file VersionUtil.h.

Referenced by GetMajorVersion(), and SetMajorVersion().

◆ MIN_VERSION

const std::string trUtil::VersionUtil::MIN_VERSION = std::string("Minor")
static

Definition at line 51 of file VersionUtil.h.

Referenced by GetMinorVersion(), and SetMinorVersion().

◆ mRepoPath

std::string trUtil::VersionUtil::mRepoPath = trUtil::StringUtils::STR_BLANK
private

Definition at line 244 of file VersionUtil.h.

Referenced by GetCurrentCommitNum(), and VersionUtil().

◆ mVersion

◆ VERSION_FILE_NAME

const std::string trUtil::VersionUtil::VERSION_FILE_NAME = std::string("Version.trver")
static

Definition at line 49 of file VersionUtil.h.

◆ YYMM_VERSION

const std::string trUtil::VersionUtil::YYMM_VERSION = std::string("YYMM")
static

Definition at line 52 of file VersionUtil.h.

Referenced by GetYYMMVersion(), and SetYYMMVersion().


The documentation for this class was generated from the following files: