*** empty log message ***

This commit is contained in:
James Turk 2005-02-05 02:57:07 +00:00
parent ee10100b1e
commit d829770bbd
2 changed files with 117 additions and 3 deletions

View File

@ -5,10 +5,13 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: VersionInfo.h,v 1.1 2005/01/27 03:35:23 cozman Exp $ // $Id: VersionInfo.h,v 1.2 2005/02/05 02:57:07 cozman Exp $
// //
// Revisions: // Revisions:
// $Log: VersionInfo.h,v $ // $Log: VersionInfo.h,v $
// Revision 1.2 2005/02/05 02:57:07 cozman
// *** empty log message ***
//
// Revision 1.1 2005/01/27 03:35:23 cozman // Revision 1.1 2005/01/27 03:35:23 cozman
// initial import (exceptions,types, and logging,oh my!) // initial import (exceptions,types, and logging,oh my!)
// //
@ -17,10 +20,70 @@
#ifndef PHOTON_UTIL_VERSIONINFO_H #ifndef PHOTON_UTIL_VERSIONINFO_H
#define PHOTON_UTIL_VERSIONINFO_H #define PHOTON_UTIL_VERSIONINFO_H
#include <string>
#include <ostream>
namespace photon { namespace photon {
namespace util { namespace util {
// Class: VersionInfo
// Class which stores version information, such as release numbers.
// Format is Major.Minor.Release [ExtraInfo].
//
// Operators:
// VersionInfo < VersionInfo
// VersionInfo <= VersionInfo
// VersionInfo == VersionInfo
// VersionInfo >= VersionInfo
// VersionInfo > VersionInfo
// ostream& << VersionInfo
class VersionInfo
{
public:
// Group: Variables
// Variable: Major
// Major version number, should be changed when major changes take place.
unsigned int major;
// Variable: Minor
// Minor version number, should be changed when key features are
// added/removed/changed.
unsigned int minor;
// Variable: Release
// Release number, should be changed upon every release that isn't
// signifigant enough to reflect a change in the minor versioning number.
unsigned int release;
// Variable: Extra
// String for holding extra data, such as a release name or special tag.
std::string extra;
// Group: (Con/De)structors
// Function: VersionInfo
// Initializing constructor, VersionInfo must be initalized with this
// constructor.
//
// Parameters:
// maj - Major version number.
// min - Minor version number.
// rel - Release number.
// ext - Extra info string. [default: ""]
VersionInfo(unsigned int maj, unsigned int min, unsigned int rel,
std::string ext="");
//operators
bool operator<(const VersionInfo &rhs) const;
bool operator<=(const VersionInfo &rhs) const;
bool operator==(const VersionInfo &rhs) const;
bool operator>=(const VersionInfo &rhs) const;
bool operator>(const VersionInfo &rhs) const;
//output operator
friend std::ostream& operator<<(std::ostream &o, const VersionInfo &rhs);
};
} }
} }

View File

@ -5,10 +5,13 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: VersionInfo.cpp,v 1.1 2005/01/27 03:35:24 cozman Exp $ // $Id: VersionInfo.cpp,v 1.2 2005/02/05 02:57:07 cozman Exp $
// //
// Revisions: // Revisions:
// $Log: VersionInfo.cpp,v $ // $Log: VersionInfo.cpp,v $
// Revision 1.2 2005/02/05 02:57:07 cozman
// *** empty log message ***
//
// Revision 1.1 2005/01/27 03:35:24 cozman // Revision 1.1 2005/01/27 03:35:24 cozman
// initial import (exceptions,types, and logging,oh my!) // initial import (exceptions,types, and logging,oh my!)
// //
@ -16,11 +19,59 @@
#include "util/VersionInfo.h" #include "util/VersionInfo.h"
namespace photon { namespace photon {
namespace util { namespace util {
VersionInfo::VersionInfo(unsigned int maj, unsigned int min, unsigned int rel,
std::string ext) :
major(maj), minor(min), release(rel), extra(ext)
{
}
bool VersionInfo::operator<(const VersionInfo &rhs) const
{
//chained compares, compare numbers in order of importance
if(this->major < rhs.major)
return true;
else if(this->major == rhs.major)
{
if(this->minor < rhs.minor)
return true;
else if(this->minor == rhs.minor)
{
if(this->release < rhs.release)
return true;
}
}
return false; //if it reaches this point rhs is >=
}
bool VersionInfo::operator<=(const VersionInfo &rhs) const
{
return ((*this) < rhs || (*this) == rhs);
}
bool VersionInfo::operator==(const VersionInfo &rhs) const
{
return this->extra == rhs.extra && this->release == rhs.release &&
this->minor == rhs.minor && this->major == rhs.major;
}
bool VersionInfo::operator>=(const VersionInfo &rhs) const
{
return ((*this) < rhs || (*this) == rhs);
}
bool VersionInfo::operator>(const VersionInfo &rhs) const
{
return !((*this) <= rhs);
}
std::ostream& operator<<(std::ostream &o, const VersionInfo &rhs)
{
return o << rhs.major << '.' << rhs.minor << '.' << rhs.release <<
" [" << rhs.extra << "]";
}
} }
} }