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