casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Algorithm.h
Go to the documentation of this file.
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: aips2-request@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
35 
36 namespace casacore{
37 
38 class String;
39 }
40 
41 namespace casa { //# NAMESPACE CASA - BEGIN
42 
43 //# Forward Declarations
44 
45 class PTransport;
46 extern Applicator applicator;
47 
48 // <summary>
49 // Defines a computational unit for parallel processing
50 // </summary>
51 
52 // <use visibility=local> or <use visibility=export>
53 
54 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
55 // </reviewed>
56 
57 // <prerequisite>
58 // <li> SomeClass
59 // <li> SomeOtherClass
60 // <li> some concept
61 // </prerequisite>
62 //
63 // <etymology>
64 // </etymology>
65 //
66 // <synopsis>
67 // Base class used to define a computational unit for parallel processing.
68 // The user supplies: i) the get() (fetch the data); ii) the task() (do
69 // the work); iii) the put() (send the results back); and iv) the name()
70 // (name of the task).
71 // </synopsis>
72 //
73 // <example>
74 // </example>
75 //
76 // <motivation>
77 // The algorithm class is used for embarassingly- or nearly-embarassingly
78 // types of parallel problems.
79 // </motivation>
80 //
81 //
82 // <todo asof="1999/05/27">
83 // <li> Document document document.
84 // </todo>
85 
86 //
87 // Base class. User always derives off this class
88 //
89 class Algorithm {
90  public:
91  // Default constructor and destructor
92  Algorithm() {}
93  virtual ~Algorithm(){}
94 
95  // Generic apply to execute the parallel task
96  void apply() { get(); // Get the input from the controller
97  task(); // Do the work
98  applicator.done(); // Signal that the work is done
99  put(); // Return results to the controller
100  };
101 
102  // Get the input data and parameters from the controller
103  virtual void get() = 0;
104 
105  // Return the results to the controller
106  virtual void put() = 0;
107 
108  // Return the name of the algorithm
109  virtual casacore::String &name() = 0;
110 
111  protected:
112  // Do the work assigned as a parallel task
113  virtual void task() = 0;
114 };
115 
116 
117 } //# NAMESPACE CASA - END
118 
119 #endif
120 
121 
122 
123 
124 
Algorithm()
Default constructor and destructor.
Definition: Algorithm.h:92
Defines a computational unit for parallel processing.
Definition: Algorithm.h:89
virtual casacore::String & name()=0
Return the name of the algorithm.
virtual ~Algorithm()
Definition: Algorithm.h:93
virtual void task()=0
Do the work assigned as a parallel task.
Applicator applicator
void done()
Signal that a worker process is done.
void apply()
Generic apply to execute the parallel task.
Definition: Algorithm.h:96
virtual void put()=0
Return the results to the controller.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42