Public Member Functions | Private Attributes | List of all members
icl_core::Finalizable< T > Class Template Reference

#include <Finalizable.h>

Public Member Functions

 Finalizable (const T &value)
 
 Finalizable (const Finalizable &other)
 
void finalize ()
 Finalizes the object, i.e. makes it unmodifiable. More...
 
bool isFinal () const
 Returns true if the object is final. More...
 
 operator T () const
 Implicit conversion. More...
 
std::ostream & operator<< (std::ostream &os)
 Output stream operator. More...
 
Finalizableoperator= (const Finalizable &other)
 Assignment is only allowed as long as this is not final. More...
 
Finalizableoperator= (const T &value)
 Assigning a value is only allowed as long as this is not final. More...
 

Private Attributes

bool m_final
 Indicates whether m_value is final, i.e. no longer modifiable. More...
 
m_value
 

Detailed Description

template<typename T>
class icl_core::Finalizable< T >

A simple object wrapper for objects which may be modified until they are "finalized", after which they are constant. Finalizable<T> behaves mostly like T, but after calling finalize(), assignments are no longer allowed and result in a std::logic_error.

This is useful in cases where variables cannot be made const, but should have a const behavior once they have received their correct value.

Definition at line 42 of file Finalizable.h.

Constructor & Destructor Documentation

template<typename T >
icl_core::Finalizable< T >::Finalizable ( const T &  value)
inline

Definition at line 45 of file Finalizable.h.

template<typename T >
icl_core::Finalizable< T >::Finalizable ( const Finalizable< T > &  other)
inline

Copy construction includes the m_final state, so a finalized object remains finalized.

Definition at line 53 of file Finalizable.h.

Member Function Documentation

template<typename T >
void icl_core::Finalizable< T >::finalize ( )
inline

Finalizes the object, i.e. makes it unmodifiable.

Definition at line 93 of file Finalizable.h.

template<typename T >
bool icl_core::Finalizable< T >::isFinal ( ) const
inline

Returns true if the object is final.

Definition at line 90 of file Finalizable.h.

template<typename T >
icl_core::Finalizable< T >::operator T ( ) const
inline

Implicit conversion.

Definition at line 87 of file Finalizable.h.

template<typename T >
std::ostream& icl_core::Finalizable< T >::operator<< ( std::ostream &  os)
inline

Output stream operator.

Definition at line 96 of file Finalizable.h.

template<typename T >
Finalizable& icl_core::Finalizable< T >::operator= ( const Finalizable< T > &  other)
inline

Assignment is only allowed as long as this is not final.

Definition at line 59 of file Finalizable.h.

template<typename T >
Finalizable& icl_core::Finalizable< T >::operator= ( const T &  value)
inline

Assigning a value is only allowed as long as this is not final.

Definition at line 73 of file Finalizable.h.

Member Data Documentation

template<typename T >
bool icl_core::Finalizable< T >::m_final
private

Indicates whether m_value is final, i.e. no longer modifiable.

Definition at line 107 of file Finalizable.h.

template<typename T >
T icl_core::Finalizable< T >::m_value
private

The value managed by this object. Can be modified as long as m_final is false, after that it appears constant.

Definition at line 105 of file Finalizable.h.


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


fzi_icl_core
Author(s):
autogenerated on Mon Jun 10 2019 13:17:59