Skip to content
Snippets Groups Projects
Commit 716d7c46 authored by Ger van Diepen's avatar Ger van Diepen
Browse files

bug 468:

Add support for a single program version
parent 1dc8fc54
No related branches found
No related tags found
No related merge requests found
...@@ -35,8 +35,11 @@ namespace LOFAR { ...@@ -35,8 +35,11 @@ namespace LOFAR {
{ {
public: public:
// Add package/version to vector if not existing yet. // Add package/version to vector if not existing yet.
static void fillVersion (const std::string& package, // It returns false if the version differs from the main version.
static bool fillVersion (const std::string& package,
const std::string& version, const std::string& version,
const std::string& versionSuffix,
const std::string& mainVersion,
std::vector<std::string>& v); std::vector<std::string>& v);
// Show the package or application name and the versions of the packages // Show the package or application name and the versions of the packages
...@@ -49,8 +52,26 @@ namespace LOFAR { ...@@ -49,8 +52,26 @@ namespace LOFAR {
std::ostream& os) std::ostream& os)
{ {
std::vector<std::string> v; std::vector<std::string> v;
T::fillVersion(v); bool sameVers = T::fillVersion (T::getVersion(), v);
os << name << ": versions " << v << endl; os << name << ": main version = " << T::getVersion();
if (!sameVers) os << '*';
os << endl;
os << " packages: " << v << endl;
}
// Get the main version and the individual package versions being used.
// It returns false if a package version differs from the main version.
// Use like:
// @code
// std::string mainVersion;
// std::vector<std::string> packageVersions;
// Version::get<BlobVersion> (mainVersion, packageVersions);
// @endcode
template<typename T> static bool get (std::string& mainVersion,
std::vector<std::string>& pkgVers)
{
mainVersion = T::getVersion();
return T::fillVersion (mainVersion, pkgVers);
} }
}; };
......
...@@ -24,11 +24,14 @@ ...@@ -24,11 +24,14 @@
namespace LOFAR { namespace LOFAR {
void Version::fillVersion (const std::string& package, bool Version::fillVersion (const std::string& package,
const std::string& version, const std::string& version,
const std::string& versionSuffix,
const std::string& mainVersion,
std::vector<std::string>& v) std::vector<std::string>& v)
{ {
std::string pv = package + '/' + version; bool sameVers = (version == mainVersion);
std::string pv = package + '/' + version + versionSuffix;
// Only insert if not existing yet. // Only insert if not existing yet.
// Later you might remove the existing one, so the dependencies are // Later you might remove the existing one, so the dependencies are
// shown in a somewhat better way. // shown in a somewhat better way.
...@@ -36,10 +39,11 @@ namespace LOFAR { ...@@ -36,10 +39,11 @@ namespace LOFAR {
iter!=v.end(); iter!=v.end();
++iter) { ++iter) {
if (*iter == pv) { if (*iter == pv) {
return; return sameVers;
} }
} }
v.push_back (pv); v.push_back (pv);
return sameVers;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment