casacore
AipsrcVector.h
Go to the documentation of this file.
1 //# AipsrcVector.h: Read multiple values from the Aipsrc resource files
2 //# Copyright (C) 1995,1996,1997,1999,2002
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 CASA_AIPSRCVECTOR_H
29 #define CASA_AIPSRCVECTOR_H
30 
31 #include <casacore/casa/aips.h>
32 #include <casacore/casa/Arrays/ArrayFwd.h>
33 #include <casacore/casa/BasicSL/String.h>
34 #include <casacore/casa/Containers/Block.h>
35 #include <casacore/casa/System/Aipsrc.h>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 //# Forward declarations
40 class Unit;
41 
42 // <summary> Read multiple values from the Aipsrc resource files </summary>
43 
44 // <use visibility=export>
45 
46 // <reviewed reviewer="mhaller" date="1997/10/08" tests="tAipsrcValue" demos="">
47 // </reviewed>
48 
49 // <prerequisite>
50 // <li> <linkto class=AipsrcValue>AipsrcValue</linkto>
51 // </prerequisite>
52 //
53 // <etymology>
54 // A class for getting multiple values from the Aipsrc files
55 // </etymology>
56 //
57 // <synopsis>
58 // The available functions (and notes) are the same as in
59 // <linkto class=AipsrcValue>AipsrcValue</linkto>, but with a Vector result.
60 // </synopsis>
61 //
62 // <templating>
63 // <li> All types with a <src>>></src> defined.
64 // <note role=warning>
65 // Since interpretation of the keyword value string is done with the standard
66 // input right-shift operator, specialisations are necessary for non-standard
67 // cases like Bool and String. They are provided.
68 // </note>
69 // </templating>
70 //
71 // <example>
72 // </example>
73 //
74 // <motivation>
75 // Programs need a way to get multi-valued keywords from the Aipsrc files.
76 // </motivation>
77 //
78 // <thrown>
79 // <li>AipsError if the environment variables HOME and/or AIPSPATH not set.
80 // </thrown>
81 //
82 // <todo asof="1997/08/07">
83 // </todo>
84 
85 template <class T> class AipsrcVector : public Aipsrc {
86 
87 public:
88  //# Constructors
89  // Default constructor
90  // See a note in <linkto class=AipsrcValue>AipsrcValue</linkto>.
92  //# Destructor
94 
95  //# Member functions
96  // The <src>find()</src> functions will, given a keyword, return the value
97  // of a matched keyword found in the files. If no match found the
98  // function will be False, and the default returned if specified.
99  // <group>
100  static Bool find(Vector<T> &value, const String &keyword);
101  static Bool find(Vector<T> &value, const String &keyword,
102  const Vector<T> &deflt);
103  // </group>
104  // These <src>find()</src> functions will, given a keyword, read the values
105  // of a matched keyword as a Quantity. If no unit has been given in the
106  // keyword value, the defun Unit will be assumed. The value returned
107  // will be converted to the resun Unit. If no match found, the default
108  // value is returned (see example above).
109  // <group>
110  static Bool find(Vector<T> &value, const String &keyword,
111  const Unit &defun, const Unit &resun);
112  static Bool find(Vector<T> &value, const String &keyword,
113  const Unit &defun, const Unit &resun,
114  const Vector<T> &deflt);
115  // </group>
116  // Functions to register keywords for later use in get() and set(). The
117  // returned value is the index for get() and set().
118  // <group>
119  static uInt registerRC(const String &keyword,
120  const Vector<T> &deflt);
121  static uInt registerRC(const String &keyword,
122  const Unit &defun, const Unit &resun,
123  const Vector<T> &deflt);
124  // </group>
125 
126  // Gets are like find, but using registered integers rather than names.
127  // <group>
128  static const Vector<T> &get(uInt keyword);
129  // </group>
130 
131  // Sets allow registered values to be set
132  // <group>
133  static void set(uInt keyword, const Vector<T> &deflt);
134  // </group>
135 
136  // Save registered value to <src>$HOME/.aipsrc</src>
137  static void save(uInt keyword);
138 
139 private:
140  //# Data
142  static std::mutex theirMutex;
143  // register list
144  // <group>
147  // </group>
148 
149  //# Constructors
150  // Copy constructor (not implemented)
152 
153  //# Copy assignment (not implemented)
155 
156  //# General member functions
157 };
158 
159 #define AipsrcVector_String AipsrcVector
160 
161 // <summary> Specialization of AipsrcVector for String </summary>
162 
163 // <synopsis>
164 // <note role=warning>
165 // The name <src>AipsrcVector_String</src> is only for cxx2html
166 // documentation problems. Use <src>AipsrcVector</src> in your code.</note>
167 // </synopsis>
168 
169 template <> class AipsrcVector_String<String> : public Aipsrc {
170  public:
173  static Bool find(Vector<String> &value, const String &keyword);
174  static Bool find(Vector<String> &value, const String &keyword,
175  const Vector<String> &deflt);
176  static uInt registerRC(const String &keyword, const Vector<String> &deflt);
177  static const Vector<String> &get(uInt keyword);
178  static void set(uInt keyword, const Vector<String> &deflt);
179  static void save(uInt keyword);
180 
181 private:
183  static std::mutex theirMutex;
189 };
190 
191 #undef AipsrcVector_String
192 
193 #define AipsrcVector_Bool AipsrcVector
194 
195 // <summary> Specialization of AipsrcVector for Bool </summary>
196 
197 // <synopsis>
198 // <note role=warning>
199 // The name <src>AipsrcVector_Bool</src> is only for cxx2html
200 // documentation problems. Use <src>AipsrcVector</src> in your code.</note>
201 // </synopsis>
202 
203 template <> class AipsrcVector_Bool<Bool> : public Aipsrc {
204  public:
207  static Bool find(Vector<Bool> &value, const String &keyword);
208  static Bool find(Vector<Bool> &value, const String &keyword,
209  const Vector<Bool> &deflt);
210  static uInt registerRC(const String &keyword, const Vector<Bool> &deflt);
211  static const Vector<Bool> &get(uInt keyword);
212  static void set(uInt keyword, const Vector<Bool> &deflt);
213  static void save(uInt keyword);
214 
215 private:
217  static std::mutex theirMutex;
223 };
224 
225 #undef AipsrcVector_Bool
226 
227 
228 } //# NAMESPACE CASACORE - END
229 
230 #ifndef CASACORE_NO_AUTO_TEMPLATES
231 #include <casacore/casa/System/AipsrcVector.tcc>
232 #endif //# CASACORE_NO_AUTO_TEMPLATES
233 #endif
#define AipsrcVector_String
Definition: AipsrcVector.h:159
#define AipsrcVector_Bool
Definition: AipsrcVector.h:193
Specialization of AipsrcVector for Bool.
Definition: AipsrcVector.h:203
static const Vector< Bool > & get(uInt keyword)
static Bool find(Vector< Bool > &value, const String &keyword, const Vector< Bool > &deflt)
static AipsrcVector_Bool myp_p
Definition: AipsrcVector.h:216
Block< Vector< Bool > > tlst
Definition: AipsrcVector.h:218
static Bool find(Vector< Bool > &value, const String &keyword)
static void save(uInt keyword)
static uInt registerRC(const String &keyword, const Vector< Bool > &deflt)
static void set(uInt keyword, const Vector< Bool > &deflt)
AipsrcVector_Bool< Bool > & operator=(const AipsrcVector_Bool< Bool > &other)
AipsrcVector_Bool(const AipsrcVector_Bool< Bool > &other)
Specialization of AipsrcVector for String.
Definition: AipsrcVector.h:169
static Bool find(Vector< String > &value, const String &keyword)
static Bool find(Vector< String > &value, const String &keyword, const Vector< String > &deflt)
static AipsrcVector_String myp_p
Definition: AipsrcVector.h:182
AipsrcVector_String(const AipsrcVector_String< String > &other)
static uInt registerRC(const String &keyword, const Vector< String > &deflt)
AipsrcVector_String< String > & operator=(const AipsrcVector_String< String > &other)
static void set(uInt keyword, const Vector< String > &deflt)
Block< Vector< String > > tlst
Definition: AipsrcVector.h:184
static void save(uInt keyword)
static const Vector< String > & get(uInt keyword)
AipsrcVector(const AipsrcVector< T > &other)
static uInt registerRC(const String &keyword, const Unit &defun, const Unit &resun, const Vector< T > &deflt)
static AipsrcVector myp_p
Definition: AipsrcVector.h:141
static Bool find(Vector< T > &value, const String &keyword, const Unit &defun, const Unit &resun)
These find() functions will, given a keyword, read the values of a matched keyword as a Quantity.
static void set(uInt keyword, const Vector< T > &deflt)
Sets allow registered values to be set.
static Bool find(Vector< T > &value, const String &keyword, const Vector< T > &deflt)
static uInt registerRC(const String &keyword, const Vector< T > &deflt)
Functions to register keywords for later use in get() and set().
static std::mutex theirMutex
Definition: AipsrcVector.h:142
AipsrcVector()
Default constructor See a note in AipsrcValue.
Block< Vector< T > > tlst
register list
Definition: AipsrcVector.h:145
Block< String > ntlst
Definition: AipsrcVector.h:146
static Bool find(Vector< T > &value, const String &keyword, const Unit &defun, const Unit &resun, const Vector< T > &deflt)
static const Vector< T > & get(uInt keyword)
Gets are like find, but using registered integers rather than names.
static void save(uInt keyword)
Save registered value to $HOME/.aipsrc
AipsrcVector< T > & operator=(const AipsrcVector< T > &other)
Copy constructor (not implemented)
static Bool find(Vector< T > &value, const String &keyword)
The find() functions will, given a keyword, return the value of a matched keyword found in the files.
simple 1-D array
Definition: Block.h:200
String: the storage and methods of handling collections of characters.
Definition: String.h:225
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.