|
Last change
on this file since 5dba7a was 5dba7a, checked in by Tillmann Crueger <crueger@…>, 16 years ago |
|
Made the periodentafel use STL-containers instead of custom llists
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | * Calculation_impl.hpp
|
|---|
| 3 | *
|
|---|
| 4 | * Created on: Feb 19, 2010
|
|---|
| 5 | * Author: crueger
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #ifndef CALCULATION_IMPL_HPP_
|
|---|
| 9 | #define CALCULATION_IMPL_HPP_
|
|---|
| 10 |
|
|---|
| 11 | #include "Actions/Calculation.hpp"
|
|---|
| 12 |
|
|---|
| 13 | #include <cassert>
|
|---|
| 14 |
|
|---|
| 15 | template<typename T>
|
|---|
| 16 | Calculation<T>::Calculation(int _maxSteps, std::string _name, bool _doRegister) :
|
|---|
| 17 | Process(_maxSteps,_name,_doRegister),
|
|---|
| 18 | result(0),
|
|---|
| 19 | done(false)
|
|---|
| 20 | {}
|
|---|
| 21 |
|
|---|
| 22 | template<typename T>
|
|---|
| 23 | Calculation<T>::~Calculation()
|
|---|
| 24 | {
|
|---|
| 25 | delete result;
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | // methods inherited from Action
|
|---|
| 29 |
|
|---|
| 30 | template<typename T>
|
|---|
| 31 | void Calculation<T>::call(){
|
|---|
| 32 | reset();
|
|---|
| 33 | (*this)();
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | template<typename T>
|
|---|
| 37 | void Calculation<T>::undo(){}
|
|---|
| 38 |
|
|---|
| 39 | template<typename T>
|
|---|
| 40 | bool Calculation<T>::canUndo()
|
|---|
| 41 | {
|
|---|
| 42 | return false;
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | // methods for calculation infrastructure
|
|---|
| 46 |
|
|---|
| 47 | template<typename T>
|
|---|
| 48 | T Calculation<T>::operator()(){
|
|---|
| 49 | if(!done){
|
|---|
| 50 | result = doCalc();
|
|---|
| 51 | done = true;
|
|---|
| 52 | }
|
|---|
| 53 | return *result;
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | template<typename T>
|
|---|
| 57 | bool Calculation<T>::hasResult(){
|
|---|
| 58 | return done;
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | template<typename T>
|
|---|
| 62 | T Calculation<T>::getResult(){
|
|---|
| 63 | assert(done && "No result calculated");
|
|---|
| 64 | return *result;
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | template<typename T>
|
|---|
| 68 | void Calculation<T>::reset(){
|
|---|
| 69 | done = false;
|
|---|
| 70 | delete result;
|
|---|
| 71 | result = 0;
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | #endif /* CALCULATION_IMPL_HPP_ */
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.