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