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> class AipsrcVector : public Aipsrc {
86
87public:
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,
95 const Vector<T> &deflt);
96 // </group>
97 // These <src>find()</src> functions will, given a keyword, read the values
98 // of a matched keyword as a Quantity. If no unit has been given in the
99 // keyword value, the defun Unit will be assumed. The value returned
100 // will be converted to the resun Unit. If no match found, the default
101 // value is returned (see example above).
102 // <group>
103 static Bool find(Vector<T> &value, const String &keyword,
104 const Unit &defun, const Unit &resun);
105 static Bool find(Vector<T> &value, const String &keyword,
106 const Unit &defun, const Unit &resun,
107 const Vector<T> &deflt);
108 // </group>
109 // Functions to register keywords for later use in get() and set(). The
110 // returned value is the index for get() and set().
111 // <group>
112 static uInt registerRC(const String &keyword,
113 const Vector<T> &deflt);
114 static uInt registerRC(const String &keyword,
115 const Unit &defun, const Unit &resun,
116 const Vector<T> &deflt);
117 // </group>
118
119 // Gets are like find, but using registered integers rather than names.
120 // <group>
121 static const Vector<T> get(uInt keyword);
122 // </group>
123
124 // Sets allow registered values to be set
125 // <group>
126 static void set(uInt keyword, const Vector<T> &deflt);
127 // </group>
128
129 // Save registered value to <src>$HOME/.aipsrc</src>
130 static void save(uInt keyword);
131
132private:
133 //# Data
134 inline static std::mutex theirMutex;
135 // register list
136 // <group>
137 inline static std::vector<Vector<T> > tlst;
138 inline static std::vector<String> ntlst;
139 // </group>
140};
141
142#define AipsrcVector_String AipsrcVector
143
144// <summary> Specialization of AipsrcVector for String </summary>
145
146// <synopsis>
147// <note role=warning>
148// The name <src>AipsrcVector_String</src> is only for cxx2html
149// documentation problems. Use <src>AipsrcVector</src> in your code.</note>
150// </synopsis>
151
152template <> class AipsrcVector_String<String> : public Aipsrc {
153 public:
154 static Bool find(Vector<String> &value, const String &keyword);
155 static Bool find(Vector<String> &value, const String &keyword,
156 const Vector<String> &deflt);
157 static uInt registerRC(const String &keyword, const Vector<String> &deflt);
158 static const Vector<String> get(uInt keyword);
159 static void set(uInt keyword, const Vector<String> &deflt);
160 static void save(uInt keyword);
161
162private:
163 inline static std::mutex theirMutex;
164 inline static std::vector<Vector<String> > tlst;
165 inline static std::vector<String> ntlst;
166};
167
168#undef AipsrcVector_String
169
170#define AipsrcVector_Bool AipsrcVector
171
172// <summary> Specialization of AipsrcVector for Bool </summary>
173
174// <synopsis>
175// <note role=warning>
176// The name <src>AipsrcVector_Bool</src> is only for cxx2html
177// documentation problems. Use <src>AipsrcVector</src> in your code.</note>
178// </synopsis>
179
180template <> class AipsrcVector_Bool<Bool> : public Aipsrc {
181 public:
182 static Bool find(Vector<Bool> &value, const String &keyword);
183 static Bool find(Vector<Bool> &value, const String &keyword,
184 const Vector<Bool> &deflt);
185 static uInt registerRC(const String &keyword, const Vector<Bool> &deflt);
186 static const Vector<Bool> get(uInt keyword);
187 static void set(uInt keyword, const Vector<Bool> &deflt);
188 static void save(uInt keyword);
189
190private:
191 inline static std::mutex theirMutex;
192 inline static std::vector<Vector<Bool> > tlst;
193 inline static std::vector<String> ntlst;
194};
195
196#undef AipsrcVector_Bool
197
198
199} //# NAMESPACE CASACORE - END
200
201#ifndef CASACORE_NO_AUTO_TEMPLATES
202#include <casacore/casa/System/AipsrcVector.tcc>
203#endif //# CASACORE_NO_AUTO_TEMPLATES
204#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: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
NewDelAllocator< T > NewDelAllocator< T >::value
Definition Allocator.h:368