diff --git a/alib2abstraction/src/abstraction/ValueHolderInterface.hpp b/alib2abstraction/src/abstraction/ValueHolderInterface.hpp index 5e9999b81a9e26edf4ba03968994d4ab38949fd9..394cab8ec3ae3a5d3864f9a00474eeebf662b7af 100644 --- a/alib2abstraction/src/abstraction/ValueHolderInterface.hpp +++ b/alib2abstraction/src/abstraction/ValueHolderInterface.hpp @@ -8,49 +8,16 @@ #ifndef _VALUE_HOLDER_INTERFACE_HPP_ #define _VALUE_HOLDER_INTERFACE_HPP_ -#include <abstraction/Value.hpp> +#include <abstraction/ValueInterface.hpp> namespace abstraction { template < class Type > -class ValueHolderInterface : public Value { - ParamQualifiers::ParamQualifierSet m_paramQualifierSet; - bool m_isTemporary; - -protected: - ValueHolderInterface ( ParamQualifiers::ParamQualifierSet paramQualifierSet, bool isTemporary ) : m_paramQualifierSet ( paramQualifierSet ), m_isTemporary ( isTemporary ) { - if ( this->isLvalueRef ( ) && this->isTemporary ( ) ) - throw std::domain_error ( "Lvalue references cannot be a temporarie." ); - if ( this->isLvalueRef ( ) && this->isRvalueRef ( ) ) - throw std::domain_error ( "A reference cannot be both, rvalue and lvalue." ); - } - +class ValueHolderInterface : public ValueInterface { public: - virtual Type && getValue ( ) const = 0; - - ParamQualifiers::ParamQualifierSet getParamQualifiersSet ( ) const { - return m_paramQualifierSet; - } - - bool isConst ( ) const { - return m_paramQualifierSet && ParamQualifiers::ParamQualifierSet::CONST; - } + using ValueInterface::ValueInterface; - bool isRef ( ) const { - return isRvalueRef ( ) || isLvalueRef ( ); - } - - bool isRvalueRef ( ) const { - return m_paramQualifierSet && ParamQualifiers::ParamQualifierSet::RREF; - } - - bool isLvalueRef ( ) const { - return m_paramQualifierSet && ParamQualifiers::ParamQualifierSet::LREF; - } - - bool isTemporary ( ) const { - return m_isTemporary; - } + virtual Type && getValue ( ) const = 0; }; diff --git a/alib2abstraction/src/abstraction/ValueInterface.hpp b/alib2abstraction/src/abstraction/ValueInterface.hpp new file mode 100644 index 0000000000000000000000000000000000000000..9b908c3ee5e77bec37a559e7c5be79f78dbbdddd --- /dev/null +++ b/alib2abstraction/src/abstraction/ValueInterface.hpp @@ -0,0 +1,56 @@ +/* + * ValueHolderInterface.hpp + * + * Created on: 11. 7. 2017 + * Author: Jan Travnicek + */ + +#ifndef _VALUE_INTERFACE_HPP_ +#define _VALUE_INTERFACE_HPP_ + +#include <abstraction/Value.hpp> + +namespace abstraction { + +class ValueInterface : public Value { + ParamQualifiers::ParamQualifierSet m_paramQualifierSet; + bool m_isTemporary; + +protected: + ValueInterface ( ParamQualifiers::ParamQualifierSet paramQualifierSet, bool isTemporary ) : m_paramQualifierSet ( paramQualifierSet ), m_isTemporary ( isTemporary ) { + if ( this->isLvalueRef ( ) && this->isTemporary ( ) ) + throw std::domain_error ( "Lvalue references cannot be a temporarie." ); + if ( this->isLvalueRef ( ) && this->isRvalueRef ( ) ) + throw std::domain_error ( "A reference cannot be both, rvalue and lvalue." ); + } + +public: + ParamQualifiers::ParamQualifierSet getParamQualifiersSet ( ) const { + return m_paramQualifierSet; + } + + bool isConst ( ) const { + return m_paramQualifierSet && ParamQualifiers::ParamQualifierSet::CONST; + } + + bool isRef ( ) const { + return isRvalueRef ( ) || isLvalueRef ( ); + } + + bool isRvalueRef ( ) const { + return m_paramQualifierSet && ParamQualifiers::ParamQualifierSet::RREF; + } + + bool isLvalueRef ( ) const { + return m_paramQualifierSet && ParamQualifiers::ParamQualifierSet::LREF; + } + + bool isTemporary ( ) const { + return m_isTemporary; + } + +}; + +} /* namespace abstraction */ + +#endif /* _VALUE_INTERFACE_HPP_ */