SOFA API  ca70b0f0
Open source framework for multi-physics simuation
sofa::helper::OptionsGroup Class Reference

#include <OptionsGroup.h>

OptionsGroup is a kind of data for a radio button. It has a list of text representing a list of choices, and a interger number indicating the choice selected. More...

Detailed Description

OptionsGroup is a kind of data for a radio button. It has a list of text representing a list of choices, and a interger number indicating the choice selected.

Protected Attributes

type::vector< std::string > textItems
 
unsigned int selectedItem
 

Public Member Functions

int isInOptionsList (const std::string &tempostring) const
 
Constructors

Default constructor

 OptionsGroup ()
 
 OptionsGroup (int nbofRadioButton,...)
 
template<class T , typename = std::enable_if_t<type::trait::is_container<T>::value>>
 OptionsGroup (const T &list)
 generic constructor taking other string container like list<string>, set<string>, vector<string> More...
 
template<class T >
 OptionsGroup (const std::initializer_list< T > &list)
 
 OptionsGroup (const OptionsGroup &m_radiotrick)
 Copy constructor. More...
 
setting operators
void setNbItems (size_type nbofRadioButton)
 Set the number of items. More...
 
void setItemName (unsigned int id_item, const std::string &name)
 Set the name of the id-th item. More...
 
void setNames (int nbofRadioButton,...)
 
template<class T >
void setNames (const std::initializer_list< T > &list)
 
OptionsGroupsetSelectedItem (unsigned int id_item)
 Setting the activated item by its id. More...
 
OptionsGroupsetSelectedItem (const std::string &)
 Setting the activated item by its value (string) More...
 
void readFromStream (std::istream &stream)
 
getting informations operators
unsigned int getSelectedId () const
 
const std::string & getSelectedItem () const
 
const std::string & operator[] (const unsigned int i) const
 
size_t size () const
 
void writeToStream (std::ostream &stream) const
 
OptionsGroupoperator= (const OptionsGroup &m_radiotrick)=default
 

Protected Member Functions

template<class T >
void buildFromContainer (const T &list)
 

Attribute details

◆ selectedItem

unsigned int sofa::helper::OptionsGroup::selectedItem
protected

◆ textItems

type::vector<std::string> sofa::helper::OptionsGroup::textItems
protected

Constructor details

◆ OptionsGroup() [1/5]

sofa::helper::OptionsGroup::OptionsGroup ( )

◆ OptionsGroup() [2/5]

sofa::helper::OptionsGroup::OptionsGroup ( int  nbofRadioButton,
  ... 
)
explicit

Constructor by given the number of argument following by the variable arguments Example OptionsGroup m_options(4,"button0","button1","button2","button3");

◆ OptionsGroup() [3/5]

template<class T , typename >
sofa::helper::OptionsGroup::OptionsGroup ( const T &  list)
explicit

generic constructor taking other string container like list<string>, set<string>, vector<string>

◆ OptionsGroup() [4/5]

template<class T >
sofa::helper::OptionsGroup::OptionsGroup ( const std::initializer_list< T > &  list)

◆ OptionsGroup() [5/5]

sofa::helper::OptionsGroup::OptionsGroup ( const OptionsGroup m_radiotrick)

Copy constructor.

Function details

◆ buildFromContainer()

template<class T >
void sofa::helper::OptionsGroup::buildFromContainer ( const T &  list)
protected

◆ getSelectedId()

unsigned int sofa::helper::OptionsGroup::getSelectedId ( ) const

◆ getSelectedItem()

const std::string & sofa::helper::OptionsGroup::getSelectedItem ( ) const

◆ isInOptionsList()

int sofa::helper::OptionsGroup::isInOptionsList ( const std::string &  tempostring) const

return the id_item of the string if found in string list button -1 if not found

◆ operator=()

OptionsGroup& sofa::helper::OptionsGroup::operator= ( const OptionsGroup m_radiotrick)
default

◆ operator[]()

const std::string& sofa::helper::OptionsGroup::operator[] ( const unsigned int  i) const
inline

◆ readFromStream()

void sofa::helper::OptionsGroup::readFromStream ( std::istream &  stream)

Setting the activated item by a input-stream. the istream is converted to string. If the reading string is in options list, its value is setted activated, else push a warning.

◆ setItemName()

void sofa::helper::OptionsGroup::setItemName ( unsigned int  id_item,
const std::string &  name 
)

Set the name of the id-th item.

◆ setNames() [1/2]

template<class T >
void sofa::helper::OptionsGroup::setNames ( const std::initializer_list< T > &  list)

◆ setNames() [2/2]

void sofa::helper::OptionsGroup::setNames ( int  nbofRadioButton,
  ... 
)

Reinitializing options by a pre-constructed optionsgroup objected Example m_options.setNames(4,"button0","button1","button2","button3");

◆ setNbItems()

void sofa::helper::OptionsGroup::setNbItems ( size_type  nbofRadioButton)

Set the number of items.

◆ setSelectedItem() [1/2]

OptionsGroup & sofa::helper::OptionsGroup::setSelectedItem ( const std::string &  m_string)

Setting the activated item by its value (string)

◆ setSelectedItem() [2/2]

OptionsGroup & sofa::helper::OptionsGroup::setSelectedItem ( unsigned int  id_item)

Setting the activated item by its id.

◆ size()

size_t sofa::helper::OptionsGroup::size ( ) const
inline

◆ writeToStream()

void sofa::helper::OptionsGroup::writeToStream ( std::ostream &  stream) const