A Discrete-Event Network Simulator
API
ns3::Version Class Reference

Helper class providing functions to access various parts of the version string, as well as functions for composing short and long variants of the version string. More...

#include "version.h"

Static Public Member Functions

static std::string BuildProfile ()
 Indicates the type of build that was performed (debug/release/optimized). More...
 
static std::string BuildSummary ()
 Constructs a string containing the most recent tag and status flags. More...
 
static std::string ClosestAncestorTag ()
 Returns the closest tag that is attached to a commit that is an ancestor of the current branch head. More...
 
static std::string CommitHash ()
 Hash of the most recent commit. More...
 
static bool DirtyWorkingTree ()
 Indicates whether there were uncommitted changes during the build. More...
 
static std::string LongVersion ()
 Constructs a string containing all of the build details. More...
 
static uint32_t Major ()
 Major component of the build version. More...
 
static uint32_t Minor ()
 Minor component of the build version. More...
 
static uint32_t Patch ()
 Patch component of the build version. More...
 
static std::string ReleaseCandidate ()
 Release candidate component of the build version. More...
 
static std::string ShortVersion ()
 Constructs a string containing the ns-3 major and minor version components, and indication of additional commits or dirty status. More...
 
static uint32_t TagDistance ()
 The number of commits between the current commit and the tag returned by ClosestAncestorTag(). More...
 
static std::string VersionTag ()
 Returns the ns-3 version tag of the closest ancestor commit. More...
 

Detailed Description

Helper class providing functions to access various parts of the version string, as well as functions for composing short and long variants of the version string.

See CommandLine::PrintVersion() for an example on how to use Version to output a version string. command-line-example has been updated to include CommandLine::PrintVersion() in its output

build-version-example.cc illustrates using each of these functions.

Below is a partial view of a git branch:

Note
Square nodes represent tags
Circle nodes represent commits
dot_inline_dotgraph_2.png

Here are the values that will be assigned based on this example branch:

Component Value Notes
VersionTag ns-3.32
ClosestAncestorTag mytag
Major 3
Minor 32
Patch 0 This version tag does not have a patch field
ReleaseCandidate "" This version tag does not have a release candidate field
TagDistance 1
CommitHash g6ad7f05 g at front of hash indicates a git hash
DirtyWorkingTree Variable Depends on status of git working and stage areas
BuildProfile Variable Depends on the value of –build-profile option of ns3 configure

|

Definition at line 101 of file version.h.

Member Function Documentation

◆ BuildProfile()

std::string ns3::Version::BuildProfile ( )
static

Indicates the type of build that was performed (debug/release/optimized).

This information is set by the –build-profile option of ns3 configure

Returns
String containing the type of build

Definition at line 90 of file version.cc.

Referenced by LongVersion().

+ Here is the caller graph for this function:

◆ BuildSummary()

std::string ns3::Version::BuildSummary ( )
static

Constructs a string containing the most recent tag and status flags.

In the case where closest-ancestor-tag == version-tag, the output of this function will be the same as ShortVersion()

The format of the constructed string is <closest-ancestor-tag>[flags].

[flags] will contain none, one, or both characters depending on the state of the branch

Returns
String containing the closest ancestor tag and flags.

Definition at line 115 of file version.cc.

References ClosestAncestorTag(), DirtyWorkingTree(), and TagDistance().

+ Here is the call graph for this function:

◆ ClosestAncestorTag()

std::string ns3::Version::ClosestAncestorTag ( )
static

Returns the closest tag that is attached to a commit that is an ancestor of the current branch head.

The value returned by this function may be the same as VersionTag() if the ns-3 version tag is the closest ancestor tag.

Returns
Closest tag attached to an ancestor of the current commit

Definition at line 42 of file version.cc.

Referenced by BuildSummary(), LongVersion(), and ShortVersion().

+ Here is the caller graph for this function:

◆ CommitHash()

std::string ns3::Version::CommitHash ( )
static

Hash of the most recent commit.

The hash component is the id of the most recent commit. The returned value is a hexadecimal string with enough data to uniquely identify the commit.

The first character of the string is a letter indicating the type of repository that was in use: g=git

Example of hash output: g6bfb0c9

Returns
hexadecimal representation of the most recent commit id

Definition at line 84 of file version.cc.

Referenced by LongVersion().

+ Here is the caller graph for this function:

◆ DirtyWorkingTree()

bool ns3::Version::DirtyWorkingTree ( )
static

Indicates whether there were uncommitted changes during the build.

Returns
true if the working tree had uncommitted changes.

Definition at line 78 of file version.cc.

Referenced by BuildSummary(), LongVersion(), and ShortVersion().

+ Here is the caller graph for this function:

◆ LongVersion()

std::string ns3::Version::LongVersion ( )
static

Constructs a string containing all of the build details.

The format of the constructed string is

* ns-<major>.<minor>[.patch][-rc][-closest-tag]-<tag-distance>@<hash>[-dirty]-<build-profile>
* 

[patch], [rc], [closest-tag], and [dirty] will only be present under certain circumstances:

Returns
String containing full version

Definition at line 133 of file version.cc.

References BuildProfile(), ClosestAncestorTag(), CommitHash(), DirtyWorkingTree(), TagDistance(), and VersionTag().

Referenced by ns3::CommandLine::GetVersion().

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

◆ Major()

uint32_t ns3::Version::Major ( )
static

Major component of the build version.

The format of the build version string is

ns-<major>.<minor>[.patch][-RC<digit>] 

The major component is the number before the first period

Returns
The major component of the build version

Definition at line 48 of file version.cc.

◆ Minor()

uint32_t ns3::Version::Minor ( )
static

Minor component of the build version.

The format of the build version string is

ns-<major>.<minor>[.patch][-RC<digit>] 

The minor component is the number after the first period

Returns
The minor component of the build version

Definition at line 54 of file version.cc.

◆ Patch()

uint32_t ns3::Version::Patch ( )
static

Patch component of the build version.

A build version with a patch component will have the format

ns-<major>.<minor>.<patch> 

The patch component is the number after the second period

Returns
The patch component of the build version or 0 if the build version does not have a patch component

Definition at line 60 of file version.cc.

◆ ReleaseCandidate()

std::string ns3::Version::ReleaseCandidate ( )
static

Release candidate component of the build version.

A build version with a release candidate will have the format

ns-<major>.<minor>[.patch]-RC<digit> 

The string returned by this function will have the format RC<digit>

Returns
The release candidate component of the build version or an empty string if the build version does not have a release candidate component

Definition at line 66 of file version.cc.

◆ ShortVersion()

std::string ns3::Version::ShortVersion ( )
static

Constructs a string containing the ns-3 major and minor version components, and indication of additional commits or dirty status.

The format of the constructed string is

ns-<major>.<minor>[.patch][-rc]<flags> 

[flags] will contain none, one, or both characters depending on the state of the branch

Returns
String containing the ns-3 major and minor components and flags.

Definition at line 96 of file version.cc.

References ClosestAncestorTag(), DirtyWorkingTree(), TagDistance(), and VersionTag().

+ Here is the call graph for this function:

◆ TagDistance()

uint32_t ns3::Version::TagDistance ( )
static

The number of commits between the current commit and the tag returned by ClosestAncestorTag().

Returns
The number of commits made since the last tagged commit

Definition at line 72 of file version.cc.

Referenced by BuildSummary(), LongVersion(), and ShortVersion().

+ Here is the caller graph for this function:

◆ VersionTag()

std::string ns3::Version::VersionTag ( )
static

Returns the ns-3 version tag of the closest ancestor commit.

The format of the tag is

ns3-<major>.<minor>[.patch] 

The patch field is optional and may not be present. The value of patch defaults to 0 if the tag does not have a patch field.

Returns
ns-3 version tag

Definition at line 36 of file version.cc.

Referenced by LongVersion(), and ShortVersion().

+ Here is the caller graph for this function:

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