Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "constexpr version" #4496

Merged
merged 2 commits into from
Jan 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
80 changes: 67 additions & 13 deletions src/shogun/base/Version.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This software is distributed under BSD 3-clause license (see LICENSE file).
*
* Authors: Soeren Sonnenburg, Viktor Gal, Heiko Strathmann, Thoralf Klein,
* Authors: Soeren Sonnenburg, Viktor Gal, Heiko Strathmann, Thoralf Klein,
* Evan Shelhamer, Bjoern Esser, Evangelos Anagnostopoulos
*/

Expand All @@ -16,17 +16,16 @@ using namespace shogun;

namespace shogun
{
// TODO: in C++17 inline all of this in header file and remove it from here
constexpr int64_t Version::version_revision;
constexpr int32_t Version::version_year;
constexpr int32_t Version::version_month;
constexpr int32_t Version::version_day;
constexpr int32_t Version::version_hour;
constexpr int32_t Version::version_minute;
constexpr int32_t Version::version_parameter;
constexpr const char Version::version_extra[128];
constexpr const char Version::version_release[128];
constexpr const char Version::version_main[32];
const int64_t Version::version_revision = VERSION_REVISION;
const int32_t Version::version_year = VERSION_YEAR;
const int32_t Version::version_month = VERSION_MONTH;
const int32_t Version::version_day = VERSION_DAY;
const int32_t Version::version_hour = VERSION_HOUR;
const int32_t Version::version_minute = VERSION_MINUTE;
const int32_t Version::version_parameter=VERSION_PARAMETER;
const char Version::version_main[32] = MAINVERSION;
const char Version::version_extra[128] = VERSION_EXTRA;
const char Version::version_release[128] = VERSION_RELEASE;
}

Version::Version()
Expand All @@ -42,7 +41,7 @@ Version::~Version()

void Version::print_version()
{
SG_SPRINT("libshogun (%s/%s%" PRId64 ")\n\n", MACHINE, Version::get_version_release(), Version::get_version_revision())
SG_SPRINT("libshogun (%s/%s%" PRId64 ")\n\n", MACHINE, VERSION_RELEASE, version_revision)
SG_SPRINT("Copyright (C) 1999-2009 Fraunhofer Institute FIRST\n")
SG_SPRINT("Copyright (C) 1999-2011 Max Planck Society\n")
SG_SPRINT("Copyright (C) 2009-2011 Berlin Institute of Technology\n")
Expand All @@ -54,6 +53,61 @@ void Version::print_version()
#endif
}

const char* Version::get_version_main()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool thanks!

{
return version_main;
}

const char* Version::get_version_extra()
{
return version_extra;
}

const char* Version::get_version_release()
{
return version_release;
}

int64_t Version::get_version_revision()
{
return version_revision;
}

int32_t Version::get_version_year()
{
return version_year;
}

int32_t Version::get_version_month()
{
return version_month;
}

int32_t Version::get_version_day()
{
return version_day;
}

int32_t Version::get_version_hour()
{
return version_hour;
}

int32_t Version::get_version_minute()
{
return version_year;
}

int32_t Version::get_version_parameter()
{
return version_parameter;
}

int64_t Version::get_version_in_minutes()
{
return ((((version_year)*12 + version_month)*30 + version_day)* 24 + version_hour)*60 + version_minute;
}

int32_t Version::ref()
{
return m_refcount->ref();
Expand Down
72 changes: 24 additions & 48 deletions src/shogun/base/Version.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* This software is distributed under BSD 3-clause license (see LICENSE file).
*
* Authors: Soeren Sonnenburg, Heiko Strathmann, Yuyu Zhang, Viktor Gal,
* Thoralf Klein, Evan Shelhamer, Sergey Lisitsyn,
* Authors: Soeren Sonnenburg, Heiko Strathmann, Yuyu Zhang, Viktor Gal,
* Thoralf Klein, Evan Shelhamer, Sergey Lisitsyn,
* Evangelos Anagnostopoulos
*/

Expand All @@ -12,7 +12,6 @@
#define VERSION_H__

#include <shogun/lib/config.h>
#include <shogun/lib/versionstring.h>

namespace shogun
{
Expand All @@ -36,59 +35,37 @@ class Version
static void print_version();

/** get main version */
static constexpr const char* get_version_main() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to keep the equivalent of this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be fixed in the commit below...

return version_main;
}
static const char* get_version_main();

/** get version extra */
static constexpr const char* get_version_extra() {
return version_extra;
}
static const char* get_version_extra();

/** get version release */
static constexpr const char* get_version_release() {
return version_release;
}
static const char* get_version_release();

/** get version revision */
static constexpr int64_t get_version_revision() {
return version_revision;
}
static int64_t get_version_revision();

/** get version year */
static constexpr int32_t get_version_year() {
return version_year;
}
static int32_t get_version_year();

/** get version month */
static constexpr int32_t get_version_month() {
return version_month;
}
static int32_t get_version_month();

/** get version day */
static constexpr int32_t get_version_day() {
return version_day;
}
static int32_t get_version_day();

/** get version hour */
static constexpr int32_t get_version_hour() {
return version_hour;
}
static int32_t get_version_hour();

/** get version minute */
static constexpr int32_t get_version_minute() {
return version_minute;
}
static int32_t get_version_minute();

/** get parameter serialization version */
static constexpr int32_t get_version_parameter() {
return version_parameter;
}
static int32_t get_version_parameter();

/** get version in minutes */
static constexpr int64_t get_version_in_minutes() {
return version_minute;
}
static int64_t get_version_in_minutes();

/** ref object
* @return ref count
Expand All @@ -107,26 +84,25 @@ class Version

protected:
/** version release */
static constexpr char version_release[128] = VERSION_RELEASE;
static const char version_release[128];
/** version main */
static const char version_main[32];
/** version extra */
static constexpr char version_extra[128] = VERSION_EXTRA;

static const char version_extra[128];
/** version revision */
static constexpr int64_t version_revision = VERSION_REVISION;
static const int64_t version_revision;
/** version year */
static constexpr int32_t version_year = VERSION_YEAR;
static const int32_t version_year;
/** version month */
static constexpr int32_t version_month = VERSION_MONTH;
static const int32_t version_month;
/** version day */
static constexpr int32_t version_day = VERSION_DAY;
static const int32_t version_day;
/** version hour */
static constexpr int32_t version_hour = VERSION_HOUR;
static const int32_t version_hour;
/** version minute */
static constexpr int32_t version_minute = VERSION_MINUTE;
static const int32_t version_minute;
/** version parameter */
static constexpr int32_t version_parameter = VERSION_PARAMETER;
/** version main */
static constexpr char version_main[32] = MAINVERSION;
static const int32_t version_parameter;

private:
RefCount* m_refcount;
Expand Down