PARTONS/ElementaryUtils  
Basic utility softwares (Logger, threads, etc)
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ElemUtils::GenericType Class Reference

A complex object to handle different simple types in a uniform way. More...

Inheritance diagram for ElemUtils::GenericType:
ElemUtils::Parameter

Public Member Functions

template<class T >
 GenericType (const T &value)
 Construct a GenericType object from any simple type. More...
 
virtual ~GenericType ()
 Default destructor. More...
 
 GenericType (const GenericType &other)
 Copy constructor. More...
 
double toDouble () const
 Convert stream to double. More...
 
int toInt () const
 Concert stream to integer. More...
 
unsigned int toUInt () const
 Convert stream to unsigned integer. More...
 
bool toBoolean () const
 Convert stream to boolean. More...
 
short toShort () const
 Convert stream to short. More...
 
unsigned short toUShort () const
 Convert stream to unsigned short. More...
 
size_t toSize_t () const
 
std::vector< double > toVectorDouble () const
 
std::vector< int > toVectorInt () const
 
std::string getString () const
 Convert stream to string. More...
 
GenericTypeoperator= (const GenericType &rhs)
 
void setValue (const GenericType &value)
 

Private Member Functions

bool operator== (const GenericType &right) const
 Disallow comparisons between GenericTypes. More...
 
bool operator!= (const GenericType &right) const
 

Private Attributes

std::stringstream m_stream
 stream to store serialized simple type More...
 

Detailed Description

A complex object to handle different simple types in a uniform way.

Simple types considered: double, int, unsigned int, boolean, short, unsigned short, string, etc. Various simple types are stored into a unique stream, providing a way to handle a generic type. Each simple type can be retrieved from the stream using an appropriate method. For example toInt() or toDouble() return respectively int or double variables.

Warning: a generic type object can be defined from any class, but the adequate conversion function may have to be added.

Constructor & Destructor Documentation

◆ GenericType() [1/2]

template<class T >
ElemUtils::GenericType::GenericType ( const T &  value)
inline

Construct a GenericType object from any simple type.

Parameters
value

◆ ~GenericType()

ElemUtils::GenericType::~GenericType ( )
virtual

Default destructor.

◆ GenericType() [2/2]

ElemUtils::GenericType::GenericType ( const GenericType other)

Copy constructor.

Parameters
other

Member Function Documentation

◆ getString()

std::string ElemUtils::GenericType::getString ( ) const

Convert stream to string.

Returns
std::string

◆ operator!=()

bool ElemUtils::GenericType::operator!= ( const GenericType right) const
private

◆ operator=()

GenericType & ElemUtils::GenericType::operator= ( const GenericType rhs)

◆ operator==()

bool ElemUtils::GenericType::operator== ( const GenericType right) const
private

Disallow comparisons between GenericTypes.

◆ setValue()

void ElemUtils::GenericType::setValue ( const GenericType value)

◆ toBoolean()

bool ElemUtils::GenericType::toBoolean ( ) const

Convert stream to boolean.

Returns
bool

◆ toDouble()

double ElemUtils::GenericType::toDouble ( ) const

Convert stream to double.

Returns
double

◆ toInt()

int ElemUtils::GenericType::toInt ( ) const

Concert stream to integer.

Returns
int

◆ toShort()

short ElemUtils::GenericType::toShort ( ) const

Convert stream to short.

◆ toSize_t()

size_t ElemUtils::GenericType::toSize_t ( ) const

◆ toUInt()

unsigned int ElemUtils::GenericType::toUInt ( ) const

Convert stream to unsigned integer.

Returns
unsigned int

◆ toUShort()

unsigned short ElemUtils::GenericType::toUShort ( ) const

Convert stream to unsigned short.

◆ toVectorDouble()

std::vector< double > ElemUtils::GenericType::toVectorDouble ( ) const

◆ toVectorInt()

std::vector< int > ElemUtils::GenericType::toVectorInt ( ) const

Member Data Documentation

◆ m_stream

std::stringstream ElemUtils::GenericType::m_stream
private

stream to store serialized simple type


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