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/System/Aipsrc.h>
33
34#include <mutex>
35#include <vector>
36
37namespace casacore { // # NAMESPACE CASACORE - BEGIN
38
39// # Forward declarations
40class 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
85template <class T>
86class AipsrcVector : public Aipsrc {
87 public:
88 // # Member functions
89 // The <src>find()</src> functions will, given a keyword, return the value
90 // of a matched keyword found in the files. If no match found the
91 // function will be False, and the default returned if specified.
92 // <group>
93 static Bool find(Vector<T> &value, const String &keyword);
94 static Bool find(Vector<T> &value, const String &keyword, const Vector<T> &deflt);
95 // </group>
96 // These <src>find()</src> functions will, given a keyword, read the values
97 // of a matched keyword as a Quantity. If no unit has been given in the
98 // keyword value, the defun Unit will be assumed. The value returned
99 // will be converted to the resun Unit. If no match found, the default
100 // value is returned (see example above).
101 // <group>
102 static Bool find(Vector<T> &value, const String &keyword, const Unit &defun, const Unit &resun);
103 static Bool find(Vector<T> &value, const String &keyword, const Unit &defun, const Unit &resun,
104 const Vector<T> &deflt);
105 // </group>
106 // Functions to register keywords for later use in get() and set(). The
107 // returned value is the index for get() and set().
108 // <group>
109 static uInt registerRC(const String &keyword, const Vector<T> &deflt);
110 static uInt registerRC(const String &keyword, const Unit &defun, const Unit &resun,
111 const Vector<T> &deflt);
112 // </group>
113
114 // Gets are like find, but using registered integers rather than names.
115 // <group>
116 static const Vector<T> get(uInt keyword);
117 // </group>
118
119 // Sets allow registered values to be set
120 // <group>
121 static void set(uInt keyword, const Vector<T> &deflt);
122 // </group>
123
124 // Save registered value to <src>$HOME/.aipsrc</src>
125 static void save(uInt keyword);
126
127 private:
128 // # Data
129 inline static std::mutex theirMutex;
130 // register list
131 // <group>
132 inline static std::vector<Vector<T>> tlst;
133 inline static std::vector<String> ntlst;
134 // </group>
135};
136
137#define AipsrcVector_String AipsrcVector
138
139// <summary> Specialization of AipsrcVector for String </summary>
140
141// <synopsis>
142// <note role=warning>
143// The name <src>AipsrcVector_String</src> is only for cxx2html
144// documentation problems. Use <src>AipsrcVector</src> in your code.</note>
145// </synopsis>
146
147template <>
149 public:
150 static Bool find(Vector<String> &value, const String &keyword);
151 static Bool find(Vector<String> &value, const String &keyword, const Vector<String> &deflt);
152 static uInt registerRC(const String &keyword, const Vector<String> &deflt);
153 static const Vector<String> get(uInt keyword);
154 static void set(uInt keyword, const Vector<String> &deflt);
155 static void save(uInt keyword);
156
157 private:
158 inline static std::mutex theirMutex;
159 inline static std::vector<Vector<String>> tlst;
160 inline static std::vector<String> ntlst;
161};
162
163#undef AipsrcVector_String
164
165#define AipsrcVector_Bool AipsrcVector
166
167// <summary> Specialization of AipsrcVector for Bool </summary>
168
169// <synopsis>
170// <note role=warning>
171// The name <src>AipsrcVector_Bool</src> is only for cxx2html
172// documentation problems. Use <src>AipsrcVector</src> in your code.</note>
173// </synopsis>
174
175template <>
177 public:
178 static Bool find(Vector<Bool> &value, const String &keyword);
179 static Bool find(Vector<Bool> &value, const String &keyword, const Vector<Bool> &deflt);
180 static uInt registerRC(const String &keyword, const Vector<Bool> &deflt);
181 static const Vector<Bool> get(uInt keyword);
182 static void set(uInt keyword, const Vector<Bool> &deflt);
183 static void save(uInt keyword);
184
185 private:
186 inline static std::mutex theirMutex;
187 inline static std::vector<Vector<Bool>> tlst;
188 inline static std::vector<String> ntlst;
189};
190
191#undef AipsrcVector_Bool
192
193} // namespace casacore
194
195#ifndef CASACORE_NO_AUTO_TEMPLATES
196#include <casacore/casa/System/AipsrcVector.tcc>
197#endif // # CASACORE_NO_AUTO_TEMPLATES
198#endif
#define AipsrcVector_String
#define AipsrcVector_Bool
static Bool find(Vector< Bool > &value, const String &keyword, const Vector< Bool > &deflt)
static const Vector< Bool > get(uInt keyword)
static Bool find(Vector< Bool > &value, const String &keyword)
static void save(uInt keyword)
static std::vector< String > ntlst
static std::vector< Vector< Bool > > tlst
static uInt registerRC(const String &keyword, const Vector< Bool > &deflt)
static void set(uInt keyword, const Vector< Bool > &deflt)
static std::vector< String > ntlst
static const Vector< String > get(uInt keyword)
static Bool find(Vector< String > &value, const String &keyword)
static Bool find(Vector< String > &value, const String &keyword, const Vector< String > &deflt)
static std::vector< Vector< String > > tlst
static uInt registerRC(const String &keyword, const Vector< String > &deflt)
static void set(uInt keyword, const Vector< String > &deflt)
static void save(uInt keyword)
static const Vector< T > get(uInt keyword)
Gets are like find, but using registered integers rather than names.
static std::vector< Vector< Double > > tlst
static uInt registerRC(const String &keyword, const Unit &defun, const Unit &resun, const Vector< T > &deflt)
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 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.
static std::vector< String > ntlst
String: the storage and methods of handling collections of characters.
Definition String.h:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
NewDelAllocator< T > NewDelAllocator< T >::value
Definition Allocator.h:360