TINC
Toolkit for Interactive Computation
tinc::ParameterSpaceDimension Class Reference

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
 
ParameterSpaceDimensionoperator= (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 >
ParameterTypegetParameter ()
 
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< ParameterSpaceDimensiondeepCopy ()
 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
 

Detailed Description

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.

Member Enumeration Documentation

◆ RepresentationType

Enumerator
VALUE 
INDEX 
ID 

Definition at line 96 of file ParameterSpaceDimension.hpp.

Constructor & Destructor Documentation

◆ ParameterSpaceDimension() [1/3]

tinc::ParameterSpaceDimension::ParameterSpaceDimension ( std::string  name,
std::string  group = "",
ParameterType  paramType = ParameterType::PARAMETER_FLOAT 
)

ParameterSpaceDimension.

Parameters
name
group
paramTypeDimensions must have names and can belong to groups. paramType determines both data type as well as interface and behavior.

◆ ParameterSpaceDimension() [2/3]

tinc::ParameterSpaceDimension::ParameterSpaceDimension ( al::ParameterMeta *  param,
bool  makeInternal = false 
)

construct a ParameterSpaceDimension from a ParameterMeta *

Parameters
param
makeInternal

◆ ~ParameterSpaceDimension()

tinc::ParameterSpaceDimension::~ParameterSpaceDimension ( )

◆ ParameterSpaceDimension() [3/3]

tinc::ParameterSpaceDimension::ParameterSpaceDimension ( const ParameterSpaceDimension other)
delete

Member Function Documentation

◆ appendSpaceValues()

void tinc::ParameterSpaceDimension::appendSpaceValues ( void *  values,
size_t  count,
std::string  idprefix = "",
al::Socket *  src = nullptr 
)

append values to current dimension values

Parameters
valuespointer to array of values
countnumber of values in pointer
idprefixprefix for auto generated ids
srcsource socket if this function is called from the network

◆ at()

float tinc::ParameterSpaceDimension::at ( size_t  index)

Get value at index 'index' as float

◆ clear()

void tinc::ParameterSpaceDimension::clear ( al::Socket *  src = nullptr)

Clear the parameter space.

Parameters
srcsocket that generated this request

◆ conformSpace()

bool tinc::ParameterSpaceDimension::conformSpace ( al::Socket *  src = nullptr)

Adjust range according to current values in parameter space.

Returns
true if conform was succesful and space is consistent

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.

◆ deepCopy()

std::shared_ptr<ParameterSpaceDimension> tinc::ParameterSpaceDimension::deepCopy ( )

provide a deep copy of the parameter space

Returns
the copy

This is useful when you need to capture the state of a ParameterSpaceDimension.

Note that currently callbacks for parameters are not being copied.

◆ getCurrentId()

std::string tinc::ParameterSpaceDimension::getCurrentId ( )

get current id

Returns
id

If there are no ids defined, or the current value is invalid, an empty string is returned.

◆ getCurrentIds()

std::vector<std::string> tinc::ParameterSpaceDimension::getCurrentIds ( )

getCurrentIds

Returns

See getCurrentIndeces()

◆ getCurrentIndeces()

std::vector<size_t> tinc::ParameterSpaceDimension::getCurrentIndeces ( )

get all index for current value in parameter space

Returns
vector of indeces

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.

◆ getCurrentIndex()

size_t tinc::ParameterSpaceDimension::getCurrentIndex ( )

get index of current value in parameter space

Returns
index

◆ getCurrentValue()

float tinc::ParameterSpaceDimension::getCurrentValue ( )

Get current value as a float

◆ getFullAddress()

std::string tinc::ParameterSpaceDimension::getFullAddress ( )

Get OSC address for dimension.

Returns
OSC address

OSC address joins group and parameter name as: /group/name This serves as a unique identifier for dimensions within a parameter space

◆ getGroup()

std::string tinc::ParameterSpaceDimension::getGroup ( )

returns the dimension's group

Returns
group name

◆ getIdsForValue()

std::vector<std::string> tinc::ParameterSpaceDimension::getIdsForValue ( float  value)

get all ids for a value

Parameters
value
Returns
ids

◆ getIndexForValue()

size_t tinc::ParameterSpaceDimension::getIndexForValue ( float  value)

Get index in space for value.

Parameters
value
Returns
the index

◆ getName()

std::string tinc::ParameterSpaceDimension::getName ( )

Get the name of the dimension.

Returns
the name

◆ getParameter()

template<typename ParameterType >
ParameterType& tinc::ParameterSpaceDimension::getParameter ( )
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.

◆ getParameterMeta()

al::ParameterMeta* tinc::ParameterSpaceDimension::getParameterMeta ( )
inline

get abstract ParameterMeta pointer to internal parameter

Returns

To determine the type of parameter, you can test if dynamic_cast<>() != nullptr.

Definition at line 239 of file ParameterSpaceDimension.hpp.

◆ getSpaceDataType()

al::VariantType tinc::ParameterSpaceDimension::getSpaceDataType ( )
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.

◆ getSpaceIds()

std::vector<std::string> tinc::ParameterSpaceDimension::getSpaceIds ( )

Get vector containing all space ids

◆ getSpaceRepresentationType()

RepresentationType tinc::ParameterSpaceDimension::getSpaceRepresentationType ( )
inline

Get current representation type

Definition at line 215 of file ParameterSpaceDimension.hpp.

◆ getSpaceStride()

size_t tinc::ParameterSpaceDimension::getSpaceStride ( )
inline

get number of elements to jump to move to next value

Returns

Definition at line 222 of file ParameterSpaceDimension.hpp.

◆ getSpaceValues()

template<typename SpaceDataType >
std::vector<SpaceDataType> tinc::ParameterSpaceDimension::getSpaceValues ( )
inline

Get possible values this dimension can take

Definition at line 331 of file ParameterSpaceDimension.hpp.

◆ idAt()

std::string tinc::ParameterSpaceDimension::idAt ( size_t  index)

Get id at index

◆ operator=()

ParameterSpaceDimension& tinc::ParameterSpaceDimension::operator= ( const ParameterSpaceDimension other)
delete

◆ print()

void tinc::ParameterSpaceDimension::print ( std::ostream &  stream = std::cout)

◆ setCurrentIndex()

void tinc::ParameterSpaceDimension::setCurrentIndex ( size_t  index)

Set current index.

◆ setCurrentValue()

bool tinc::ParameterSpaceDimension::setCurrentValue ( float  value)

Set current value from float

◆ setSpaceIds()

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.

◆ setSpaceRepresentationType()

void tinc::ParameterSpaceDimension::setSpaceRepresentationType ( RepresentationType  type,
al::Socket *  src = nullptr 
)
inline

set representation type for dimension.

Parameters
type
srcThis determines the preferred representation for the dimension, for example in gui objects.

Definition at line 204 of file ParameterSpaceDimension.hpp.

◆ setSpaceValues() [1/2]

template<typename SpaceDataType >
void tinc::ParameterSpaceDimension::setSpaceValues ( std::vector< SpaceDataType >  values,
std::string  idprefix = "",
al::Socket *  src = nullptr 
)
inline

Set possible values in the parameter space dimension.

Parameters
valuespointer to array of values
idprefixprefix for auto generated ids
srcsource 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.

◆ setSpaceValues() [2/2]

void tinc::ParameterSpaceDimension::setSpaceValues ( void *  values,
size_t  count,
std::string  idprefix = "",
al::Socket *  src = nullptr 
)

Set possible values in the parameter space dimension.

Parameters
valuespointer to array of values
countnumber of values in pointer
idprefixprefix for auto generated ids
srcsource socket if this function is called from the network

◆ size()

size_t tinc::ParameterSpaceDimension::size ( )

Size of the defined values in the parameter space

◆ sort()

void tinc::ParameterSpaceDimension::sort ( al::Socket *  src = nullptr)

sort

Parameters
srcsocket that generated this request

◆ stepDecrease()

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.

◆ stepIncrement()

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.

Friends And Related Function Documentation

◆ ParameterSpace

friend class ParameterSpace
friend

Definition at line 92 of file ParameterSpaceDimension.hpp.

◆ TincProtocol

friend class TincProtocol
friend

Definition at line 93 of file ParameterSpaceDimension.hpp.

Member Data Documentation

◆ onDimensionMetadataChange

std::function<void(ParameterSpaceDimension *, al::Socket *src)> tinc::ParameterSpaceDimension::onDimensionMetadataChange
Initial value:
=
[](ParameterSpaceDimension *, al::Socket *src) {}
ParameterSpaceDimension(std::string name, std::string group="", ParameterType paramType=ParameterType::PARAMETER_FLOAT)
ParameterSpaceDimension.

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.


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