Line data Source code
1 : //# Algorithm.h: defines base class Algorithm, a parallel computational unit 2 : //# Copyright (C) 1999,2000 3 : //# Associated Universities, Inc. Washington DC, USA. 4 : //# 5 : //# This library is free software; you can redistribute it and/or modify it 6 : //# under the terms of the GNU Library General Public License as published by 7 : //# the Free Software Foundation; either version 2 of the License, or (at your 8 : //# option) any later version. 9 : //# 10 : //# This library is distributed in the hope that it will be useful, but WITHOUT 11 : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 : //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 13 : //# License for more details. 14 : //# 15 : //# You should have received a copy of the GNU Library General Public License 16 : //# along with this library; if not, write to the Free Software Foundation, 17 : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 18 : //# 19 : //# Correspondence concerning AIPS++ should be addressed as follows: 20 : //# Internet email: casa-feedback@nrao.edu. 21 : //# Postal address: AIPS++ Project Office 22 : //# National Radio Astronomy Observatory 23 : //# 520 Edgemont Road 24 : //# Charlottesville, VA 22903-2475 USA 25 : //# 26 : //# 27 : //# $Id$ 28 : //#! ======================================================================== 29 : 30 : #ifndef SYNTHESIS_ALGORITHM_H 31 : #define SYNTHESIS_ALGORITHM_H 32 : 33 : //# Includes 34 : #include <synthesis/Parallel/Applicator.h> 35 : 36 : namespace casacore{ 37 : 38 : class String; 39 : } 40 : 41 : namespace casa { //# NAMESPACE CASA - BEGIN 42 : 43 : //# Forward Declarations 44 : 45 : extern Applicator applicator; 46 : 47 : // <summary> 48 : // Defines a computational unit for parallel processing 49 : // </summary> 50 : 51 : // <use visibility=local> or <use visibility=export> 52 : 53 : // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 54 : // </reviewed> 55 : 56 : // <prerequisite> 57 : // <li> SomeClass 58 : // <li> SomeOtherClass 59 : // <li> some concept 60 : // </prerequisite> 61 : // 62 : // <etymology> 63 : // </etymology> 64 : // 65 : // <synopsis> 66 : // Base class used to define a computational unit for parallel processing. 67 : // The user supplies: i) the get() (fetch the data); ii) the task() (do 68 : // the work); iii) the put() (send the results back); and iv) the name() 69 : // (name of the task). 70 : // </synopsis> 71 : // 72 : // <example> 73 : // </example> 74 : // 75 : // <motivation> 76 : // The algorithm class is used for embarassingly- or nearly-embarassingly 77 : // types of parallel problems. 78 : // </motivation> 79 : // 80 : // 81 : // <todo asof="1999/05/27"> 82 : // <li> Document document document. 83 : // </todo> 84 : 85 : // 86 : // Base class. User always derives off this class 87 : // 88 : class Algorithm { 89 : public: 90 : // Default constructor and destructor 91 0 : Algorithm() {} 92 0 : virtual ~Algorithm(){} 93 : 94 : // Generic apply to execute the parallel task 95 0 : void apply() { get(); // Get the input from the controller 96 0 : task(); // Do the work 97 0 : applicator.done(); // Signal that the work is done 98 0 : put(); // Return results to the controller 99 0 : }; 100 : 101 : // Get the input data and parameters from the controller 102 : virtual void get() = 0; 103 : 104 : // Return the results to the controller 105 : virtual void put() = 0; 106 : 107 : // Return the name of the algorithm 108 : virtual casacore::String &name() = 0; 109 : 110 : protected: 111 : // Do the work assigned as a parallel task 112 : virtual void task() = 0; 113 : }; 114 : 115 : 116 : } //# NAMESPACE CASA - END 117 : 118 : #endif 119 : 120 : 121 : 122 : 123 :