QtlMovie 1.12 (A specialized FFmpeg front-end)
QtlVariable< T > Class Template Reference

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

Public Member Functions

 QtlVariable () throw ()
 Default constructor, the variable is uninitialized. More...
 
 QtlVariable (const QtlVariable< T > &other)
 Copy constructor. More...
 
 QtlVariable (const T &obj)
 Constructor from a T instance, the variable is initialized. More...
 
virtual ~QtlVariable ()
 Virtual destructor. More...
 
bool operator!= (const QtlVariable< T > &other) const
 Unequality operator. More...
 
bool operator!= (const T &obj) const
 Unequality operator with a T instance. More...
 
QtlVariable< T > & operator= (const QtlVariable< T > &other)
 Assignment operator. More...
 
QtlVariable< T > & operator= (const T &obj)
 Assignment operator from a T object. More...
 
bool operator== (const QtlVariable< 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 throw (QtlUninitializedException)
 Access the constant T value inside the variable. More...
 
T & value () throw (QtlUninitializedException)
 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...
 

Private Attributes

T * _access
 
quint8 _data [sizeof(T)]
 

Detailed Description

template<typename T>
class QtlVariable< 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

◆ QtlVariable() [1/3]

template<typename T >
QtlVariable< T >::QtlVariable ( )
throw (
)
inline

Default constructor, the variable is uninitialized.

◆ QtlVariable() [2/3]

template<typename T >
QtlVariable< T >::QtlVariable ( const QtlVariable< T > &  other)

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.

◆ QtlVariable() [3/3]

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

Constructor from a T instance, the variable is initialized.

Parameters
[in]objThe initial value for the variable.

◆ ~QtlVariable()

template<typename T >
virtual QtlVariable< T >::~QtlVariable ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

◆ operator=() [1/2]

template<typename T >
QtlVariable< T > & QtlVariable< T >::operator= ( const QtlVariable< T > &  other)

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 >
QtlVariable< T > & QtlVariable< T >::operator= ( const T &  obj)

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 QtlVariable< T >::set ( ) const
inline

Check the presence of a value.

Returns
True if the variable is initialized, false otherwise.

◆ reset()

template<typename T >
void QtlVariable< T >::reset ( )

Reset the value.

This object becomes uninitialized if it was not already.

◆ value() [1/3]

template<typename T >
const T & QtlVariable< T >::value ( ) const
throw (QtlUninitializedException
)

Access the constant T value inside the variable.

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

◆ value() [2/3]

template<typename T >
T & QtlVariable< T >::value ( )
throw (QtlUninitializedException
)

Access the T value inside the variable.

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

◆ value() [3/3]

template<typename T >
T QtlVariable< 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 QtlVariable< T >::operator== ( const QtlVariable< 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 QtlVariable< T >::operator!= ( const QtlVariable< 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 QtlVariable< 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 QtlVariable< 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.

Member Data Documentation

◆ _access

template<typename T >
T* QtlVariable< T >::_access
private

◆ _data

template<typename T >
quint8 QtlVariable< T >::_data[sizeof(T)]
private

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