/* * Calculation_impl.hpp * * Created on: Feb 19, 2010 * Author: crueger */ #ifndef CALCULATION_IMPL_HPP_ #define CALCULATION_IMPL_HPP_ #include "Actions/Calculation.hpp" #include template Calculation::Calculation(int _maxSteps, std::string _name, bool _doRegister) : Process(_maxSteps,_name,_doRegister), done(false), result(0) {} template Calculation::~Calculation() { delete result; } // methods inherited from Action template void Calculation::call(){ reset(); (*this)(); } template void Calculation::undo(){} template bool Calculation::canUndo() { return false; } // methods for calculation infrastructure template T Calculation::operator()(){ if(!done){ result = doCalc(); done = true; } return *result; } template bool Calculation::hasResult(){ return done; } template T Calculation::getResult(){ assert(done && "No result calculated"); return *result; } template void Calculation::reset(){ done = false; delete result; result = 0; } #endif /* CALCULATION_IMPL_HPP_ */