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