-
Notifications
You must be signed in to change notification settings - Fork 1
/
global_classes.cpp
140 lines (110 loc) · 4.57 KB
/
global_classes.cpp
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
/***************************************************************************
** **
** This file is part of SpineCreator, an easy to use, GUI for **
** describing spiking neural network models. **
** Copyright (C) 2013 Alex Cope, Paul Richmond **
** **
** This program is free software: you can redistribute it and/or modify **
** it under the terms of the GNU General Public License as published by **
** the Free Software Foundation, either version 3 of the License, or **
** (at your option) any later version. **
** **
** This program is distributed in the hope that it will be useful, **
** but WITHOUT ANY WARRANTY; without even the implied warranty of **
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
** GNU General Public License for more details. **
** **
** You should have received a copy of the GNU General Public License **
** along with this program. If not, see http://www.gnu.org/licenses/. **
** **
****************************************************************************
** Author: Alex Cope **
** Website/Contact: http://bimpa.group.shef.ac.uk/ **
****************************************************************************/
#include "globalHeader.h"
// deactivated for now...
versionNumber::versionNumber() {
// defaults
major = 0;
minor = 0;
revision = 0;
QSettings settings;
last_owner = settings.value("versioning/localName", QHostInfo::localHostName()).toString();
}
versionNumber& versionNumber::operator=(const versionNumber& data) {
major = data.major;
minor = data.minor;
revision = data.revision;
last_owner = data.last_owner;
return *this;
}
void versionNumber::fromFileString(QString fileName) {
QStringList strings = fileName.split(".ver");
// get second string
if (strings.size() == 2) {
QStringList bits = strings.at(1).split('_');
if (bits.size() == 4) {
major = bits.at(0).toInt();
minor = bits.at(1).toInt();
revision = bits.at(2).toInt();
last_owner = bits.at(3);
last_owner.chop(4);
// no need to use defaults
return;
}
}
// defaults
major = 0;
minor = 0;
revision = 0;
QSettings settings;
last_owner = settings.value("versioning/localName", QHostInfo::localHostName()).toString();
}
bool operator==(versionNumber& v1, versionNumber& v2) {
/*if (v1.major == v2.major)
if(v1.minor == v2.minor)
if(v1.revision == v2.revision)
if(v1.last_owner == v2.last_owner)
return true;*/
return true;
}
bool operator!=(versionNumber& v1, versionNumber& v2) {
return !(v1==v2);
}
bool operator>=(versionNumber& v1, versionNumber& v2) {
/*if (v1.last_owner != v2.last_owner)
return false;
if (v1.major < v2.major)
return false;
if (v1.major == v2.major && v1.minor < v2.minor)
return false;
if (v1.major == v2.major && v1.minor == v2.minor && v1.revision < v2.revision)
return false;*/
return false;
}
bool operator<=(versionNumber& v1, versionNumber& v2) {
/*if (v1.last_owner != v2.last_owner)
return false;
if (v1.major > v2.major)
return false;
if (v1.major == v2.major && v1.minor > v2.minor)
return false;
if (v1.major == v2.major && v1.minor == v2.minor && v1.revision > v2.revision)
return false;
return true;*/
return false;
}
bool operator>(versionNumber& v1, versionNumber& v2) {
return !(v1 <= v2);
}
bool operator<(versionNumber& v1, versionNumber& v2) {
return !(v1 >= v2);
}
QString versionNumber::toString() {
return "";
return "ver: " + QString::number(float(this->major)) + "." + QString::number(float(this->minor)) + "-" + QString::number(float(this->revision));
}
QString versionNumber::toFileString() {
return "";
return ".ver" + QString::number(float(this->major)) + "_" + QString::number(float(this->minor)) + "_" + QString::number(float(this->revision)) + "_" + this->last_owner;
}