NCBI C++ ToolKit
version.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef CORELIB___VERSION__HPP
2 #define CORELIB___VERSION__HPP
3 
4 /* $Id: version.hpp 100668 2023-08-24 17:03:58Z gouriano $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Denis Vakatov, Vladimir Ivanov, Anatoliy Kuznetsov
30  *
31  *
32  */
33 
34 /// @file version.hpp
35 /// Define CVersionInfo, a version info storage class.
36 
37 
38 #include <corelib/version_api.hpp>
39 #include <common/ncbi_build_info.h>
40 
41 
42 
44 
45 /** @addtogroup Version
46  *
47  * @{
48  */
49 
50 // Define macros to set application version
51 #ifndef NCBI_BUILD_TIME
52 # define NCBI_BUILD_TIME __DATE__ " " __TIME__
53 #endif
54 
55 #ifdef NCBI_BUILD_TAG
56 # define NCBI_BUILD_TAG_PROXY NCBI_AS_STRING(NCBI_BUILD_TAG)
57 #else
58 # define NCBI_BUILD_TAG_PROXY ""
59 #endif
60 
61 // Cope with potentially having an older ncbi_build_info.h
62 #ifndef NCBI_TEAMCITY_PROJECT_NAME_SBUILDINFO
63 # define NCBI_TEAMCITY_PROJECT_NAME_SBUILDINFO \
64  .Extra(SBuildInfo::eTeamCityProjectName, NCBI_TEAMCITY_PROJECT_NAME_PROXY)
65 # define NCBI_TEAMCITY_BUILDCONF_NAME_SBUILDINFO \
66  .Extra(SBuildInfo::eTeamCityBuildConf, NCBI_TEAMCITY_BUILDCONF_NAME_PROXY)
67 # define NCBI_TEAMCITY_BUILD_NUMBER_SBUILDINFO \
68  .Extra(SBuildInfo::eTeamCityBuildNumber, NCBI_TEAMCITY_BUILD_NUMBER_PROXY)
69 # define NCBI_SUBVERSION_REVISION_SBUILDINFO \
70  .Extra(SBuildInfo::eSubversionRevision, NCBI_SUBVERSION_REVISION_PROXY)
71 # define NCBI_SC_VERSION_SBUILDINFO \
72  .Extra(SBuildInfo::eStableComponentsVersion, NCBI_SC_VERSION_PROXY)
73 #endif
74 
75 // Cope with potentially having an older ncbi_source_ver.h
76 #ifndef NCBI_SRCTREE_VER_SBUILDINFO
77 # ifdef NCBI_SRCTREE_NAME_PROXY
78 # define NCBI_SRCTREE_VER_SBUILDINFO \
79  .Extra(NCBI_SRCTREE_NAME_PROXY, NCBI_SRCTREE_VER_PROXY)
80 # else
81 # define NCBI_SRCTREE_VER_SBUILDINFO /* empty */
82 # endif
83 #endif
84 
85 #ifdef NCBI_APP_BUILT_AS
86 # define NCBI_BUILT_AS_SBUILDINFO \
87  .Extra(SBuildInfo::eBuiltAs, NCBI_AS_STRING(NCBI_APP_BUILT_AS))
88 #else
89 # define NCBI_BUILT_AS_SBUILDINFO /* empty */
90 #endif
91 
92 #ifdef NCBI_TEAMCITY_BUILD_ID
93 # define NCBI_BUILD_ID NCBI_TEAMCITY_BUILD_ID
94 #elif defined(NCBI_BUILD_SESSION_ID)
95 # define NCBI_BUILD_ID NCBI_AS_STRING(NCBI_BUILD_SESSION_ID)
96 #endif
97 #ifdef NCBI_BUILD_ID
98 # define NCBI_BUILD_ID_SBUILDINFO .Extra(SBuildInfo::eBuildID, NCBI_BUILD_ID)
99 #else
100 # define NCBI_BUILD_ID_SBUILDINFO /* empty */
101 #endif
102 
103 #define NCBI_SBUILDINFO_DEFAULT_IMPL() \
104  NCBI_SBUILDINFO_DEFAULT_INSTANCE() \
105  NCBI_TEAMCITY_PROJECT_NAME_SBUILDINFO \
106  NCBI_TEAMCITY_BUILDCONF_NAME_SBUILDINFO \
107  NCBI_TEAMCITY_BUILD_NUMBER_SBUILDINFO \
108  NCBI_BUILD_ID_SBUILDINFO \
109  NCBI_GIT_BRANCH_SBUILDINFO \
110  NCBI_REVISION_SBUILDINFO \
111  NCBI_SUBVERSION_REVISION_SBUILDINFO \
112  NCBI_SC_VERSION_SBUILDINFO \
113  NCBI_SRCTREE_VER_SBUILDINFO \
114  NCBI_BUILT_AS_SBUILDINFO
115 
116 #if defined(NCBI_USE_PCH) && !defined(NCBI_TEAMCITY_BUILD_NUMBER)
117 #define NCBI_SBUILDINFO_DEFAULT() SBuildInfo()
118 #else
119 #define NCBI_SBUILDINFO_DEFAULT() NCBI_SBUILDINFO_DEFAULT_IMPL()
120 #endif
121 #define NCBI_APP_SBUILDINFO_DEFAULT() NCBI_SBUILDINFO_DEFAULT_IMPL()
122 
123 #ifdef NCBI_SBUILDINFO_DEFAULT_INSTANCE
124 # undef NCBI_SBUILDINFO_DEFAULT_INSTANCE
125 #endif
126 #define NCBI_SBUILDINFO_DEFAULT_INSTANCE() SBuildInfo(NCBI_BUILD_TIME, NCBI_BUILD_TAG_PROXY)
127 
128 #ifdef CVersion
129 # undef CVersion
130 #endif
131 #ifdef CComponentVersionInfo
132 # undef CComponentVersionInfo
133 #endif
134 
136 {
137 public:
138  /// Constructor
139  CComponentVersionInfo(const string& component_name,
140  int ver_major,
141  int ver_minor,
142  int patch_level = 0,
143  const string& ver_name = kEmptyStr,
144  const SBuildInfo& build_info = NCBI_SBUILDINFO_DEFAULT())
145  : CComponentVersionInfoAPI(component_name, ver_major, ver_minor, patch_level, ver_name, build_info)
146  {
147  }
148 
149  /// Constructor
150  ///
151  /// @param component_name
152  /// component name
153  /// @param version
154  /// version string (eg, 1.2.4)
155  /// @param ver_name
156  /// version name
157  CComponentVersionInfo(const string& component_name,
158  const string& version,
159  const string& ver_name = kEmptyStr,
160  const SBuildInfo& build_info = NCBI_SBUILDINFO_DEFAULT())
161  : CComponentVersionInfoAPI(component_name, version, ver_name, build_info)
162  {
163  }
164 };
165 
166 
167 class CVersion : public CVersionAPI
168 {
169 public:
170 
171  explicit
173  : CVersionAPI(build_info)
174  {
175  }
176 
177  explicit
179  const SBuildInfo& build_info = NCBI_SBUILDINFO_DEFAULT())
180  : CVersionAPI(version, build_info)
181  {
182  }
183 
186  {
187  }
188 
190 
191  /// Add component version information
192  void AddComponentVersion(const string& component_name,
193  int ver_major,
194  int ver_minor,
195  int patch_level = 0,
196  const string& ver_name = kEmptyStr,
197  const SBuildInfo& build_info = NCBI_SBUILDINFO_DEFAULT())
198  {
199  CVersionAPI::AddComponentVersion(component_name, ver_major, ver_minor, patch_level, ver_name, build_info);
200  }
201 };
202 
203 
204 /* @} */
205 
206 
208 
209 #endif // CORELIB___VERSION__HPP
CVersionInfo –.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define kEmptyStr
Definition: ncbistr.hpp:123
void AddComponentVersion(const string &component_name, int ver_major, int ver_minor, int patch_level=0, const string &ver_name=kEmptyStr, const SBuildInfo &build_info=SBuildInfo(__DATE__ " " __TIME__, "") .Extra(SBuildInfo::eTeamCityProjectName, NCBI_TEAMCITY_PROJECT_NAME_PROXY) .Extra(SBuildInfo::eTeamCityBuildConf, NCBI_TEAMCITY_BUILDCONF_NAME_PROXY) .Extra(SBuildInfo::eTeamCityBuildNumber, NCBI_TEAMCITY_BUILD_NUMBER_PROXY) NCBI_GIT_BRANCH_SBUILDINFO NCBI_REVISION_SBUILDINFO .Extra(SBuildInfo::eSubversionRevision, NCBI_SUBVERSION_REVISION_PROXY) .Extra(SBuildInfo::eStableComponentsVersion, NCBI_SC_VERSION_PROXY))
Add component version information.
Definition: version.hpp:192
CVersion(const CVersionInfo &version, const SBuildInfo &build_info=SBuildInfo(__DATE__ " " __TIME__, "") .Extra(SBuildInfo::eTeamCityProjectName, NCBI_TEAMCITY_PROJECT_NAME_PROXY) .Extra(SBuildInfo::eTeamCityBuildConf, NCBI_TEAMCITY_BUILDCONF_NAME_PROXY) .Extra(SBuildInfo::eTeamCityBuildNumber, NCBI_TEAMCITY_BUILD_NUMBER_PROXY) NCBI_GIT_BRANCH_SBUILDINFO NCBI_REVISION_SBUILDINFO .Extra(SBuildInfo::eSubversionRevision, NCBI_SUBVERSION_REVISION_PROXY) .Extra(SBuildInfo::eStableComponentsVersion, NCBI_SC_VERSION_PROXY))
Definition: version.hpp:178
CVersion(const CVersion &version)
Definition: version.hpp:184
CComponentVersionInfo(const string &component_name, const string &version, const string &ver_name=kEmptyStr, const SBuildInfo &build_info=SBuildInfo(__DATE__ " " __TIME__, "") .Extra(SBuildInfo::eTeamCityProjectName, NCBI_TEAMCITY_PROJECT_NAME_PROXY) .Extra(SBuildInfo::eTeamCityBuildConf, NCBI_TEAMCITY_BUILDCONF_NAME_PROXY) .Extra(SBuildInfo::eTeamCityBuildNumber, NCBI_TEAMCITY_BUILD_NUMBER_PROXY) NCBI_GIT_BRANCH_SBUILDINFO NCBI_REVISION_SBUILDINFO .Extra(SBuildInfo::eSubversionRevision, NCBI_SUBVERSION_REVISION_PROXY) .Extra(SBuildInfo::eStableComponentsVersion, NCBI_SC_VERSION_PROXY))
Constructor.
Definition: version.hpp:157
CComponentVersionInfo(const string &component_name, int ver_major, int ver_minor, int patch_level=0, const string &ver_name=kEmptyStr, const SBuildInfo &build_info=SBuildInfo(__DATE__ " " __TIME__, "") .Extra(SBuildInfo::eTeamCityProjectName, NCBI_TEAMCITY_PROJECT_NAME_PROXY) .Extra(SBuildInfo::eTeamCityBuildConf, NCBI_TEAMCITY_BUILDCONF_NAME_PROXY) .Extra(SBuildInfo::eTeamCityBuildNumber, NCBI_TEAMCITY_BUILD_NUMBER_PROXY) NCBI_GIT_BRANCH_SBUILDINFO NCBI_REVISION_SBUILDINFO .Extra(SBuildInfo::eSubversionRevision, NCBI_SUBVERSION_REVISION_PROXY) .Extra(SBuildInfo::eStableComponentsVersion, NCBI_SC_VERSION_PROXY))
Constructor.
Definition: version.hpp:139
void AddComponentVersion(const string &component_name, int ver_major, int ver_minor, int patch_level, const string &ver_name, const SBuildInfo &build_info)
Add component version information.
Definition: version.cpp:691
CVersion(const SBuildInfo &build_info=SBuildInfo(__DATE__ " " __TIME__, "") .Extra(SBuildInfo::eTeamCityProjectName, NCBI_TEAMCITY_PROJECT_NAME_PROXY) .Extra(SBuildInfo::eTeamCityBuildConf, NCBI_TEAMCITY_BUILDCONF_NAME_PROXY) .Extra(SBuildInfo::eTeamCityBuildNumber, NCBI_TEAMCITY_BUILD_NUMBER_PROXY) NCBI_GIT_BRANCH_SBUILDINFO NCBI_REVISION_SBUILDINFO .Extra(SBuildInfo::eSubversionRevision, NCBI_SUBVERSION_REVISION_PROXY) .Extra(SBuildInfo::eStableComponentsVersion, NCBI_SC_VERSION_PROXY))
Definition: version.hpp:172
#define NCBI_SBUILDINFO_DEFAULT()
Definition: version.hpp:119
const string version
version string
Definition: variables.hpp:66
This class allows to add build info (date and tag) to application version.
Definition: version_api.hpp:62
Modified on Fri Sep 20 14:57:20 2024 by modify_doxy.py rev. 669887