Leap C++ API Reference  0.7.9
Leap::Config Class Reference

The Config class provides access to Leap system configuration information. More...

Inherits Leap::Interface.

Public Types

enum  ValueType {
  TYPE_UNKNOWN = 0, TYPE_BOOLEAN = 1, TYPE_INT32 = 2, TYPE_FLOAT = 6,
  TYPE_STRING = 8
}
 Enumerates the possible data types for configuration values. More...
 

Public Member Functions

 Config ()
 Constructs a Config object.
 
bool getBool (const std::string &key) const
 Gets the boolean representation for the specified key.
 
float getFloat (const std::string &key) const
 Gets the floating point representation for the specified key.
 
int32_t getInt32 (const std::string &key) const
 Gets the 32-bit integer representation for the specified key.
 
std::string getString (const std::string &key) const
 Gets the string representation for the specified key.
 
bool save ()
 Saves the current state of the config.
 
bool setBool (const std::string &key, bool value)
 Sets the boolean representation for the specified key.
 
bool setFloat (const std::string &key, float value)
 Sets the floating point representation for the specified key.
 
bool setInt32 (const std::string &key, int32_t value)
 Sets the 32-bit integer representation for the specified key.
 
bool setString (const std::string &key, const std::string &value)
 Sets the string representation for the specified key.
 
ValueType type (const std::string &key) const
 Reports the natural data type for the value related to the specified key.
 

Detailed Description

The Config class provides access to Leap system configuration information.

You can get and set gesture configuration parameters using the Config object obtained from a connected Controller object. The key strings required to identify a configuration parameter include:

Key string Value type Default value Units
Gesture.Circle.MinRadius float 5.0 mm
Gesture.Circle.MinArc float 1.5*pi radians
Gesture.Swipe.MinLength float 150 mm
Gesture.Swipe.MinVelocity float 1000 mm/s
Gesture.KeyTap.MinDownVelocity float 50 mm/s
Gesture.KeyTap.HistorySeconds float 0.1 s
Gesture.KeyTap.MinDistance float 3.0 mm
Gesture.ScreenTap.MinForwardVelocity float 50 mm/s
Gesture.ScreenTap.HistorySeconds float 0.1 s
Gesture.ScreenTap.MinDistance float 5.0 mm

After setting a configuration value, you must call the Config::save method to commit the changes. The configuration value changes are not persistent; your application needs to set the values everytime it runs.

See Also
CircleGesture
KeyTapGesture
ScreenTapGesture
SwipeGesture

Member Enumeration Documentation

Enumerates the possible data types for configuration values.

The Config::type() function returns an item from the ValueType enumeration.

Enumerator:
TYPE_UNKNOWN 

The data type is unknown.

TYPE_BOOLEAN 

A boolean value.

TYPE_INT32 

A 32-bit integer.

TYPE_FLOAT 

A floating-point number.

TYPE_STRING 

A string of characters.

Constructor & Destructor Documentation

Leap::Config::Config ( )

Constructs a Config object.

Member Function Documentation

bool Leap::Config::getBool ( const std::string &  key) const

Gets the boolean representation for the specified key.

float Leap::Config::getFloat ( const std::string &  key) const

Gets the floating point representation for the specified key.

int32_t Leap::Config::getInt32 ( const std::string &  key) const

Gets the 32-bit integer representation for the specified key.

std::string Leap::Config::getString ( const std::string &  key) const

Gets the string representation for the specified key.

bool Leap::Config::save ( )

Saves the current state of the config.

Call save() after making a set of configuration changes. The save() function transfers the configuration changes to the Leap application. The configuration value changes are not persistent; your application needs to set the values everytime it runs.

Returns
true on success, false on failure.
bool Leap::Config::setBool ( const std::string &  key,
bool  value 
)

Sets the boolean representation for the specified key.

Returns
true on success, false on failure.
bool Leap::Config::setFloat ( const std::string &  key,
float  value 
)

Sets the floating point representation for the specified key.

Returns
true on success, false on failure.
bool Leap::Config::setInt32 ( const std::string &  key,
int32_t  value 
)

Sets the 32-bit integer representation for the specified key.

Returns
true on success, false on failure.
bool Leap::Config::setString ( const std::string &  key,
const std::string &  value 
)

Sets the string representation for the specified key.

Returns
true on success, false on failure.
ValueType Leap::Config::type ( const std::string &  key) const

Reports the natural data type for the value related to the specified key.

Parameters
keyThe key for the looking up the value in the configuration dictionary.
Returns
The native data type of the value, that is, the type that does not require a data conversion.