File: version.h

package info (click to toggle)
korelib 0.0.1-8
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,788 kB
  • ctags: 1,918
  • sloc: sh: 8,555; cpp: 3,989; makefile: 633; ansic: 65
file content (163 lines) | stat: -rw-r--r-- 5,832 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163

#ifndef VERSION_H
#define VERSION_H

#include <kore/kore.h>

namespace kore
{

/**
 * class kore::Version - common version information (major/minor/revision/string)
 * helper class
 */
class KORE_API Version
{
public:
    /**
     * Create a Version instance: <major>.<minor>.<revision>
     * @param major - Major version number (default = 0)
     * @param minor - Minor version number (default = 0)
     * @param revision - Revision number (default = 0)
     * @param version - Version string (usually "<major>.<minor>.<revision>")
     */
    Version(const int major ,const int minor = 0,const int revision = 0,const char* version = 0);
//    /**
//     * Copy constructor
//     * @param other - version to be copied
//     */
//    Version(Version& other);
    virtual ~Version();
    /**
     * Get the major version number.
     * @return - the major version number
     */
    virtual const int major() const;
    /**
     * Get the minor version number.
     * @return - the minor version number
     */
    virtual const int minor() const;
    /**
     * Get the revision number.
     * @return - the revision number
     */
    virtual const int revision() const;
    /**
     * Get the version string (usually "<major>.<minor>.<revision>").
     * @return - the version number string
     */
    virtual const char* string() const;
    /**
     * Get the version string (usually "<major>.<minor>.<revision>").
     * @return - the version number string
     */
    virtual operator const char*() const;
    /**
     * Compares to version to see if they match
     * Two versions match if they have the same major, minor and revision
     * Note: the version string is ignored when performing version comparison
     * @param other - the other version to compare against
     * @return true - if the two versions match (i.e. are the same), false otherwise
     */
    virtual const bool operator ==(const Version& other) const;
    /**
     * Compares to version to see if they don't match
     * v1 != v2 if and only if !(v1 == v2)
     * Note: the version string is ignored when performing version comparison
     * @param other - the other version to compare against
     * @return true - if the two versions match (i.e. are the same), false otherwise
     */
    virtual const bool operator !=(const Version& other) const;
    /**
     * Checks of the current version is older (smaller) than the specified one
     * The comparison is performed on major, minor and revision, in this order
     * Note: the version string is ignored when performing version comparison
     * @param other - the other version to compare against
     * @return true - if the corrent version is older (smaller), false otherwise
     */
    virtual const bool operator <(const Version& other) const;
    /**
     * The combined result of == and <
     * v1 <= v2 if and only if (v1 == v2) || (v1 < v2)
     * Note: the version string is ignored when performing version comparison
     * @param other - the other version to compare against
     * @return true - if the corrent version is older (smaller), false otherwise
     */
    virtual const bool operator <=(const Version& other) const;
    /**
     * Checks of the current version is newer (bigger) than the specified one
     * The comparison is performed on major, minor and revision, in this order
     * Note: the version string is ignored when performing version comparison
     * @param other - the other version to compare against
     * @return true - if the corrent version is newer (bigger), false otherwise
     */
    virtual const bool operator >(const Version& other) const;
    /**
     * The combined result of == and >
     * v1 >= v2 if and only if (v1 == v2) || (v1 > v2)
     * Note: the version string is ignored when performing version comparison
     * @param other - the other version to compare against
     * @return true - if the corrent version is older (smaller), false otherwise
     */
    virtual const bool operator >=(const Version& other) const;
    /**
     * Checks if the current version is binary compatible with the specified one
     * @param other - the other version to compare against
     * @return true - if the two versions are binary compatible, false otherwise
     */
    virtual const bool operator &(const Version& other) const;
    /**
     * Checks if the current version is source compatible with the specified one
     * @param other - the other version to compare against
     * @return true - if the two versions are source compatible, false otherwise
     */
    virtual const bool operator &&(const Version& other) const;

protected:
    /**
     * Default constructor.
     */
    Version();
    /**
     * Set the major version number.
     * @param major - the major version number
     */
    void setMajor(const int major = 0 );
    /**
     * Set the minor version number.
     * @param minor - the minor version number
     */
    void setMinor(const int minor = 0 );
    /**
     * Set the revision number.
     * @param revision - the revision number
     */
    void setRevision(const int revision = 0);
    /**
     * Set the version string.
     * @param version - the version string
     */
    void setString(const char* version = 0 );
    /**
     * Set the version information: major/minor/revision/string
     * @param major - the major version number
     * @param minor - the minor version number
     * @param revision - the revision number
     * @param version - the version string
     */
    void setVersion(const int major = 0,const int minor = 0,const int revision = 0,const char* version = 0);
private:
    // major version number
    int _major;
    // minor version number
    int _minor;
    // revision number
    int _revision;
    // version string
    const char* _version;
};

}

#endif