casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VBRemapper.h
Go to the documentation of this file.
1 //# VBRemapper.h: Base classes for objects that process VisBuffGroups
2 //# as fed to them by GroupProcessor.
3 //# Copyright (C) 2011
4 //# Associated Universities, Inc. Washington DC, USA.
5 //#
6 //# This library is free software; you can redistribute it and/or modify it
7 //# under the terms of the GNU Library General Public License as published by
8 //# the Free Software Foundation; either version 2 of the License, or (at your
9 //# option) any later version.
10 //#
11 //# This library is distributed in the hope that it will be useful, but WITHOUT
12 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14 //# License for more details.
15 //#
16 //# You should have received a copy of the GNU Library General Public License
17 //# along with this library; if not, write to the Free Software Foundation,
18 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
19 //#
20 //# Correspondence concerning AIPS++ should be addressed as follows:
21 //# Internet email: aips2-request@nrao.edu.
22 //# Postal address: AIPS++ Project Office
23 //# National Radio Astronomy Observatory
24 //# 520 Edgemont Road
25 //# Charlottesville, VA 22903-2475 USA
26 //#
27 
28 #ifndef MSVIS_VBREMAPPER_H
29 #define MSVIS_VBREMAPPER_H
30 
31 #include <casa/aips.h>
32 #include <casa/Arrays/Vector.h>
34 #include <map>
35 
36 namespace casa { //# NAMESPACE CASA - BEGIN
37 
38 class VisBuffer;
39 
40 //<summary>VBRemappers remap VisBuffers</summary>
41 //
42 // <use visibility=export>
43 //
44 // <reviewed reviewer="" date="" tests="" demos="">
45 
46 // <prerequisite>
47 // <li> <linkto class="VisBuffer">VisBuffer</linkto>
48 // <li> <linkto class="SubMS">SubMS</linkto>
49 // </prerequisite>
50 //
51 // <etymology>
52 // VBRemappers remap VisBuffers.
53 // </etymology>
54 //
55 // <synopsis>
56 // When selected parts of an casacore::MS are written to a new casacore::MS, it may be necessary to
57 // remap metadata indices like Field ID, DDID, ObservationID, etc..
58 // </synopsis>
59 //
60 // <example>
61 // // DDIDs 1, 4, and 7, and field ID 3 is selected. They should become 0, 1,
62 // // and 2, and 0, in the output.
63 // </example>
64 //<todo>
65 // <li>
66 //</todo>
68 {
69 public:
70  // Defaults to no remapping.
71  VBRemapper();
72 
74  std::map<casacore::Int, casacore::Int> >& inToOutMaps);
75 
77  //VBRemapper(const VBRemapper& gw) {}
78 
79  // Destructor
80  virtual ~VBRemapper() {}
81 
83  //virtual VBRemapper& operator=(const VBRemapper& gw) {}
84 
85  const std::map<VisBufferComponents::EnumType, std::map<casacore::Int, casacore::Int> >& getMaps() const
86  {
87  return inToOutMaps_p;
88  }
89 
90  void setMaps(const std::map<VisBufferComponents::EnumType, std::map<casacore::Int, casacore::Int> >& maps)
91  {
92  inToOutMaps_p = maps;
93  }
94 
95  // Remaps vb and returns its success value.
96  casacore::Bool remap(VisBuffer& vb, const casacore::Bool squawk=true) const;
97 
98 protected:
99  // Remaps col using mapper.
100  // Returns false if col has a value that is not in mapper's keys (those
101  // values are left unchanged), true otherwise.
102  casacore::Bool remapScalar(casacore::Int& colref, const std::map<casacore::Int, casacore::Int>& mapper) const;
103  casacore::Bool remapVector(casacore::Vector<casacore::Int>& col, const std::map<casacore::Int, casacore::Int>& mapper) const;
104 
105  // Set of maps from input ID to output ID, keyed by VisBufferComponent.
106  std::map<VisBufferComponents::EnumType, std::map<casacore::Int, casacore::Int> > inToOutMaps_p;
107 };
108 
109 } //# NAMESPACE CASA - END
110 
111 #endif
112 
int Int
Definition: aipstype.h:50
VBRemappers remap VisBuffers.
Definition: VBRemapper.h:67
casacore::Bool remapScalar(casacore::Int &colref, const std::map< casacore::Int, casacore::Int > &mapper) const
Remaps col using mapper.
Destructor *virtual ~VBRemapper()
Definition: VBRemapper.h:80
VBRemapper()
Defaults to no remapping.
void setMaps(const std::map< VisBufferComponents::EnumType, std::map< casacore::Int, casacore::Int > > &maps)
Definition: VBRemapper.h:90
casacore::Bool remapVector(casacore::Vector< casacore::Int > &col, const std::map< casacore::Int, casacore::Int > &mapper) const
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
std::map< VisBufferComponents::EnumType, std::map< casacore::Int, casacore::Int > > inToOutMaps_p
Set of maps from input ID to output ID, keyed by VisBufferComponent.
Definition: VBRemapper.h:106
VisBuffers encapsulate one chunk of visibility data for processing.
Definition: VisBuffer.h:153
casacore::Bool remap(VisBuffer &vb, const casacore::Bool squawk=true) const
Remaps vb and returns its success value.
*const std::map< VisBufferComponents::EnumType, std::map< casacore::Int, casacore::Int > > & getMaps() const
Definition: VBRemapper.h:85