Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
AlgorithmAbstraction.hpp 993 B
/*
 * AlgorithmAbstraction.hpp
 *
 *  Created on: 11. 7. 2017
 *	  Author: Jan Travnicek
 */

#ifndef _ALGORITHM_ABSTRACTION_HPP_
#define _ALGORITHM_ABSTRACTION_HPP_

#include <abstraction/NaryOperationAbstraction.hpp>
#include <tuple>
#include <memory>
#include <abstraction/Registry.h>

namespace abstraction {

template < class ReturnType, class ... ParamTypes >
class AlgorithmAbstraction : public NaryOperationAbstraction < ReturnType, ParamTypes ... > {
	std::function < ReturnType ( ParamTypes ... ) > m_callback;

public:
	AlgorithmAbstraction ( std::function < ReturnType ( ParamTypes ... ) > callback ) : m_callback ( callback ) {
	}

	virtual bool run ( ) override {
		if ( ! this->inputsReady ( ) )
			return false;

		if ( this->cached ( ) )
			return true;

		this->run_helper ( m_callback, this->m_params, this->m_moves, std::make_index_sequence < sizeof ... ( ParamTypes ) > { } );
		return true;
	}

};

} /* namespace abstraction */

#endif /* _ALGORITHM_ABSTRACTION_HPP_ */