Quark  0.1
Version.h++
Go to the documentation of this file.
1 #ifndef __libquark_util_Version_hxx
2 #define __libquark_util_Version_hxx
3 
4 #include <iostream>
5 #include <QString>
6 
7 namespace quark {
8 namespace util {
9 
35 class Version
36 {
37  public:
38 
45  Version(const QString &version);
46 
55  Version(uint current = 0, uint revision = 0, uint age = 0);
56 
58  Version(const Version &other);
59 
61  ~Version();
62 
72  bool satisfies(const Version &requested) const;
73 
82  bool satisfiedBy(const Version &available) const;
83 
85  inline uint current() const
86  { return(_current); }
87 
89  inline uint revision() const
90  { return(_revision); }
91 
93  inline uint age() const
94  { return(_age); }
95 
97  void interfacesAdded();
98 
100  void interfacesRemoved();
101 
105  void interfacesChanged();
106 
108  void implementationChanged();
109 
113  QString toString() const;
114 
116  QString toCRAString() const;
117 
119  bool fromString(const QString &version);
120 
122  bool operator==(const Version &other) const;
123 
125  inline bool operator!=(const Version &other) const
126  { return(! operator==(other)); }
127 
129  bool operator<(const Version &other) const;
130 
132  inline bool operator<=(const Version &other) const
133  { return(operator<(other) || operator==(other)); }
134 
136  bool operator>(const Version &other) const;
137 
139  inline bool operator>=(const Version &other) const
140  { return(operator>(other) || operator==(other)); }
141 
143  Version& operator=(const Version &other);
144 
145  private:
146 
147  uint _current;
148  uint _revision;
149  uint _age;
150  mutable QString _str;
151  mutable QString _vstr;
152 };
153 
154 inline std::ostream& operator<<(std::ostream& stream, const Version& v)
155 { return(stream << qPrintable(v.toString())); }
156 
157 } // namespace util
158 } // namespace quark
159 
160 #endif // __libquark_util_Version_hxx
void interfacesChanged()
Adjusts the version to reflect non-backward-compatible changes to the interfaces. ...
void interfacesAdded()
Adjusts the version to reflect the addition of new interfaces.
std::ostream & operator<<(std::ostream &stream, const Version &v)
Definition: Version.h++:154
bool operator!=(const Version &other) const
Inequality operator.
Definition: Version.h++:125
bool operator<(const Version &other) const
Determines if this Version is older than another version.
~Version()
Destructor.
uint revision() const
Returns the revision component of the version.
Definition: Version.h++:89
Definition: BarChartView.h++:6
QString toString() const
Returns a string representation of the version, in C-A.A.R form.
QString toCRAString() const
Returns a string representation of the version, in C:R:A form.
bool fromString(const QString &version)
Parses the verison from a string.
uint current() const
Returns the current component of the version.
Definition: Version.h++:85
bool satisfiedBy(const Version &available) const
Determines if a requested interface with this version is satisfied by a specific available version (i...
bool satisfies(const Version &requested) const
Determines if an interface with this version satisfies a request for an interface with a specific req...
bool operator==(const Version &other) const
Equality operator.
bool operator<=(const Version &other) const
Determines if this Version is older than or equal to another version.
Definition: Version.h++:132
Version(const QString &version)
Constructs a new Version from the specified string representation.
bool operator>=(const Version &other) const
Determines if this Version is newer than or equal to another version.
Definition: Version.h++:139
void interfacesRemoved()
Adjusts the version to reflect the removal of existing interfaces.
bool operator>(const Version &other) const
Determines if this Version is newer than another version.
uint age() const
Returns the age component of the version.
Definition: Version.h++:93
void implementationChanged()
Adjusts the version to reflect internal implementation changes.
A class representing an interface version number.
Definition: Version.h++:35
Version & operator=(const Version &other)
Assignment operator.