From ad6318cc5f7adbb3369fb4bc4f7e1523fa76e6a5 Mon Sep 17 00:00:00 2001 From: Peter Parker <peter.parker@stfc.ac.uk> Date: Mon, 7 Oct 2013 15:37:40 +0100 Subject: [PATCH] Refs #7830 - Add DOIs to welcome message. Hopefully it's the right patch number from CMake - need to double check this. Nick needs to confirm the exact wording of the message, as well as the "desciption" field in the DOI metadata. --- .../Kernel/inc/MantidKernel/MantidVersion.h | 4 +++ .../Framework/Kernel/src/ConfigService.cpp | 4 ++- .../Framework/Kernel/src/MantidVersion.cpp.in | 29 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Code/Mantid/Framework/Kernel/inc/MantidKernel/MantidVersion.h b/Code/Mantid/Framework/Kernel/inc/MantidKernel/MantidVersion.h index 533ef742b43..f47c375f2b3 100644 --- a/Code/Mantid/Framework/Kernel/inc/MantidKernel/MantidVersion.h +++ b/Code/Mantid/Framework/Kernel/inc/MantidKernel/MantidVersion.h @@ -6,6 +6,8 @@ //---------------------------------------------------------------------- #include "MantidKernel/DllConfig.h" +#include <string> + namespace Mantid { namespace Kernel @@ -39,6 +41,8 @@ public: static const char* revision(); ///< The abbreviated SHA-1 of the last commit static const char* revisionFull(); ///< The full SHA-1 of the last commit static const char* releaseDate(); ///< The date of the last commit + static const char* mainDOI(); ///< The main landing page DOI for Mantid. + static std::string releaseDOI(); ///< The DOI for this release of Mantid. private: MantidVersion(); ///< Private, unimplemented constructor. Not a class that can be instantiated. diff --git a/Code/Mantid/Framework/Kernel/src/ConfigService.cpp b/Code/Mantid/Framework/Kernel/src/ConfigService.cpp index 5dfc1fdc3c1..2d070f2e443 100644 --- a/Code/Mantid/Framework/Kernel/src/ConfigService.cpp +++ b/Code/Mantid/Framework/Kernel/src/ConfigService.cpp @@ -54,7 +54,9 @@ namespace Mantid */ std::string welcomeMessage() { - return "Welcome to Mantid version " + std::string(Mantid::Kernel::MantidVersion::version()) + " - Manipulation and Analysis Toolkit for Instrument Data"; + return "Welcome to Mantid version " + std::string(Mantid::Kernel::MantidVersion::version()) + " - Manipulation and Analysis Toolkit for Instrument Data\n" + + "Main DOI: " + Mantid::Kernel::MantidVersion::mainDOI() + "\n" + + "Current Version DOI: " + Mantid::Kernel::MantidVersion::releaseDOI(); } namespace Kernel diff --git a/Code/Mantid/Framework/Kernel/src/MantidVersion.cpp.in b/Code/Mantid/Framework/Kernel/src/MantidVersion.cpp.in index 932e96de192..cd57e8d7b60 100644 --- a/Code/Mantid/Framework/Kernel/src/MantidVersion.cpp.in +++ b/Code/Mantid/Framework/Kernel/src/MantidVersion.cpp.in @@ -3,6 +3,9 @@ //---------------------------------------------------------------------- #include "MantidKernel/MantidVersion.h" +#include <sstream> +#include <boost/lexical_cast.hpp> + namespace Mantid { namespace Kernel @@ -30,5 +33,31 @@ const char* MantidVersion::releaseDate() return "@MtdVersion_WC_LAST_CHANGED_DATE@"; } +const char* MantidVersion::mainDOI() +{ + return "http://dx.doi.org/10.5286/Software/Mantid"; +} + +std::string MantidVersion::releaseDOI() +{ + int patchVersion; + try + { + patchVersion = boost::lexical_cast<int>(@MtdVersion_WC_LAST_CHANGED_REV@); + } + catch(boost::bad_lexical_cast &) + { + patchVersion = 0; + } + + std::stringstream doi; + doi << mainDOI() << "@VERSION_MAJOR@.@VERSION_MINOR@"; + + if( patchVersion != 0 ) + doi << "." << patchVersion; + + return doi.str(); +} + } // namespace Kernel } // namespace Mantid -- GitLab