Lumiverse  2.5
A framework for creating lighting control applications
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Lumiverse::LumiverseFloat Class Reference

Defines a float in Lumiverse. More...

#include <LumiverseFloat.h>

Inheritance diagram for Lumiverse::LumiverseFloat:
Inheritance graph
[legend]
Collaboration diagram for Lumiverse::LumiverseFloat:
Collaboration graph
[legend]

Public Member Functions

 LumiverseFloat (float val=0.0f, float def=0.0f, float max=1.0f, float min=0.0f)
 Constructs a float, default value is 0. More...
 
 LumiverseFloat (LumiverseFloat *other)
 Constructs a float with the contents of a different float. More...
 
 LumiverseFloat (LumiverseType *other)
 Constructs a float by copying from a generic LumiverseType. More...
 
 ~LumiverseFloat ()
 Destroys the float.
 
virtual string getTypeName ()
 Says that this object is a float. More...
 
void operator= (float val)
 
void operator= (LumiverseFloat val)
 
LumiverseFloatoperator+= (float val)
 
LumiverseFloatoperator+= (LumiverseFloat &val)
 
LumiverseFloatoperator-= (float val)
 
LumiverseFloatoperator-= (LumiverseFloat &val)
 
LumiverseFloatoperator*= (float val)
 
LumiverseFloatoperator*= (LumiverseFloat &val)
 
LumiverseFloatoperator/= (float val)
 
LumiverseFloatoperator/= (LumiverseFloat &val)
 
float getVal ()
 Gets the value of the float. More...
 
void setVal (float val)
 Sets the value of the float. More...
 
void setVals (float val, float def, float min, float max)
 Sets values for all float params.
 
void setMax (float val)
 Set maximum value. More...
 
float getMax ()
 Get the maximum value. More...
 
void setMin (float val)
 Set miniumum value. More...
 
float getMin ()
 Get the minimum value. More...
 
void setDefault (float val)
 Set the default value for the float. More...
 
float getDefault ()
 Gets the default value for the float. More...
 
virtual void reset ()
 Resets the value to the default value.
 
void setValAsPercent (float val)
 Sets the value of the LumiverseFloat proportionally.
 
float asPercent ()
 Returns the value of this float as a percentage. More...
 
virtual JSONNode toJSON (string name)
 Converts the type to a JSON object with the specified name. More...
 
virtual string asString ()
 Returns the value of the LumiverseFloat as a string. More...
 
virtual bool isDefault ()
 Returns true if the value is equal to the default value for the type.
 
- Public Member Functions inherited from Lumiverse::LumiverseType
virtual ~LumiverseType ()
 Destroys the object.
 

Private Member Functions

void clamp ()
 Ensures that the value of this float is between min and max.
 

Private Attributes

float m_val
 the value of this object
 
float m_default
 Default value for this float.
 
float m_max
 Maximum value for the float (default 1.0)
 
float m_min
 

Detailed Description

Defines a float in Lumiverse.

This class allows limits to be set on the minimum and maximum values for the variable in question. Overloads for comparison ops and arithmetic ops are located in Lumiverse namespace.

See also
Lumiverse

Constructor & Destructor Documentation

Lumiverse::LumiverseFloat::LumiverseFloat ( float  val = 0.0f,
float  def = 0.0f,
float  max = 1.0f,
float  min = 0.0f 
)

Constructs a float, default value is 0.

Parameters
valInitial value
defDefault value. When reset() is called, val will be set to def.
maxMaximum allowed value
minMinimum allowed value
See also
reset()
Lumiverse::LumiverseFloat::LumiverseFloat ( LumiverseFloat other)

Constructs a float with the contents of a different float.

Parameters
otherThe other object to copy from
Lumiverse::LumiverseFloat::LumiverseFloat ( LumiverseType other)

Constructs a float by copying from a generic LumiverseType.

If the other object isn't actually a float, this function will initialize with default values.

Parameters
otherThe other object to copy from.

Member Function Documentation

float Lumiverse::LumiverseFloat::asPercent ( )

Returns the value of this float as a percentage.

Returns
Returns the value: m_val / (m_max - m_min)
string Lumiverse::LumiverseFloat::asString ( )
virtual

Returns the value of the LumiverseFloat as a string.

Precision goes up to 4 decimal places.

Implements Lumiverse::LumiverseType.

float Lumiverse::LumiverseFloat::getDefault ( )
inline

Gets the default value for the float.

Returns
Default value
float Lumiverse::LumiverseFloat::getMax ( )
inline

Get the maximum value.

Returns
Maximum value for the float
float Lumiverse::LumiverseFloat::getMin ( )
inline

Get the minimum value.

Returns
Minimum value for the float
virtual string Lumiverse::LumiverseFloat::getTypeName ( )
inlinevirtual

Says that this object is a float.

Returns
String with contents: "float"

Implements Lumiverse::LumiverseType.

float Lumiverse::LumiverseFloat::getVal ( )
inline

Gets the value of the float.

Returns
Value of the object
void Lumiverse::LumiverseFloat::setDefault ( float  val)
inline

Set the default value for the float.

Parameters
valNew default value
void Lumiverse::LumiverseFloat::setMax ( float  val)
inline

Set maximum value.

Parameters
valNew maximum value
void Lumiverse::LumiverseFloat::setMin ( float  val)
inline

Set miniumum value.

Parameters
valNew minimum value
void Lumiverse::LumiverseFloat::setVal ( float  val)
inline

Sets the value of the float.

Parameters
valNew value
JSONNode Lumiverse::LumiverseFloat::toJSON ( string  name)
virtual

Converts the type to a JSON object with the specified name.

Required for proper serialiaztion.

Implements Lumiverse::LumiverseType.

Member Data Documentation

float Lumiverse::LumiverseFloat::m_min
private

Minimum value for the float (default 0.0)


The documentation for this class was generated from the following files: