TINC
Toolkit for Interactive Computation
|
Class to represent a dimension for a ParameterSpace. More...
#include <ParameterSpaceDimension.hpp>
Public Types | |
enum | RepresentationType { VALUE = 0x00 , INDEX = 0x01 , ID = 0x02 } |
Public Member Functions | |
ParameterSpaceDimension (std::string name, std::string group="", ParameterType paramType=ParameterType::PARAMETER_FLOAT) | |
ParameterSpaceDimension. More... | |
ParameterSpaceDimension (al::ParameterMeta *param, bool makeInternal=false) | |
construct a ParameterSpaceDimension from a ParameterMeta * More... | |
~ParameterSpaceDimension () | |
ParameterSpaceDimension (const ParameterSpaceDimension &other)=delete | |
ParameterSpaceDimension & | operator= (const ParameterSpaceDimension &other)=delete |
std::string | getName () |
Get the name of the dimension. More... | |
std::string | getGroup () |
returns the dimension's group More... | |
std::string | getFullAddress () |
Get OSC address for dimension. More... | |
bool | setCurrentValue (float value) |
float | getCurrentValue () |
void | setCurrentIndex (size_t index) |
Set current index. More... | |
size_t | getCurrentIndex () |
get index of current value in parameter space More... | |
std::vector< size_t > | getCurrentIndeces () |
get all index for current value in parameter space More... | |
std::string | getCurrentId () |
get current id More... | |
std::vector< std::string > | getCurrentIds () |
getCurrentIds More... | |
void | setSpaceRepresentationType (RepresentationType type, al::Socket *src=nullptr) |
set representation type for dimension. More... | |
RepresentationType | getSpaceRepresentationType () |
size_t | getSpaceStride () |
get number of elements to jump to move to next value More... | |
template<typename ParameterType > | |
ParameterType & | getParameter () |
al::ParameterMeta * | getParameterMeta () |
get abstract ParameterMeta pointer to internal parameter More... | |
void | stepIncrement () |
void | stepDecrease () |
size_t | size () |
void | sort (al::Socket *src=nullptr) |
sort More... | |
void | clear (al::Socket *src=nullptr) |
Clear the parameter space. More... | |
float | at (size_t index) |
std::string | idAt (size_t index) |
std::vector< std::string > | getIdsForValue (float value) |
get all ids for a value More... | |
void | setSpaceValues (void *values, size_t count, std::string idprefix="", al::Socket *src=nullptr) |
Set possible values in the parameter space dimension. More... | |
template<typename SpaceDataType > | |
void | setSpaceValues (std::vector< SpaceDataType > values, std::string idprefix="", al::Socket *src=nullptr) |
Set possible values in the parameter space dimension. More... | |
void | appendSpaceValues (void *values, size_t count, std::string idprefix="", al::Socket *src=nullptr) |
append values to current dimension values More... | |
template<typename SpaceDataType > | |
std::vector< SpaceDataType > | getSpaceValues () |
void | setSpaceIds (std::vector< std::string > ids, al::Socket *src=nullptr) |
std::vector< std::string > | getSpaceIds () |
al::VariantType | getSpaceDataType () |
Get Data type for space data. More... | |
size_t | getIndexForValue (float value) |
Get index in space for value. More... | |
bool | conformSpace (al::Socket *src=nullptr) |
Adjust range according to current values in parameter space. More... | |
std::shared_ptr< ParameterSpaceDimension > | deepCopy () |
provide a deep copy of the parameter space More... | |
void | print (std::ostream &stream=std::cout) |
Public Attributes | |
std::function< void(ParameterSpaceDimension *, al::Socket *src)> | onDimensionMetadataChange |
Friends | |
class | ParameterSpace |
class | TincProtocol |
Class to represent a dimension for a ParameterSpace.
This class provides data storage, interactivity and (optionally) discretization for the dimension.
It allows mapping a discrete set of parameter values to string ids, for example for mapping values to filesystem names. A ParameterSpaceDimension groups the possible values or states parameters can take. It also holds a "current" value in this parameter space.
In NetCDF parlance, a ParameterSpaceDimension encapsulates both a variable and a dimension. As it deals both with the shape and the values of the parameter space.
Definition at line 91 of file ParameterSpaceDimension.hpp.
Enumerator | |
---|---|
VALUE | |
INDEX | |
ID |
Definition at line 96 of file ParameterSpaceDimension.hpp.
tinc::ParameterSpaceDimension::ParameterSpaceDimension | ( | std::string | name, |
std::string | group = "" , |
||
ParameterType | paramType = ParameterType::PARAMETER_FLOAT |
||
) |
name | |
group | |
paramType | Dimensions must have names and can belong to groups. paramType determines both data type as well as interface and behavior. |
tinc::ParameterSpaceDimension::ParameterSpaceDimension | ( | al::ParameterMeta * | param, |
bool | makeInternal = false |
||
) |
construct a ParameterSpaceDimension from a ParameterMeta *
param | |
makeInternal |
tinc::ParameterSpaceDimension::~ParameterSpaceDimension | ( | ) |
|
delete |
void tinc::ParameterSpaceDimension::appendSpaceValues | ( | void * | values, |
size_t | count, | ||
std::string | idprefix = "" , |
||
al::Socket * | src = nullptr |
||
) |
append values to current dimension values
values | pointer to array of values |
count | number of values in pointer |
idprefix | prefix for auto generated ids |
src | source socket if this function is called from the network |
float tinc::ParameterSpaceDimension::at | ( | size_t | index | ) |
Get value at index 'index' as float
void tinc::ParameterSpaceDimension::clear | ( | al::Socket * | src = nullptr | ) |
Clear the parameter space.
src | socket that generated this request |
bool tinc::ParameterSpaceDimension::conformSpace | ( | al::Socket * | src = nullptr | ) |
Adjust range according to current values in parameter space.
The minimum and maximum value are stored separately from the values the parameter can take, so you must set them manually or use this function.
std::shared_ptr<ParameterSpaceDimension> tinc::ParameterSpaceDimension::deepCopy | ( | ) |
provide a deep copy of the parameter space
This is useful when you need to capture the state of a ParameterSpaceDimension.
Note that currently callbacks for parameters are not being copied.
std::string tinc::ParameterSpaceDimension::getCurrentId | ( | ) |
get current id
If there are no ids defined, or the current value is invalid, an empty string is returned.
std::vector<std::string> tinc::ParameterSpaceDimension::getCurrentIds | ( | ) |
std::vector<size_t> tinc::ParameterSpaceDimension::getCurrentIndeces | ( | ) |
get all index for current value in parameter space
If the parameter space has been defined so that one value can be mapped to multiple ids, this function will return all indeces at which the current value occurs.
size_t tinc::ParameterSpaceDimension::getCurrentIndex | ( | ) |
get index of current value in parameter space
float tinc::ParameterSpaceDimension::getCurrentValue | ( | ) |
Get current value as a float
std::string tinc::ParameterSpaceDimension::getFullAddress | ( | ) |
Get OSC address for dimension.
OSC address joins group and parameter name as: /group/name This serves as a unique identifier for dimensions within a parameter space
std::string tinc::ParameterSpaceDimension::getGroup | ( | ) |
returns the dimension's group
std::vector<std::string> tinc::ParameterSpaceDimension::getIdsForValue | ( | float | value | ) |
get all ids for a value
value |
size_t tinc::ParameterSpaceDimension::getIndexForValue | ( | float | value | ) |
Get index in space for value.
value |
std::string tinc::ParameterSpaceDimension::getName | ( | ) |
Get the name of the dimension.
|
inline |
The parameter instance holds the current value. You can set values for the internal parameter through this function, register notifications and create GUIs/ network synchronization.
Definition at line 229 of file ParameterSpaceDimension.hpp.
|
inline |
get abstract ParameterMeta pointer to internal parameter
To determine the type of parameter, you can test if dynamic_cast<>() != nullptr.
Definition at line 239 of file ParameterSpaceDimension.hpp.
|
inline |
Get Data type for space data.
The space data might be different to the parameter data type. Spaces in int8, int16 and in32 are all handled by ParameterInt that uses a 32 bit representation.
Definition at line 353 of file ParameterSpaceDimension.hpp.
std::vector<std::string> tinc::ParameterSpaceDimension::getSpaceIds | ( | ) |
Get vector containing all space ids
|
inline |
Get current representation type
Definition at line 215 of file ParameterSpaceDimension.hpp.
|
inline |
get number of elements to jump to move to next value
Definition at line 222 of file ParameterSpaceDimension.hpp.
|
inline |
Get possible values this dimension can take
Definition at line 331 of file ParameterSpaceDimension.hpp.
std::string tinc::ParameterSpaceDimension::idAt | ( | size_t | index | ) |
Get id at index
|
delete |
void tinc::ParameterSpaceDimension::print | ( | std::ostream & | stream = std::cout | ) |
void tinc::ParameterSpaceDimension::setCurrentIndex | ( | size_t | index | ) |
Set current index.
bool tinc::ParameterSpaceDimension::setCurrentValue | ( | float | value | ) |
Set current value from float
void tinc::ParameterSpaceDimension::setSpaceIds | ( | std::vector< std::string > | ids, |
al::Socket * | src = nullptr |
||
) |
Set ids for space values. You must ensure that the size of the space and the number of ids matches.
|
inline |
set representation type for dimension.
type | |
src | This determines the preferred representation for the dimension, for example in gui objects. |
Definition at line 204 of file ParameterSpaceDimension.hpp.
|
inline |
Set possible values in the parameter space dimension.
values | pointer to array of values |
idprefix | prefix for auto generated ids |
src | source socket if this function is called from the network |
You will need to call conformSpace() to ensure value and minimum and maximum are update to reflect the parameter space.
Definition at line 310 of file ParameterSpaceDimension.hpp.
void tinc::ParameterSpaceDimension::setSpaceValues | ( | void * | values, |
size_t | count, | ||
std::string | idprefix = "" , |
||
al::Socket * | src = nullptr |
||
) |
Set possible values in the parameter space dimension.
values | pointer to array of values |
count | number of values in pointer |
idprefix | prefix for auto generated ids |
src | source socket if this function is called from the network |
size_t tinc::ParameterSpaceDimension::size | ( | ) |
Size of the defined values in the parameter space
void tinc::ParameterSpaceDimension::sort | ( | al::Socket * | src = nullptr | ) |
sort
src | socket that generated this request |
void tinc::ParameterSpaceDimension::stepDecrease | ( | ) |
Step to the nearest index that decrements the paramter value. This could result in an increase or decrease of the index. Requires that the space is sorted in ascending or descending order.
void tinc::ParameterSpaceDimension::stepIncrement | ( | ) |
Step to the nearest index that increments the paramter value. This could result in an increase or decrease of the index. Requires that the space is sorted in ascending or descending order.
|
friend |
Definition at line 92 of file ParameterSpaceDimension.hpp.
|
friend |
Definition at line 93 of file ParameterSpaceDimension.hpp.
std::function<void(ParameterSpaceDimension *, al::Socket *src)> tinc::ParameterSpaceDimension::onDimensionMetadataChange |
This function is called whenever dimension metadata cahnges, to notify connected clients. 'src' provides the socket that originated the change, to avoid resending the change to that socket.
Definition at line 390 of file ParameterSpaceDimension.hpp.