A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
version.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Lawrence Livermore National Laboratory
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Authors: Mathew Bielejeski <bielejeski1@llnl.gov>
18 */
19
20#include "version.h"
21
22#include "ns3/version-defines.h"
23
24#include <sstream>
25
26/**
27 * \file
28 * \ingroup buildversion
29 * ns3::Version implementation
30 */
31
32namespace ns3
33{
34
35std::string
37{
38 return NS3_VERSION_TAG;
39}
40
41std::string
43{
44 return NS3_VERSION_CLOSEST_TAG;
45}
46
49{
50 return NS3_VERSION_MAJOR;
51}
52
55{
56 return NS3_VERSION_MINOR;
57}
58
61{
62 return NS3_VERSION_PATCH;
63}
64
65std::string
67{
68 return std::string{NS3_VERSION_RELEASE_CANDIDATE};
69}
70
73{
74 return NS3_VERSION_TAG_DISTANCE;
75}
76
77bool
79{
80 return static_cast<bool>(NS3_VERSION_DIRTY_FLAG);
81}
82
83std::string
85{
86 return std::string{NS3_VERSION_COMMIT_HASH};
87}
88
89std::string
91{
92 return std::string{NS3_VERSION_BUILD_PROFILE};
93}
94
95std::string
97{
98 std::ostringstream ostream;
99 ostream << VersionTag();
100
101 auto ancestorTag = ClosestAncestorTag();
102 if ((!ancestorTag.empty() && (ancestorTag != VersionTag())) || TagDistance() > 0)
103 {
104 ostream << "+";
105 }
106 if (DirtyWorkingTree())
107 {
108 ostream << "*";
109 }
110
111 return ostream.str();
112}
113
114std::string
116{
117 std::ostringstream ostream;
118 ostream << ClosestAncestorTag();
119
120 if (TagDistance() > 0)
121 {
122 ostream << "+";
123 }
124 if (DirtyWorkingTree())
125 {
126 ostream << "*";
127 }
128
129 return ostream.str();
130}
131
132std::string
134{
135 std::ostringstream ostream;
136 ostream << VersionTag();
137
138 auto ancestorTag = ClosestAncestorTag();
139 if (!ancestorTag.empty() && (ancestorTag != VersionTag()))
140 {
141 ostream << '+' << ancestorTag;
142 }
143
144 auto tagDistance = TagDistance();
145
146 if (tagDistance > 0)
147 {
148 ostream << '+' << tagDistance;
149 }
150
151 ostream << '@' << CommitHash();
152
153 if (DirtyWorkingTree())
154 {
155 ostream << "-dirty";
156 }
157
158 ostream << '-' << BuildProfile();
159
160 return ostream.str();
161}
162
163} // namespace ns3
static uint32_t Patch()
Patch component of the build version.
Definition: version.cc:60
static std::string CommitHash()
Hash of the most recent commit.
Definition: version.cc:84
static uint32_t Major()
Major component of the build version.
Definition: version.cc:48
static uint32_t TagDistance()
The number of commits between the current commit and the tag returned by ClosestAncestorTag().
Definition: version.cc:72
static std::string BuildProfile()
Indicates the type of build that was performed (debug/release/optimized).
Definition: version.cc:90
static std::string ReleaseCandidate()
Release candidate component of the build version.
Definition: version.cc:66
static uint32_t Minor()
Minor component of the build version.
Definition: version.cc:54
static std::string BuildSummary()
Constructs a string containing the most recent tag and status flags.
Definition: version.cc:115
static bool DirtyWorkingTree()
Indicates whether there were uncommitted changes during the build.
Definition: version.cc:78
static std::string ShortVersion()
Constructs a string containing the ns-3 major and minor version components, and indication of additio...
Definition: version.cc:96
static std::string LongVersion()
Constructs a string containing all of the build details.
Definition: version.cc:133
static std::string VersionTag()
Returns the ns-3 version tag of the closest ancestor commit.
Definition: version.cc:36
static std::string ClosestAncestorTag()
Returns the closest tag that is attached to a commit that is an ancestor of the current branch head.
Definition: version.cc:42
Every class exported by the ns3 library is enclosed in the ns3 namespace.
class ns3::Version definition