iCub-main
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
iCub::learningmachine::merge::IndexSelector Class Reference

The IndexSelector selects the components at specified indices from the source. More...

+ Inheritance diagram for iCub::learningmachine::merge::IndexSelector:

Public Member Functions

 IndexSelector (std::string format)
 Default constructor. More...
 
std::string toString (int indent=0)
 Returns a string specification of the data selector. More...
 
virtual void declareSources (SourceList &sl)
 Declares the required sources for this data selector to the source list. More...
 
virtual void select (Bottle &bot, SourceList &sl)
 Selectively adds data from the source list to an output bottle. More...
 
virtual void loadFormat (std::string format)
 Loads the format of the IndexSelector from a string. More...
 
virtual void loadIndices (std::string format)
 Loads index specifiers from a string format. More...
 

Static Public Member Functions

static std::vector< std::string > split (std::string input, std::string delimiter)
 Splits a string into parts at the given delimiter. More...
 
static int stringToInt (std::string str)
 Converts a string to an integer in a proper C++ way. More...
 

Protected Member Functions

virtual void selectRecursive (Bottle &out, Bottle &in, std::list< std::list< int > >::iterator it)
 Select data from source recursively using the index specifiers. More...
 
virtual void addBottle (Bottle &out, const Bottle &in)
 Adds all the elements in one bottle to an output bottle. More...
 

Protected Attributes

std::string name
 The name of the source port. More...
 
std::list< std::list< int > > indices
 A list of a list of indices. More...
 

Detailed Description

The IndexSelector selects the components at specified indices from the source.

It supports an arbitrary number of dimensions and indices can be specified using a range. If not indices are specified, it returns all of the source data.

Definition at line 346 of file merge.cpp.

Constructor & Destructor Documentation

◆ IndexSelector()

iCub::learningmachine::merge::IndexSelector::IndexSelector ( std::string  format)
inline

Default constructor.

Parameters
formata string specifying the format

Definition at line 410 of file merge.cpp.

Member Function Documentation

◆ addBottle()

virtual void iCub::learningmachine::merge::IndexSelector::addBottle ( Bottle &  out,
const Bottle &  in 
)
inlineprotectedvirtual

Adds all the elements in one bottle to an output bottle.

Parameters
outa reference to the output bottle
ina reference to the input bottle

Definition at line 398 of file merge.cpp.

◆ declareSources()

virtual void iCub::learningmachine::merge::IndexSelector::declareSources ( SourceList sl)
inlinevirtual

Declares the required sources for this data selector to the source list.

Parameters
slthe source list

Implements iCub::learningmachine::merge::DataSelector.

Definition at line 438 of file merge.cpp.

◆ loadFormat()

virtual void iCub::learningmachine::merge::IndexSelector::loadFormat ( std::string  format)
inlinevirtual

Loads the format of the IndexSelector from a string.

Parameters
formatthe format string
Exceptions
aruntime error if parsing fails

Definition at line 464 of file merge.cpp.

◆ loadIndices()

virtual void iCub::learningmachine::merge::IndexSelector::loadIndices ( std::string  format)
inlinevirtual

Loads index specifiers from a string format.

Parameters
formatthe format string
Exceptions
aruntime error if parsing the index specifiers fails

Definition at line 490 of file merge.cpp.

◆ select()

virtual void iCub::learningmachine::merge::IndexSelector::select ( Bottle &  bot,
SourceList sl 
)
inlinevirtual

Selectively adds data from the source list to an output bottle.

Parameters
bota reference to the output Bottle
slthe source list

Implements iCub::learningmachine::merge::DataSelector.

Definition at line 445 of file merge.cpp.

◆ selectRecursive()

virtual void iCub::learningmachine::merge::IndexSelector::selectRecursive ( Bottle &  out,
Bottle &  in,
std::list< std::list< int > >::iterator  it 
)
inlineprotectedvirtual

Select data from source recursively using the index specifiers.

Parameters
outa reference to the output Bottle
ina reference to the input bottle
itthe iterator
Exceptions
aruntime error if trying to index a non-list type

Definition at line 367 of file merge.cpp.

◆ split()

static std::vector<std::string> iCub::learningmachine::merge::IndexSelector::split ( std::string  input,
std::string  delimiter 
)
inlinestatic

Splits a string into parts at the given delimiter.

Parameters
inputthe input string
delimiterthe delimiter
Returns
a vector with the string parts

Definition at line 530 of file merge.cpp.

◆ stringToInt()

static int iCub::learningmachine::merge::IndexSelector::stringToInt ( std::string  str)
inlinestatic

Converts a string to an integer in a proper C++ way.

Parameters
strthe string
Returns
an integer
Exceptions
aruntime error if the string cannot be parsed as an integer

Definition at line 548 of file merge.cpp.

◆ toString()

std::string iCub::learningmachine::merge::IndexSelector::toString ( int  indent = 0)
inlinevirtual

Returns a string specification of the data selector.

Parameters
indenta number of spaces of indentation

Implements iCub::learningmachine::merge::DataSelector.

Definition at line 417 of file merge.cpp.

Member Data Documentation

◆ indices

std::list<std::list<int> > iCub::learningmachine::merge::IndexSelector::indices
protected

A list of a list of indices.

For each dimension, there is a list of indices.

Definition at line 357 of file merge.cpp.

◆ name

std::string iCub::learningmachine::merge::IndexSelector::name
protected

The name of the source port.

Definition at line 351 of file merge.cpp.


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