4 #ifndef _LUMIVERSEENUM_
5 #define _LUMIVERSEENUM_
9 #include "../LumiverseType.h"
120 LumiverseEnum(map<string, int> keys,
string mode,
string interpMode,
int rangeMax = 255,
string def =
"");
157 virtual void reset();
160 virtual JSONNode
toJSON(
string name);
176 void addVal(
string name,
int start);
206 bool setVal(
string name,
float tweak);
339 void operator=(
string name);
384 void init(map<string, int> keys,
string active,
Mode mode,
string def,
401 void init(map<string, int> keys,
string active,
Mode mode,
string def,
503 inline bool operator!=(LumiverseEnum& a, LumiverseEnum& b) {
float asPercent()
Gets the value of the enum in terms of a percentage.
Definition: LumiverseEnum.cpp:308
Definition: LumiverseEnum.h:79
Defines an enumeration in Lumiverse.
Definition: LumiverseEnum.h:43
void setInterpMode(InterpolationMode mode)
Sets the interpolation mode.
Definition: LumiverseEnum.h:283
InterpolationMode stringToInterpMode(string input)
Converts a string to an interpolation mode.
Definition: LumiverseEnum.cpp:372
int m_rangeMax
Maximum value for the enumeration range.
Definition: LumiverseEnum.h:481
Definition: LumiverseEnum.h:72
Definition: LumiverseEnum.h:58
float m_tweak
Tweak determines where in the range we are.
Definition: LumiverseEnum.h:473
void setTweak(float tweak)
Tweaks the value of the enum.
Definition: LumiverseEnum.cpp:204
This class is a wapper around a variety of different possible data types that might be needed by a De...
Definition: LumiverseType.h:33
map< int, string > m_startToName
Maps the start of a range to the name of the enumeration option.
Definition: LumiverseEnum.h:458
map< string, int > m_nameToStart
Map of the name of the enumeration option to the start of the range.
Definition: LumiverseEnum.h:455
void setDefault(string name)
Sets the default value of the enumeration.
Definition: LumiverseEnum.h:242
Mode getMode()
Returns the mode.
Definition: LumiverseEnum.h:277
void setRangeMax(int newMax)
Sets the maximum numeric value this LumiverseEnum can take.
Definition: LumiverseEnum.h:301
int getLowestStartValue()
Gets the lowest start value for an enumeration option.
Definition: LumiverseEnum.cpp:300
float getTweak()
Gets the tweak value for the enumeration.
Definition: LumiverseEnum.h:259
Definition: LumiverseEnum.h:59
string modeAsString()
Returns the current mode as a string.
Definition: LumiverseEnum.cpp:331
Definition: LumiverseEnum.h:78
float getRangeVal()
Returns the exact value in the range given the active parameter and the tweak value.
Definition: LumiverseEnum.cpp:210
InterpolationMode
Sets the interpolation mode when transitioning between two LumiverseEnums.
Definition: LumiverseEnum.h:71
virtual bool isDefault()
Returns true if the current value of the enumeration is equal to the default.
Definition: LumiverseEnum.cpp:276
virtual void reset()
Resets the enum to default.
Definition: LumiverseEnum.cpp:88
string getVal()
Gets the current state of the enumeration.
Definition: LumiverseEnum.h:248
vector< string > getVals()
Gets a list of all the possible values the enumeration can take.
Definition: LumiverseEnum.cpp:284
void setValAsPercent(float val)
Sets the value of the LumiverseFloat proportionally.
Definition: LumiverseEnum.h:328
virtual string getTypeName()
Says that this object is an enum.
Definition: LumiverseEnum.h:152
Definition: LumiverseEnum.h:57
InterpolationMode getInterpMode()
Returns the interpolation mode.
Definition: LumiverseEnum.h:289
~LumiverseEnum()
Destructor fun times.
Definition: LumiverseEnum.cpp:84
shared_ptr< LumiverseType > lerp(LumiverseEnum *rhs, float t)
Does a linear interpolation based on the interpolation mode.
Definition: LumiverseEnum.cpp:226
const map< int, string > & getStartToVals()
Returns a reference to the map of range starts to values.
Definition: LumiverseEnum.h:362
void removeVal(string name)
Removes an option from the enumeration.
Definition: LumiverseEnum.cpp:131
string interpModeAsString()
Returns the interpolation mode as a string.
Definition: LumiverseEnum.cpp:357
bool setVal(string name)
Sets the value of the enumeration.
Definition: LumiverseEnum.cpp:139
Mode
When you select an enumeration, mode determines where in the range the calculated value will fall...
Definition: LumiverseEnum.h:56
int getValIndex()
Gets the first value in the active range.
Definition: LumiverseEnum.h:253
int getRangeMax()
Returns the maximum numeric value this LumiverseEnum can take.
Definition: LumiverseEnum.h:294
string getDefault()
Gets the default value.
Definition: LumiverseEnum.h:265
string m_active
The active enumeration option.
Definition: LumiverseEnum.h:445
void setMode(Mode mode)
Sets the mode.
Definition: LumiverseEnum.h:271
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: LumiverseEnum.cpp:92
void setTweakWithMode()
Sets the tweak value based on the mode.
Definition: LumiverseEnum.cpp:313
mutex m_enumMapMutex
Protects the access of the m_nameToStart and m_startToName maps during assignment and read (can't mod...
Definition: LumiverseEnum.h:485
void init(map< string, int > keys, string active, Mode mode, string def, float tweak, int rangeMax, InterpolationMode interpMode)
Initializes the enumeration. Called from constructors.
Definition: LumiverseEnum.cpp:55
string m_default
The default option for the enumeration.
Definition: LumiverseEnum.h:448
void addVal(string name, int start)
Adds an option to the enumeration.
Definition: LumiverseEnum.cpp:121
Mode stringToMode(string input)
Converts a string to a mode.
Definition: LumiverseEnum.cpp:346
LumiverseEnum(Mode mode=CENTER, int rangeMax=255, InterpolationMode interpMode=SMOOTH_WITHIN_OPTION)
Constructs an enumeration with nothing in it.
Definition: LumiverseEnum.cpp:4
int getHighestStartValue()
Gets the highest start value for an enumeration option.
Definition: LumiverseEnum.cpp:292
Mode m_mode
Enumeration mode.
Definition: LumiverseEnum.h:461
const map< string, int > & getValsToStart()
Returns a reference to the map of values to the start of their range.
Definition: LumiverseEnum.h:357
InterpolationMode m_interpMode
Interpolation mode.
Definition: LumiverseEnum.h:464
virtual string asString()
Returns the current enumeration value as a string.
Definition: LumiverseEnum.cpp:115