-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel_value.cpp
81 lines (64 loc) · 1.63 KB
/
model_value.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
/*
* model_value.cpp
*
* Created on: 1 jan. 2018
* Author: MisterCavespider
*/
#include "model_value.h"
BoundedValue::BoundedValue()
{
this->min = -1.0;
this->step = 0.1;
this->max = 1.0;
this->val = 0.0;
}
BoundedValue::BoundedValue(float min, float step, float max)
{
this->min = min;
this->step = step;
this->max = max;
this->val = 0.0;
}
BoundedValue::BoundedValue(float min, float step, float max, float val)
{
this->min = min;
this->step = step;
this->max = max;
this->val = val;
}
float BoundedValue::minimum() {return this->min;}
float BoundedValue::stepSize() {return this->step;}
float BoundedValue::maximum() {return this->max;}
float BoundedValue::value() {return this->val;}
BoundedValue BoundedValue::operator=(float f)
{
this->val = f;
if(this->val > max) this->val = max;
if(this->val < min) this->val = min;
return *this;
}
BoundedValue BoundedValue::operator+=(float val)
{
this->val += val;
if(this->val > max) this->val = max;
if(this->val < min) this->val = min;
return *this;
}
BoundedValue BoundedValue::operator+=(int32_t steps)
{
if(steps == 0) return *this;
val += step * steps;
if(this->val > max) this->val = max;
if(this->val < min) this->val = min;
return *this;
}
bool BoundedValue::operator==(float f) {return f == val;}
bool BoundedValue::operator!=(float f) {return f != val;}
bool BoundedValue::operator>(float f) {return f > val;}
bool BoundedValue::operator>=(float f) {return f >= val;}
bool BoundedValue::operator<(float f) {return f < val;}
bool BoundedValue::operator<=(float f) {return f <= val;}
BoundedValue::~BoundedValue()
{
// TODO Auto-generated destructor stub
}