casa
$Rev:20696$
|
00001 //# Algorithm.h: defines base class Algorithm, a parallel computational unit 00002 //# Copyright (C) 1999,2000 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# 00027 //# $Id$ 00028 //#! ======================================================================== 00029 00030 #ifndef SYNTHESIS_ALGORITHM_H 00031 #define SYNTHESIS_ALGORITHM_H 00032 00033 //# Includes 00034 #include <synthesis/Parallel/Applicator.h> 00035 00036 namespace casa { //# NAMESPACE CASA - BEGIN 00037 00038 //# Forward Declarations 00039 00040 class PTransport; 00041 class String; 00042 extern Applicator applicator; 00043 00044 // <summary> 00045 // Defines a computational unit for parallel processing 00046 // </summary> 00047 00048 // <use visibility=local> or <use visibility=export> 00049 00050 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00051 // </reviewed> 00052 00053 // <prerequisite> 00054 // <li> SomeClass 00055 // <li> SomeOtherClass 00056 // <li> some concept 00057 // </prerequisite> 00058 // 00059 // <etymology> 00060 // </etymology> 00061 // 00062 // <synopsis> 00063 // Base class used to define a computational unit for parallel processing. 00064 // The user supplies: i) the get() (fetch the data); ii) the task() (do 00065 // the work); iii) the put() (send the results back); and iv) the name() 00066 // (name of the task). 00067 // </synopsis> 00068 // 00069 // <example> 00070 // </example> 00071 // 00072 // <motivation> 00073 // The algorithm class is used for embarassingly- or nearly-embarassingly 00074 // types of parallel problems. 00075 // </motivation> 00076 // 00077 // 00078 // <todo asof="1999/05/27"> 00079 // <li> Document document document. 00080 // </todo> 00081 00082 // 00083 // Base class. User always derives off this class 00084 // 00085 class Algorithm { 00086 public: 00087 // Default constructor and destructor 00088 Algorithm() {} 00089 virtual ~Algorithm(){} 00090 00091 // Generic apply to execute the parallel task 00092 void apply() { get(); // Get the input from the controller 00093 task(); // Do the work 00094 applicator.done(); // Signal that the work is done 00095 put(); // Return results to the controller 00096 }; 00097 00098 // Get the input data and parameters from the controller 00099 virtual void get() = 0; 00100 00101 // Return the results to the controller 00102 virtual void put() = 0; 00103 00104 // Return the name of the algorithm 00105 virtual String &name() = 0; 00106 00107 protected: 00108 // Do the work assigned as a parallel task 00109 virtual void task() = 0; 00110 }; 00111 00112 00113 } //# NAMESPACE CASA - END 00114 00115 #endif 00116 00117 00118 00119 00120