-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
//============================================================================= | ||
// Copyright (C) 2019 The pmp-library developers | ||
// Copyright (c) 2010 Martin Reddy. All rights reserved. | ||
// | ||
// This file is part of the Polygon Mesh Processing Library. | ||
// Distributed under the terms of the MIT license, see LICENSE.txt for details. | ||
// | ||
// SPDX-License-Identifier: MIT | ||
//============================================================================= | ||
|
||
#include <pmp/Version.h> | ||
|
||
#include <sstream> | ||
#include <string> | ||
#include <set> | ||
|
||
//============================================================================= | ||
|
||
namespace pmp { | ||
|
||
//============================================================================= | ||
|
||
int Version::get_major() | ||
{ | ||
return int(PMP_MAJOR_VERSION); | ||
} | ||
|
||
int Version::get_minor() | ||
{ | ||
return int(PMP_MINOR_VERSION); | ||
} | ||
|
||
int Version::get_patch() | ||
{ | ||
return int(PMP_PATCH_VERSION); | ||
} | ||
|
||
std::string Version::get_version() | ||
{ | ||
static std::string version(""); | ||
|
||
if (version.empty()) | ||
{ | ||
// cache the version string | ||
std::ostringstream stream; | ||
stream << PMP_MAJOR_VERSION << "." << PMP_MINOR_VERSION << "." | ||
<< PMP_PATCH_VERSION; | ||
version = stream.str(); | ||
} | ||
|
||
return version; | ||
} | ||
|
||
bool Version::is_at_least(int major, int minor, int patch) | ||
{ | ||
if (PMP_MAJOR_VERSION < major) | ||
return false; | ||
if (PMP_MAJOR_VERSION > major) | ||
return true; | ||
if (PMP_MINOR_VERSION < minor) | ||
return false; | ||
if (PMP_MINOR_VERSION > minor) | ||
return true; | ||
if (PMP_PATCH_VERSION < patch) | ||
return false; | ||
return true; | ||
} | ||
|
||
bool Version::has_feature(const std::string& name) | ||
{ | ||
static std::set<std::string> features; | ||
|
||
if (features.empty()) | ||
{ | ||
// cache the feature list | ||
// features.insert("XXX"); | ||
} | ||
|
||
return features.find(name) != features.end(); | ||
} | ||
|
||
//============================================================================= | ||
} // namespace pmp | ||
//============================================================================= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
//============================================================================= | ||
// Copyright (C) 2019 The pmp-library developers | ||
// Copyright (c) 2010 Martin Reddy. All rights reserved. | ||
// | ||
// This file is part of the Polygon Mesh Processing Library. | ||
// Distributed under the terms of the MIT license, see LICENSE.txt for details. | ||
// | ||
// SPDX-License-Identifier: MIT | ||
//============================================================================= | ||
#pragma once | ||
//============================================================================= | ||
|
||
#include <string> | ||
|
||
#define PMP_MAJOR_VERSION 0 | ||
#define PMP_MINOR_VERSION 1 | ||
#define PMP_PATCH_VERSION 0 | ||
|
||
//============================================================================= | ||
|
||
namespace pmp { | ||
|
||
//============================================================================= | ||
|
||
//! \addtogroup core core | ||
//!@{ | ||
|
||
//! API version information | ||
class Version | ||
{ | ||
public: | ||
//! return the major version number | ||
static int get_major(); | ||
|
||
//! return the minor version number | ||
static int get_minor(); | ||
|
||
//! return the patch version number | ||
static int get_patch(); | ||
|
||
//! return the current API version number as a string | ||
static std::string get_version(); | ||
|
||
//! return true if the current version >= (major, minor, patch) | ||
static bool is_at_least(int major, int minor, int patch); | ||
|
||
//! return true if the named feature is available in this version | ||
static bool has_feature(const std::string &name); | ||
}; | ||
|
||
//============================================================================= | ||
//!@} | ||
//============================================================================= | ||
} // namespace pmp | ||
//============================================================================= |