Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
MemberAbstraction.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include <ext/memory>
9
13
14namespace abstraction {
15
16template < class ObjectType, class ReturnType, class ... ParamTypes >
17class MemberAbstraction : virtual public NaryOperationAbstraction < ObjectType &, ParamTypes ... >, virtual public ValueOperationAbstraction < ReturnType > {
18 std::function < ReturnType ( typename std::remove_reference < ObjectType >::type *, ParamTypes ... ) > m_callback;
19
20public:
21 explicit MemberAbstraction ( std::function < ReturnType ( typename std::remove_reference < ObjectType >::type *, ParamTypes ... ) > callback ) : m_callback ( std::move ( callback ) ) {
22 }
23
24 std::shared_ptr < abstraction::Value > run ( ) const override {
25 ext::array < std::shared_ptr < abstraction::Value >, sizeof ... ( ParamTypes ) + 1 > params = this->getParams ( );
26
27 std::shared_ptr < OperationAbstraction > reference = std::make_shared < ReferenceAbstraction < typename std::remove_reference < ObjectType >::type > > ( );
28 reference->attachInput ( std::get < 0 > ( this->getParams ( ) ), 0 );
29
30 std::shared_ptr < abstraction::Value > ref = reference->eval ( );
31 if ( ! ref )
32 throw std::invalid_argument ( "Eval of object of call to member falsed." );
33
34 std::get < 0 > ( params ) = ref;
35
36 return ValueOperationAbstraction < ReturnType >::template run_helper < typename std::remove_reference < ObjectType >::type *, ParamTypes ... > ( m_callback, params );
37 }
38
39};
40
41} /* namespace abstraction */
42
Definition: MemberAbstraction.hpp:17
std::shared_ptr< abstraction::Value > run() const override
Definition: MemberAbstraction.hpp:24
MemberAbstraction(std::function< ReturnType(typename std::remove_reference< ObjectType >::type *, ParamTypes ...) > callback)
Definition: MemberAbstraction.hpp:21
const ext::array< std::shared_ptr< abstraction::Value >, NumberOfParams > & getParams() const
Definition: NaryOperationAbstraction.hpp:21
Definition: NaryOperationAbstraction.hpp:77
Definition: ValueOperationAbstraction.hpp:19
Class extending the array class from the standard library. Original reason is to allow printing of th...
Definition: array.hpp:68
Definition: AlgorithmAbstraction.hpp:11
int callback(struct dl_phdr_info *info, size_t, void *data)
Definition: simpleStacktrace.cpp:25
Definition: FordFulkerson.hpp:16