Changeset 78b9d9 for molecuilder/src/Actions
- Timestamp:
- Mar 3, 2010, 1:57:41 PM (16 years ago)
- Children:
- 14d898
- Parents:
- dc5413
- Location:
- molecuilder/src/Actions
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/Actions/Calculation.hpp
rdc5413 r78b9d9 11 11 #include "Actions/Process.hpp" 12 12 13 /** 14 * A calculation is a Process that has some kind of result. 15 * 16 * This class can be used in the same way as any other Action or Process, but has some special methods 17 * for inspecting the result of the calculation. 18 */ 13 19 template<typename T> 14 20 class Calculation : public Process … … 18 24 virtual ~Calculation(); 19 25 26 /** 27 * Reimplemented call method for Action Base class. 28 * Resets the result and then redoes the calculation. Can be used to retrigger calculations 29 * from menu Items or other places. 30 */ 20 31 virtual void call(); 21 32 virtual void undo(); 22 33 virtual bool canUndo(); 23 34 35 /** 36 * Does the actual calculation and returns the result. 37 * When the calculation has been done before it is not redone, but the previous cached result is returned. 38 * Call reset to delete the cached value. 39 */ 24 40 virtual T operator()(); 41 42 /** 43 * Check if a cached result is available. 44 */ 25 45 virtual bool hasResult(); 46 47 /** 48 * Get the cached result. 49 * Fails if there is no cached result. 50 */ 26 51 virtual T getResult(); 52 53 /** 54 * Delete a previously calculated result from the cache. 55 */ 27 56 virtual void reset(); 28 57 29 58 protected: 30 59 T* result; 60 61 /** 62 * Pure virtual method for implementation of the actual calculation procedure. 63 */ 31 64 virtual T* doCalc()=0; 32 65 private: -
molecuilder/src/Actions/Process.cpp
rdc5413 r78b9d9 73 73 { 74 74 OBSERVE; 75 active = true;76 75 currStep=0; 77 76 } 78 77 starts = false; 78 active = true; 79 79 } 80 80 … … 85 85 86 86 void Process::stop(){ 87 active=false; 87 88 stops = true; 88 89 { 89 90 OBSERVE; 90 91 currStep=0; 91 active=false;92 92 } 93 93 { -
molecuilder/src/Actions/Process.hpp
rdc5413 r78b9d9 19 19 #include "Actions/Action.hpp" 20 20 21 /** 22 * A Process is an Action that might take some time and therefore has special 23 * methods to allow communication with progress indicators. Indicators 24 * can sign on at a global place and will be notified when any process is doing 25 * a calculation. 26 * 27 * A Process has four states: 28 * - starting: It is in the process of setting itself up, and wants everybody to know that it will start 29 * the calculation soon. Indicators should set up anything they need for displaying the progress 30 * when they are notified by a process in this state. 31 * - active: The process is currently doing it's thing and wants any indicator to know it's status, i.e. 32 * the percentage done. 33 * - stopping: The process has fullfilled it's purpose and is shutting down. Indicators recieving this status 34 * should also use it to shut down their indication mechanism and delete any objects allocated for 35 * this Process 36 * - inactive: This Process is currently sleeping. If a Process is sending out any signals in this state, there 37 * is something seriously wrong. 38 */ 21 39 class Process : public Action, public Observable 22 40 {
Note:
See TracChangeset
for help on using the changeset viewer.