Skip to content
Snippets Groups Projects
Commit ab4ed6b9 authored by Jan Travnicek's avatar Jan Travnicek
Browse files

redesign Wrapper abstraction to use private fields

parent 710af334
No related branches found
No related tags found
1 merge request!95Many clang-tidy fixes
......@@ -15,12 +15,24 @@ namespace abstraction {
 
template < class ... ParamTypes >
class BaseWrapperAbstraction : public OperationAbstraction {
protected:
std::function < std::shared_ptr < OperationAbstraction > ( ParamTypes ... ) > m_WrapperFinder;
 
std::shared_ptr < OperationAbstraction > m_abstraction;
ext::array < std::pair < std::shared_ptr < OperationAbstraction >, bool >, sizeof ... ( ParamTypes ) > m_params;
 
protected:
void evalAbstractionFunction ( ) {
m_abstraction = abstraction::apply < ParamTypes ... > ( m_WrapperFinder, m_params );
}
std::shared_ptr < OperationAbstraction > & getAbstraction ( ) {
return m_abstraction;
}
const std::shared_ptr < OperationAbstraction > & getAbstraction ( ) const {
return m_abstraction;
}
public:
BaseWrapperAbstraction ( std::function < std::shared_ptr < OperationAbstraction > ( ParamTypes ... ) > wrapperFinder ) : m_WrapperFinder ( std::move ( wrapperFinder ) ) {
for ( unsigned i = 0; i < sizeof ... ( ParamTypes ); ++ i ) {
......@@ -123,14 +135,14 @@ public:
}
 
bool run ( ) override {
this->m_abstraction = abstraction::apply < ParamTypes ... > ( this->m_WrapperFinder, this->m_params );
this->evalAbstractionFunction ( );
 
if ( this->m_abstraction->getReturnTypeIndex ( ) != this->getReturnTypeIndex ( ) )
if ( this->getAbstraction ( )->getReturnTypeIndex ( ) != this->getReturnTypeIndex ( ) )
throw std::domain_error ( "Expected and provided types do not match" );
 
this->attachInputsToAbstraction ( );
 
return this->m_abstraction->eval ( );
return this->getAbstraction ( )->eval ( );
}
 
ext::type_index getReturnTypeIndex ( ) const override {
......@@ -150,23 +162,23 @@ public:
}
 
bool run ( ) override {
this->m_abstraction = abstraction::apply < ParamTypes ... > ( this->m_WrapperFinder, this->m_params );
this->evalAbstractionFunction ( );
 
this->attachInputsToAbstraction ( );
 
return this->m_abstraction->eval ( );
return this->getAbstraction ( )->eval ( );
}
 
ext::type_index getReturnTypeIndex ( ) const override {
if ( this->cached ( ) )
return this->m_abstraction->getProxyAbstraction ( )->getReturnTypeIndex ( );
return this->getAbstraction ( )->getProxyAbstraction ( )->getReturnTypeIndex ( );
else
throw std::domain_error ( "Return type unknown before evaluation." );
}
 
ext::set < abstraction::ParamQualifiers::ParamQualifier > getReturnTypeQualifiers ( ) const override {
if ( this->cached ( ) )
return this->m_abstraction->getProxyAbstraction ( )->getReturnTypeQualifiers ( );
return this->getAbstraction ( )->getProxyAbstraction ( )->getReturnTypeQualifiers ( );
else
throw std::domain_error ( "Return type qualifiers unknown before evaluation." );
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment