TSDuck Version 3.15-955 (TSDuck - The MPEG Transport Stream Toolkit)
ts::Variable< T > Class Template Reference

A template class which defines a variable which can be either initialized or uninitialized. More...

Public Member Functions

 Variable () throw ()
 Default constructor, the variable is uninitialized.
 
 Variable (const Variable< T > &other)
 Copy constructor. More...
 
 Variable (const T &obj)
 Constructor from a T instance, the variable is initialized. More...
 
virtual ~Variable ()
 Virtual destructor.
 
bool operator!= (const Variable< T > &other) const
 Unequality operator. More...
 
bool operator!= (const T &obj) const
 Unequality operator with a T instance. More...
 
Variable< T > & operator= (const Variable< T > &other)
 Assignment operator. More...
 
Variable< T > & operator= (const T &obj)
 Assignment operator from a T object. More...
 
bool operator== (const Variable< T > &other) const
 Equality operator. More...
 
bool operator== (const T &obj) const
 Equality operator with a T instance. More...
 
void reset ()
 Reset the value. More...
 
bool set () const
 Check the presence of a value. More...
 
const T & value () const
 Access the constant T value inside the variable. More...
 
T & value ()
 Access the T value inside the variable. More...
 
value (const T &def) const
 Get a copy of the T value inside the variable or a default value. More...
 

Detailed Description

template<typename T>
class ts::Variable< T >

A template class which defines a variable which can be either initialized or uninitialized.

Template Parameters
TA type or class which describes the content of the variable. The basic requirement on T is the availability of a copy constructor and operators for assignment and equality.

Constructor & Destructor Documentation

◆ Variable() [1/2]

template<typename T>
ts::Variable< T >::Variable ( const Variable< T > &  other)
inline

Copy constructor.

This object is in the same state as other. If other is initialized, this object becomes initialized with the same T value.

Parameters
[in]otherAnother instance from which to build this object.

◆ Variable() [2/2]

template<typename T>
ts::Variable< T >::Variable ( const T &  obj)
inline

Constructor from a T instance, the variable is initialized.

Parameters
[in]objThe initial value for the variable.

Member Function Documentation

◆ operator=() [1/2]

template<typename T>
Variable<T>& ts::Variable< T >::operator= ( const Variable< T > &  other)
inline

Assignment operator.

This object is in the same state as other. If other is initialized, this object becomes initialized with the same T value.

Parameters
[in]otherAnother instance from which to assign this object.
Returns
A reference to this object.

◆ operator=() [2/2]

template<typename T>
Variable<T>& ts::Variable< T >::operator= ( const T &  obj)
inline

Assignment operator from a T object.

This object becomes initialized if it was not already.

Parameters
[in]objValue from which to assign this object.
Returns
A reference to this object.

◆ set()

template<typename T>
bool ts::Variable< T >::set ( ) const
inline

Check the presence of a value.

Returns
True if the variable is initialized, false otherwise.

◆ reset()

template<typename T>
void ts::Variable< T >::reset ( )
inline

Reset the value.

This object becomes uninitialized if it was not already.

◆ value() [1/3]

template<typename T>
const T& ts::Variable< T >::value ( ) const
inline

Access the constant T value inside the variable.

Returns
A constant reference to the T value inside the variable.
Exceptions
UninitializedVariableIf the variable is uninitialized.

◆ value() [2/3]

template<typename T>
T& ts::Variable< T >::value ( )
inline

Access the T value inside the variable.

Returns
A reference to the T value inside the variable.
Exceptions
UninitializedVariableIf the variable is uninitialized.

◆ value() [3/3]

template<typename T>
T ts::Variable< T >::value ( const T &  def) const
inline

Get a copy of the T value inside the variable or a default value.

Parameters
[in]defA default T value if the variable is uninitialized.
Returns
A copy the T value inside the variable if the variable is initialized, def otherwise.

◆ operator==() [1/2]

template<typename T>
bool ts::Variable< T >::operator== ( const Variable< T > &  other) const
inline

Equality operator.

Parameters
[in]otherAn other instance to compare with.
Returns
True if both instances are initialized and contain equal values.

◆ operator!=() [1/2]

template<typename T>
bool ts::Variable< T >::operator!= ( const Variable< T > &  other) const
inline

Unequality operator.

Parameters
[in]otherAn other instance to compare with.
Returns
True if any instance is uninitialized or both are initialized with unequal values.

◆ operator==() [2/2]

template<typename T>
bool ts::Variable< T >::operator== ( const T &  obj) const
inline

Equality operator with a T instance.

Parameters
[in]objAn object to compare with.
Returns
True if this object is initialized and its value is equal to obj.

◆ operator!=() [2/2]

template<typename T>
bool ts::Variable< T >::operator!= ( const T &  obj) const
inline

Unequality operator with a T instance.

Parameters
[in]objAn object to compare with.
Returns
True if this object is uninitialized or its value is not equal to obj.

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