COPASI API  4.16.103
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
CVersion Class Reference

#include <CVersion.h>

Collaboration diagram for CVersion:
Collaboration graph
[legend]

Public Member Functions

 CVersion ()
 
const std::string & getVersion () const
 
C_INT32 getVersionDevel () const
 
C_INT32 getVersionMajor () const
 
C_INT32 getVersionMinor () const
 
bool isCompatible (const CVersion &version) const
 
const bool & isSourceModified () const
 
void setVersion (const C_INT32 &major, const C_INT32 &minor, const C_INT32 &devel, const bool &sourcesModified, const std::string &comment="", const std::string &creator="")
 
 ~CVersion ()
 

Static Public Attributes

static const CVersion VERSION
 

Private Member Functions

 CVersion (C_INT32 major, C_INT32 minor, C_INT32 build, const bool &sourcesModified, const std::string &comment, const std::string &creator)
 
void setString ()
 

Private Attributes

C_INT32 mBuild
 
std::string mComment
 
std::set< C_INT32mCompatible
 
std::string mCreator
 
C_INT32 mMajor
 
C_INT32 mMinor
 
bool mSourcesModified
 
std::string mVersion
 

Detailed Description

CVersion

(C) Pedro Mendes 2001

Definition at line 28 of file CVersion.h.

Constructor & Destructor Documentation

CVersion::CVersion ( C_INT32  major,
C_INT32  minor,
C_INT32  build,
const bool &  sourcesModified,
const std::string &  comment,
const std::string &  creator 
)
private

Constructor with four arguments.

Definition at line 37 of file CVersion.cpp.

References C_INT32, COPASI_VERSION_COMPATIBILITY, mBuild, mCompatible, and setString().

42  :
43  mMajor(major),
44  mMinor(minor),
45  mBuild(build),
46  mSourcesModified(sourcesModified),
47  mComment(comment),
48  mCreator(creator),
49  mVersion(""),
50  mCompatible()
51 {
53  int length = sizeof(Compatible) / sizeof(Compatible[0]);
54  C_INT32 * pCompatible = Compatible;
55 
56  for (int count = 0; count < length && *pCompatible != mBuild; pCompatible++, count++)
57  {
58  mCompatible.insert(*pCompatible);
59  }
60 
61  mCompatible.insert(mBuild);
62 
63  setString();
64 }
void setString()
Definition: CVersion.cpp:144
std::string mVersion
Definition: CVersion.h:69
C_INT32 mMinor
Definition: CVersion.h:42
std::string mCreator
Definition: CVersion.h:64
C_INT32 mBuild
Definition: CVersion.h:47
C_INT32 mMajor
Definition: CVersion.h:36
#define C_INT32
Definition: copasi.h:90
std::set< C_INT32 > mCompatible
Definition: CVersion.h:74
#define COPASI_VERSION_COMPATIBILITY
Definition: CopasiVersion.h:13
std::string mComment
Definition: CVersion.h:58
bool mSourcesModified
Definition: CVersion.h:53
CVersion::CVersion ( )

Default constructor. This creates a version object without any version info.

Definition at line 66 of file CVersion.cpp.

References setString().

66  :
67  mMajor(0),
68  mMinor(0),
69  mBuild(0),
70  mSourcesModified(false),
71  mComment(""),
72  mCreator(""),
73  mVersion(""),
74  mCompatible()
75 {
76  setString();
77 }
void setString()
Definition: CVersion.cpp:144
std::string mVersion
Definition: CVersion.h:69
C_INT32 mMinor
Definition: CVersion.h:42
std::string mCreator
Definition: CVersion.h:64
C_INT32 mBuild
Definition: CVersion.h:47
C_INT32 mMajor
Definition: CVersion.h:36
std::set< C_INT32 > mCompatible
Definition: CVersion.h:74
std::string mComment
Definition: CVersion.h:58
bool mSourcesModified
Definition: CVersion.h:53
CVersion::~CVersion ( )

Destructor.

Definition at line 79 of file CVersion.cpp.

80 {}

Member Function Documentation

const std::string & CVersion::getVersion ( ) const

Returns a string with the full version number.

Returns
mVersion
See Also
mVersion

Definition at line 139 of file CVersion.cpp.

References mVersion.

Referenced by CCopasiXML::load(), CCopasiXML::save(), CConfigurationFile::CXML::save(), and writeLogo().

140 {
141  return mVersion;
142 }
std::string mVersion
Definition: CVersion.h:69
C_INT32 CVersion::getVersionDevel ( ) const

Returns the development version number.

Returns
mBuild
See Also
mBuild

Definition at line 129 of file CVersion.cpp.

References mBuild.

Referenced by CCopasiXML::load(), and CCopasiXMLParser::EventElement::start().

130 {
131  return mBuild;
132 }
C_INT32 mBuild
Definition: CVersion.h:47
C_INT32 CVersion::getVersionMajor ( ) const

Returns the major version number.

Returns
mMajor
See Also
mMajor

Definition at line 119 of file CVersion.cpp.

References mMajor.

120 {
121  return mMajor;
122 }
C_INT32 mMajor
Definition: CVersion.h:36
C_INT32 CVersion::getVersionMinor ( ) const

Returns the minor version number.

Returns
mMinor
See Also
mMinor

Definition at line 124 of file CVersion.cpp.

References mMinor.

125 {
126  return mMinor;
127 }
C_INT32 mMinor
Definition: CVersion.h:42
bool CVersion::isCompatible ( const CVersion version) const

Compare Versions

Parameters
constCVersion & version
Returns
bool isCompatible

Definition at line 82 of file CVersion.cpp.

References mBuild, mCompatible, mMajor, and mMinor.

83 {
84  if (mCompatible.empty())
85  {
86  if (mMajor > version.mMajor) return false;
87 
88  if (mMinor > version.mMinor) return false;
89 
90  if (mBuild >= version.mBuild) return false;
91 
92  return true;
93  }
94 
95  if (version.mBuild < *mCompatible.begin()) return true;
96 
97  if (mCompatible.find(version.mBuild) != mCompatible.end()) return true;
98 
99  return false;
100 }
C_INT32 mMinor
Definition: CVersion.h:42
C_INT32 mBuild
Definition: CVersion.h:47
C_INT32 mMajor
Definition: CVersion.h:36
std::set< C_INT32 > mCompatible
Definition: CVersion.h:74
const bool & CVersion::isSourceModified ( ) const

Retrieve the whether the source code is modified compared to the official build

Returns
const bool & isSourceModified

Definition at line 134 of file CVersion.cpp.

References mSourcesModified.

135 {
136  return mSourcesModified;
137 }
bool mSourcesModified
Definition: CVersion.h:53
void CVersion::setString ( )
private

Creates the version string.

Definition at line 144 of file CVersion.cpp.

References mBuild, mComment, mMajor, mMinor, mSourcesModified, mVersion, and StringPrint().

Referenced by CVersion(), and setVersion().

145 {
146 #ifdef COPASI_DEBUG
147  mComment = "Debug";
148 #endif
149 
150  std::stringstream Build;
151  Build << mBuild;
152 
153  if (mSourcesModified)
154  {
155  Build << "+";
156  }
157 
158  if (mComment == "stable")
159  mVersion = StringPrint("%d.%d (Build %s)", mMajor, mMinor, Build.str().c_str());
160  else if (mComment != "")
161  mVersion = StringPrint("%d.%d.%s (%s)", mMajor, mMinor, Build.str().c_str(), mComment.c_str());
162  else
163  mVersion = StringPrint("%d.%d.%s (Source)", mMajor, mMinor, Build.str().c_str());
164 }
std::string mVersion
Definition: CVersion.h:69
C_INT32 mMinor
Definition: CVersion.h:42
C_INT32 mBuild
Definition: CVersion.h:47
C_INT32 mMajor
Definition: CVersion.h:36
std::string StringPrint(const char *format,...)
Definition: utility.cpp:87
std::string mComment
Definition: CVersion.h:58
bool mSourcesModified
Definition: CVersion.h:53
void CVersion::setVersion ( const C_INT32 major,
const C_INT32 minor,
const C_INT32 devel,
const bool &  sourcesModified,
const std::string &  comment = "",
const std::string &  creator = "" 
)

Sets a version number

Parameters
constC_INT32 & major
constC_INT32 & minor
constC_INT32 & build
constbool & sourcesModified
conststd::string & comment
conststd::string & creator

Definition at line 102 of file CVersion.cpp.

References mBuild, mComment, mCreator, mMajor, mMinor, mSourcesModified, and setString().

Referenced by CCopasiXMLParser::COPASIElement::start().

108 {
109  mMajor = major;
110  mMinor = minor;
111  mBuild = devel;
112  mSourcesModified = sourcesModified;
113  mComment = comment;
114  mCreator = creator;
115 
116  setString();
117 }
void setString()
Definition: CVersion.cpp:144
C_INT32 mMinor
Definition: CVersion.h:42
std::string mCreator
Definition: CVersion.h:64
C_INT32 mBuild
Definition: CVersion.h:47
C_INT32 mMajor
Definition: CVersion.h:36
std::string mComment
Definition: CVersion.h:58
bool mSourcesModified
Definition: CVersion.h:53

Member Data Documentation

C_INT32 CVersion::mBuild
private

The monotonously increasing build number

Definition at line 47 of file CVersion.h.

Referenced by CVersion(), getVersionDevel(), isCompatible(), setString(), and setVersion().

std::string CVersion::mComment
private

Comment appended to the version string

Definition at line 58 of file CVersion.h.

Referenced by setString(), and setVersion().

std::set< C_INT32 > CVersion::mCompatible
private

The list of compatible builds

Definition at line 74 of file CVersion.h.

Referenced by CVersion(), and isCompatible().

std::string CVersion::mCreator
private

Creator who compiled this version for official unmodified sources it is copasi.org

Definition at line 64 of file CVersion.h.

Referenced by setVersion().

C_INT32 CVersion::mMajor
private

Major version number. (4 for first COPASI release)

Definition at line 36 of file CVersion.h.

Referenced by getVersionMajor(), isCompatible(), setString(), and setVersion().

C_INT32 CVersion::mMinor
private

Minor version number. (changes with releases that are mostly bug fixes)

Definition at line 42 of file CVersion.h.

Referenced by getVersionMinor(), isCompatible(), setString(), and setVersion().

bool CVersion::mSourcesModified
private

Boolean value indicating whether mBuild is describing the current state of the sources.

Definition at line 53 of file CVersion.h.

Referenced by isSourceModified(), setString(), and setVersion().

std::string CVersion::mVersion
private

Version string.

Definition at line 69 of file CVersion.h.

Referenced by getVersion(), and setString().

const CVersion CVersion::VERSION
static

The documentation for this class was generated from the following files: