casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RecordFieldWriter.h
Go to the documentation of this file.
1 //# RecordFieldWriter.h: Various copiers to move fields between records.
2 //# Copyright (C) 1996,2000,2001
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 #ifndef CASA_RECORDFIELDWRITER_H
30 #define CASA_RECORDFIELDWRITER_H
31 
32 #include <casacore/casa/aips.h>
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38 // <summary> Record field writer. Base class for the copiers.
39 // </summary>
40 
41 // <use visibility=local>
42 
43 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
44 // </reviewed>
45 
46 // <etymology>
47 // These classes write values to a field or fields in a record.
48 // </etymology>
49 //
50 // <synopsis>
51 // These classes are used in the ms2sdfits conversion code.
52 // It might be better if they were moved there.
53 // </synopsis>
54 //
55 // <motivation>
56 // It was useful to set up a number of copiers and invoke them as appropriate
57 // via a single function call. Some copiers may be more complicate than a
58 // direct field to field copy.
59 // </motivation>
60 //
61 // <todo asof="2001/07/10">
62 // <li> Either make this generally useful here or move them out of containers
63 // <li> fully document this
64 // </todo>
65 
67 {
68 public:
69  virtual ~RecordFieldWriter();
70  virtual void writeField() = 0;
71 };
72 
73 // <summary> Record field copier. Copies field to field as is.
74 // </summary>
75 
76 // <use visibility=local>
77 
78 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
79 // </reviewed>
80 
81 // <etymology>
82 // Copies a field from a record to another record with a field
83 // of the same type.
84 // </etymology>
85 
86 // <motivation>
87 // This type of copy can be inlined.
88 // </motivation>
89 
90 template<class outType, class inType>
92 {
93 public:
95  RecordFieldId whichOutField,
96  const RecordInterface &inRecord,
97  RecordFieldId whichInField);
98  void copy() {*out_p = outType(*in_p);}
99  virtual void writeField();
100 private:
103 };
104 
105 // <summary> Unequal shape copier.
106 // </summary>
107 
108 // <use visibility=local>
109 
110 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
111 // </reviewed>
112 
113 // <etymology>
114 // Copy fields where the two fields fields do not have the same shape,
115 // however, the number of elements must match. Copying is done element
116 // by element in vector order.
117 // </etymology>
118 //
119 // <motivation>
120 // Sometimes the shapes need to change even though the number of elements
121 // stays the same.
122 // </motivation>
123 //
124 
125 template<class T> class UnequalShapeCopier : public RecordFieldWriter
126 {
127 public:
129  RecordFieldId whichOutField,
130  const RecordInterface &inRecord,
131  RecordFieldId whichInField);
132  virtual void writeField();
133 private:
136 };
137 
138 // <summary> Multi field writer. Copy many fields with a single call.
139 // </summary>
140 
141 // <use visibility=local>
142 
143 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
144 // </reviewed>
145 
146 // <etymology>
147 // This class contains other copiers and copies multiple fields at a time.
148 // </etymology>
149 //
150 // <motivation>
151 // It was useful to set up a number of copiers and invoke them as appropriate
152 // via a single function call.
153 // </motivation>
154 //
155 
157 {
158 public:
159  void addWriter(RecordFieldWriter *fromNew);
160  void copy();
162 private:
163  // Make faster by having the RecordFieldCopiers split out so straight copying
164  // is inline.
166 };
167 
168 
169 } //# NAMESPACE CASACORE - END
170 
171 #ifndef CASACORE_NO_AUTO_TEMPLATES
172 #include <casacore/casa/Containers/RecordFieldWriter.tcc>
173 #endif //# CASACORE_NO_AUTO_TEMPLATES
174 #endif
RecordFieldPtr< Array< T > > out_p
void addWriter(RecordFieldWriter *fromNew)
Record field copier.
The identification of a record field.
Definition: RecordFieldId.h:91
RecordFieldPtr< outType > out_p
Unequal shape copier.
RecordFieldCopier(RecordInterface &outRecord, RecordFieldId whichOutField, const RecordInterface &inRecord, RecordFieldId whichInField)
RORecordFieldPtr< inType > in_p
A drop-in replacement for Block&lt;T*&gt;.
Definition: WProjectFT.h:54
PtrBlock< RecordFieldWriter * > writers_p
Make faster by having the RecordFieldCopiers split out so straight copying is inline.
virtual void writeField()=0
Record field writer. Base class for the copiers.
RORecordFieldPtr< Array< T > > in_p
Abstract base class for Record classes.
UnequalShapeCopier(RecordInterface &outRecord, RecordFieldId whichOutField, const RecordInterface &inRecord, RecordFieldId whichInField)
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42