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... | |
T | 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)] |
A template class which defines a variable which can be either initialized or uninitialized.
T | A 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. |
|
inline |
Default constructor, the variable is uninitialized.
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.
[in] | other | Another instance from which to build this object. |
|
inline |
Constructor from a T instance, the variable is initialized.
[in] | obj | The initial value for the variable. |
|
inlinevirtual |
Virtual destructor.
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.
[in] | other | Another instance from which to assign this object. |
QtlVariable< T > & QtlVariable< T >::operator= | ( | const T & | obj | ) |
Assignment operator from a T object.
This object becomes initialized if it was not already.
[in] | obj | Value from which to assign this object. |
|
inline |
Check the presence of a value.
void QtlVariable< T >::reset | ( | ) |
Reset the value.
This object becomes uninitialized if it was not already.
const T & QtlVariable< T >::value | ( | ) | const | |
throw | ( | QtlUninitializedException | ||
) |
Access the constant T value inside the variable.
QtlUnitializedException | If the variable is uninitialized. |
T & QtlVariable< T >::value | ( | ) | ||
throw | ( | QtlUninitializedException | ||
) |
Access the T value inside the variable.
QtlUnitializedException | If the variable is uninitialized. |
|
inline |
Get a copy of the T value inside the variable or a default value.
[in] | def | A default T value if the variable is uninitialized. |
|
inline |
Equality operator.
[in] | other | An other instance to compare with. |
|
inline |
Unequality operator.
[in] | other | An other instance to compare with. |
|
inline |
Equality operator with a T instance.
[in] | obj | An object to compare with. |
|
inline |
Unequality operator with a T instance.
[in] | obj | An object to compare with. |
|
private |
|
private |