4 #ifndef _LumiverseFLOAT_H_
5 #define _LumiverseFLOAT_H_
8 #include "../LumiverseType.h"
33 LumiverseFloat(
float val = 0.0f,
float def = 0.0f,
float max = 1.0f,
float min = 0.0f);
61 void operator=(
float val);
91 void setVals(
float val,
float def,
float min,
float max);
132 virtual void reset();
146 virtual JSONNode
toJSON(
string name);
188 inline bool operator==(LumiverseFloat& a,
float b) {
189 if (a.getTypeName() !=
"float")
192 return a.getVal() == b;
195 inline bool operator!=(LumiverseFloat& a, LumiverseFloat& b) {
199 inline bool operator!=(LumiverseFloat& a,
float b) {
204 inline bool operator<(LumiverseFloat& a, LumiverseFloat& b) {
205 if (a.getTypeName() !=
"float" || b.getTypeName() !=
"float")
208 return a.getVal() < b.getVal();
211 inline bool operator<(LumiverseFloat& a,
float b) {
212 if (a.getTypeName() !=
"float")
215 return a.getVal() < b;
218 inline bool operator<(
float a, LumiverseFloat& b) {
219 if (b.getTypeName() !=
"float")
222 return a < b.getVal();
225 inline bool operator>(LumiverseFloat& a, LumiverseFloat& b) {
229 inline bool operator>(LumiverseFloat& a,
float b) {
233 inline bool operator<=(LumiverseFloat& a, LumiverseFloat& b) {
237 inline bool operator<=(LumiverseFloat& a,
float b) {
241 inline bool operator>=(LumiverseFloat& a, LumiverseFloat b) {
245 inline bool operator>=(LumiverseFloat& a,
float b) {
250 inline LumiverseFloat operator+(LumiverseFloat& lhs,
float rhs) {
251 LumiverseFloat val = LumiverseFloat(lhs);
263 inline LumiverseFloat operator+(LumiverseFloat lhs, LumiverseFloat rhs) {
264 LumiverseFloat val = LumiverseFloat(lhs);
269 inline LumiverseFloat operator-(LumiverseFloat& lhs,
float rhs) {
270 LumiverseFloat val = LumiverseFloat(lhs);
275 inline LumiverseFloat operator-(LumiverseFloat& lhs, LumiverseFloat& rhs) {
276 LumiverseFloat val = LumiverseFloat(lhs);
281 inline LumiverseFloat operator*(LumiverseFloat& lhs,
float rhs) {
282 LumiverseFloat val = LumiverseFloat(lhs);
287 inline LumiverseFloat operator*(LumiverseFloat& lhs, LumiverseFloat& rhs) {
288 LumiverseFloat val = LumiverseFloat(lhs);
293 inline LumiverseFloat operator/(LumiverseFloat& lhs,
float rhs) {
294 LumiverseFloat val = LumiverseFloat(lhs);
299 inline LumiverseFloat operator/(LumiverseFloat& lhs, LumiverseFloat& rhs) {
300 LumiverseFloat val = LumiverseFloat(lhs);
void setDefault(float val)
Set the default value for the float.
Definition: LumiverseFloat.h:121
void setVal(float val)
Sets the value of the float.
Definition: LumiverseFloat.h:86
void setValAsPercent(float val)
Sets the value of the LumiverseFloat proportionally.
Definition: LumiverseFloat.cpp:74
float getMax()
Get the maximum value.
Definition: LumiverseFloat.h:103
This class is a wapper around a variety of different possible data types that might be needed by a De...
Definition: LumiverseType.h:33
float m_val
the value of this object
Definition: LumiverseFloat.h:166
float m_max
Maximum value for the float (default 1.0)
Definition: LumiverseFloat.h:172
void setMax(float val)
Set maximum value.
Definition: LumiverseFloat.h:97
void setVals(float val, float def, float min, float max)
Sets values for all float params.
Definition: LumiverseFloat.cpp:110
void setMin(float val)
Set miniumum value.
Definition: LumiverseFloat.h:109
~LumiverseFloat()
Destroys the float.
Definition: LumiverseFloat.cpp:28
virtual void reset()
Resets the value to the default value.
Definition: LumiverseFloat.cpp:68
virtual bool isDefault()
Returns true if the value is equal to the default value for the type.
Definition: LumiverseFloat.cpp:53
float getVal()
Gets the value of the float.
Definition: LumiverseFloat.h:80
float m_default
Default value for this float.
Definition: LumiverseFloat.h:169
float getMin()
Get the minimum value.
Definition: LumiverseFloat.h:115
float getDefault()
Gets the default value for the float.
Definition: LumiverseFloat.h:127
Contains all core Lumiverse functions and variables.
Definition: Device.cpp:2
virtual JSONNode toJSON(string name)
Converts the type to a JSON object with the specified name.
Definition: LumiverseFloat.cpp:30
float m_min
Definition: LumiverseFloat.h:175
float asPercent()
Returns the value of this float as a percentage.
Definition: LumiverseFloat.cpp:80
Defines a float in Lumiverse.
Definition: LumiverseFloat.h:21
virtual string asString()
Returns the value of the LumiverseFloat as a string.
Definition: LumiverseFloat.cpp:43
virtual string getTypeName()
Says that this object is a float.
Definition: LumiverseFloat.h:58
LumiverseFloat(float val=0.0f, float def=0.0f, float max=1.0f, float min=0.0f)
Constructs a float, default value is 0.
Definition: LumiverseFloat.cpp:5
void clamp()
Ensures that the value of this float is between min and max.
Definition: LumiverseFloat.cpp:57