casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RetypedArraySetGet.h
Go to the documentation of this file.
1 //# RetypedArraySetGet.h: Helper functions for users of RetypedArrayEngine
2 //# Copyright (C) 1994,1995,1996,1999
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 //# $Id$
27 
28 #ifndef TABLES_RETYPEDARRAYSETGET_H
29 #define TABLES_RETYPEDARRAYSETGET_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
34 
35 namespace casacore { //# NAMESPACE CASACORE - BEGIN
36 
37 //# Forward Declarations
38 class IPosition;
39 
40 
41 // <summary>
42 // Helper functions for users of RetypedArrayEngine
43 // </summary>
44 
45 // <use visibility=export>
46 
47 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="dRetypedArrayEngine.cc" demos=dRetypedArrayEngine.h>
48 // </reviewed>
49 
50 // <prerequisite>
51 //# Classes you should understand before using this one.
52 // <li> <linkto class=RetypedArrayEngine>RetypedArrayEngine</linkto>
53 // </prerequisite>
54 
55 // <synopsis>
56 // The functions in here can be used in the implementation of the
57 // CopyInfo class inside a SourceType class used by a RetypedArrayEngine.
58 // </synopsis>
59 
60 // <example>
61 // The example in RetypedArrayEngine shows how these functions can be used.
62 // </example>
63 
64 // <motivation>
65 // These functions make the implementation of the set and get
66 // functions in the SourceType objects of the RetypedArrayEngine easier.
67 // They are not part of the RetypedArrayEngine.h file to avoid
68 // the inclusion of that (heavy) file in a SourceType.
69 // </motivation>
70 
71 // <group name=RetypedArrayEngineSetGet>
72 
73 // Copy the entire target array to the source array.
74 // It will check if the shapes and sizes match.
75 // <br>
76 // This very efficient copy function can only be called by the static set
77 // function in the SourceType when the TargetType array can directly be
78 // copied to the SourceType array.
79 // <br>See
80 // <linkto class=RetypedArrayEngine>RetypedArrayEngine</linkto> for
81 // more information.
82 template<class SourceType, class TargetType>
83 void retypedArrayEngineSet (Array<SourceType>& out,
84  const Array<TargetType>& in);
85 
86 // Copy the entire source array to the target array.
87 // It will check if the shapes and sizes match.
88 // <br>
89 // This very efficient copy function can only be called by the static set
90 // function in the SourceType when the TargetType array can directly be
91 // copied to the SourceType array.
92 // <br>See
93 // <linkto class=RetypedArrayEngine>RetypedArrayEngine</linkto> for
94 // more information.
95 template<class SourceType, class TargetType>
96 void retypedArrayEngineGet (Array<TargetType>& out,
97  const Array<SourceType>& in);
98 
99 // Fill an array with SourceType objects from the target array.
100 // This is called when the target is incomplete.
101 // The shape and extra argument can help to set the correct
102 // elements in the source.
103 // <br>
104 // It loops through all elements in the SourceType array and
105 // calls the SourceType function
106 // It calls the SourceType function
107 // <srcblock>
108 // void setElem (const TargetType* data, const IPosition& shape,
109 // const void* extraArgument);
110 // </srcblock>
111 // for each element.
112 // <note role=tip>
113 // This retypedArrayEngineSet function is only a convenience function.
114 // For optimal performance it may be needed to handcode the loop instead
115 // of using this function.
116 // </note>
117 // <br>See
118 // <linkto class=RetypedArrayEngine>RetypedArrayEngine</linkto> for
119 // more information.
120 template<class SourceType, class TargetType>
121 void retypedArrayEngineSet (Array<SourceType>& out,
122  const Array<TargetType>& in,
123  const IPosition& shape,
124  const void* extraArgument);
125 
126 // Fill an array with TargetType objects from the source array.
127 // This is called when the target is incomplete.
128 // The shape and extra argument can help to get the correct
129 // elements from the source.
130 // <br>
131 // It loops through all elements in the SourceType array and
132 // calls the SourceType function
133 // <srcblock>
134 // void getElem (TargetType* data, const IPosition& shape,
135 // const void* extraArgument);
136 // </srcblock>
137 // for each element.
138 // <note role=tip>
139 // This retypedArrayEngineGet function is only a convenience function.
140 // For optimal performance it may be needed to handcode the loop instead
141 // of using this function.
142 // </note>
143 // <br>See
144 // <linkto class=RetypedArrayEngine>RetypedArrayEngine</linkto> for
145 // more information.
146 template<class SourceType, class TargetType>
147 void retypedArrayEngineGet (Array<TargetType>& out,
148  const Array<SourceType>& in,
149  const IPosition& shape,
150  const void* extraArgument);
151 
152 
153 // </group>
154 
155 
156 
157 } //# NAMESPACE CASACORE - END
158 
159 #ifndef CASACORE_NO_AUTO_TEMPLATES
160 #include <casacore/tables/DataMan/RetypedArraySetGet.tcc>
161 #endif //# CASACORE_NO_AUTO_TEMPLATES
162 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:118
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1987
A templated N-D Array class with zero origin. Array&lt;T, Alloc&gt; is a templated, N-dimensional, Array class. The origin is zero, but by default indices are zero-based. This Array class is the base class for the Vector, Matrix, and Cube subclasses.
Definition: Array.h:156