Changed the version setup code to be consistent with the rest of the OSG

This commit is contained in:
Robert Osfield
2008-07-15 19:24:22 +00:00
parent b343cbfc5f
commit abe16fa571
2 changed files with 29 additions and 80 deletions

View File

@@ -8,15 +8,28 @@
extern "C" {
OSGWIDGET_EXPORT unsigned int osgWidgetGetMajorVersion ();
OSGWIDGET_EXPORT unsigned int osgWidgetGetMinorVersion ();
OSGWIDGET_EXPORT unsigned int osgWidgetGetPatchVersion ();
OSGWIDGET_EXPORT const char* osgWidgetGetExtraText ();
OSGWIDGET_EXPORT const char* osgWidgetGetVersion ();
OSGWIDGET_EXPORT const char* osgWidgetGetLibraryName ();
OSGWIDGET_EXPORT bool osgWidgetVersionMinimum (unsigned int, unsigned int, unsigned int);
OSGWIDGET_EXPORT bool osgWidgetVersionMaximum (unsigned int, unsigned int, unsigned int);
OSGWIDGET_EXPORT bool osgWidgetVersionRequired (unsigned int, unsigned int, unsigned int);
/**
* osgWidgetGetVersion() returns the library version number.
* Numbering convention : OpenSceneGraph-1.0 will return 1.0 from osgWidgetGetVersion.
*
* This C function can be also used to check for the existence of the OpenSceneGraph
* library using autoconf and its m4 macro AC_CHECK_LIB.
*
* Here is the code to add to your configure.in:
\verbatim
#
# Check for the OpenSceneGraph (OSG) Util library
#
AC_CHECK_LIB(osg, osgWidgetGetVersion, ,
[AC_MSG_ERROR(OpenSceneGraph Util library not found. See http://www.openscenegraph.org)],)
\endverbatim
*/
extern OSGWIDGET_EXPORT const char* osgWidgetGetVersion();
/**
* osgWidgetGetLibraryName() returns the library name in human friendly form.
*/
extern OSGWIDGET_EXPORT const char* osgWidgetGetLibraryName();
}

View File

@@ -1,83 +1,19 @@
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
// $Id: Version.cpp 64 2008-06-30 21:32:00Z cubicool $
#include <sstream>
#include <osgWidget/Version>
#include <osg/Version>
extern "C" {
const unsigned int OSGWIDGET_MAJOR_VERSION = 0;
const unsigned int OSGWIDGET_MINOR_VERSION = 1;
const unsigned int OSGWIDGET_PATCH_VERSION = 8;
const char* OSGWIDGET_EXTRA_TEXT = "(pre-merge)";
unsigned int osgWidgetGetMajorVersion() {
return OSGWIDGET_MAJOR_VERSION;
const char* osgWidgetGetVersion()
{
return osgGetVersion();
}
unsigned int osgWidgetGetMinorVersion() {
return OSGWIDGET_MINOR_VERSION;
}
unsigned int osgWidgetGetPatchVersion() {
return OSGWIDGET_PATCH_VERSION;
}
const char* osgWidgetGetExtraText() {
return OSGWIDGET_EXTRA_TEXT;
}
const char* osgWidgetGetVersion() {
static std::string version;
static bool versionInit = true;
if(versionInit) {
std::stringstream stream;
stream.str(std::string());
stream
<< OSGWIDGET_MAJOR_VERSION << "."
<< OSGWIDGET_MINOR_VERSION << "."
<< OSGWIDGET_PATCH_VERSION << " "
<< OSGWIDGET_EXTRA_TEXT
;
version = stream.str();
versionInit = false;
}
return version.c_str();
}
const char* osgWidgetGetLibraryName() {
static std::string name("OpenSceneGraph Widget Library");
return name.c_str();
}
bool osgWidgetVersionMinimum(unsigned int major, unsigned int minor, unsigned int patch) {
return
OSGWIDGET_MAJOR_VERSION >= major &&
OSGWIDGET_MINOR_VERSION >= minor &&
OSGWIDGET_PATCH_VERSION >= patch
;
}
bool osgWidgetVersionMaximum(unsigned int major, unsigned int minor, unsigned int patch) {
return
// OSGWIDGET_MAJOR_VERSION <= major &&
OSGWIDGET_MINOR_VERSION <= minor &&
OSGWIDGET_PATCH_VERSION <= patch
;
}
bool osgWidgetVersionRequired(unsigned int major, unsigned int minor, unsigned int patch) {
return
OSGWIDGET_MAJOR_VERSION == major &&
OSGWIDGET_MINOR_VERSION == minor &&
OSGWIDGET_PATCH_VERSION == patch
;
const char* osgWidgetGetLibraryName()
{
return "OpenSceneGraph Widget Library";
}
}