/* * 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, const ActionTraits &_trait, bool _doRegister) : Process(_maxSteps,_trait,_doRegister), result(0), done(false) {} template Calculation::~Calculation() { delete result; } // methods inherited from Action template void Calculation::getParametersfromValueStorage() {} template Action::state_ptr Calculation::performCall(){ reset(); (*this)(); return Action::success; } template Action::state_ptr Calculation::performUndo(Action::state_ptr){ ASSERT(0,"Cannot undo a calculation"); return Action::success; } template Action::state_ptr Calculation::performRedo(Action::state_ptr){ ASSERT(0,"Cannot redo a calculation"); return Action::success; } template bool Calculation::canUndo() { return false; } template bool Calculation::shouldUndo() { 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_ */