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