/usr/include/casacore/casa/System/AipsrcValue.h is in casacore-dev 2.2.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | //# AipsrcValue.h: Class to read values from the Aipsrc general resource files
//# Copyright (C) 1995,1996,1997,1999,2002,2003
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: aips2-request@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
//#
//# $Id$
#ifndef CASA_AIPSRCVALUE_H
#define CASA_AIPSRCVALUE_H
#include <casacore/casa/aips.h>
#include <casacore/casa/BasicSL/String.h>
#include <casacore/casa/Containers/Block.h>
#include <casacore/casa/System/Aipsrc.h>
namespace casacore { //# NAMESPACE CASACORE - BEGIN
//# Forward declarations
class Unit;
// <summary> Class to read values from the Aipsrc general resource files
// </summary>
// <use visibility=export>
// <reviewed reviewer="mhaller" date="1997/10/08" tests="tAipsrcValue" demos="">
// </reviewed>
// <prerequisite>
// <li> <linkto class=Aipsrc>Aipsrc</linkto>
// </prerequisite>
//
// <etymology>
// A class for getting values from the Aipsrc files
// </etymology>
//
// <synopsis>
// The static AipsrcValue class can get typed values from the Aipsrc
// resource files.<br>
// The basic interaction with the class is with the static keyword match
// functions:
// <srcblock>
// Bool AipsrcValue<Type>::find(Type &result, const String &keyword)
// Bool AipsrcValue<Type>::find(Type &result, const String &keyword,
// const Type &deflt)
// </srcblock>
// comparable to the standard (String) <linkto class=Aipsrc>Aipsrc</linkto>
// find.<br>
// If the resource file contains a multi-valued keyword, use the
// <linkto class=AipsrcVector>AipsrcVector</linkto> class instead.
//
// The class is templated. For ease of use typedefs are provided for:
// <srcblock>
// AipsrcDouble, AipsrcInt, AipsrcBool, AipsrcString
// AipsrcVDouble, AipsrcVInt, AipsrcVBool, AipsrcVString
// </srcblock>
// In addition to the above finds, special finds:
// <srcblock>
// Bool AipsrcValue<Type>::find(Type &result, const String &keyword,
// const Unit &defun, const Unit &resun)
// Bool AipsrcValue<Type>::find(Type &result, const String &keyword,
// const Unit &defun, const Unit &resun,
// const Type &deflt)
// </srcblock>
// are provided. These finds will read the keyword value as a Quantity.
// If no units are given, the defun are assumed. The result is converted
// to the resun, before the value is returned. E.g.
// <srcblock>
// Double x;
// find(x, "time.offset", "h", "d");
// </srcblock>
// will return:
// <ul>
// <li> 2.5/24 for a value specified as 2.5 in resource file
// <li> 2.5/24 for 2:30:00
// <li> 0.5/24 for 30min
// <li> 0.5 for 0.5d
// </ul>
//
// The class has <src>registerRC, get, set</src> functions as described in
// <linkto class=Aipsrc>Aipsrc</linkto>. Note that registration is on a
// per Type basis, and hence registration of the same keyword in different
// types (and possible sets) act on different values, but with the same
// result if no set has been done.
//
// Specialisation exists for <src>Bool</src>, where <src>True</src> is
// any value string starting with one of 'yYtT123456789', and False in
// all other cases, and no finds with Units are provided. Strings are
// supposed to be handled by standard <linkto class=Aipsrc>Aipsrc</linkto>
// class for single values, and a specialisation exists for the
// <linkto class=AipsrcVector>AipsrcVector</linkto> case.
//
// </synopsis>
//
// <example>
// <srcblock>
// String tzoff; // result of keyword find
// if (!AipsrcValue<Double>::find(tzoff, "time.zone.offset")) { // look for key
// tzoff = -5;
// };
// </srcblock>
// A more convenient way of accomplishing the same result is:
// <srcblock>
// AipsrcDouble::find(tzoff, "time.zone.offset", -5);
// </srcblock>
// or even:
// <srcblock>
// AipsrcDouble::find(tzoff, "time.zone.offset",
// "h", "h", -5);
// </srcblock>
// Here the final argument is the default to use if the keyword is not found
// at all.
// </example>
//
//
// <templating>
// <li> All types with a <src>>></src> defined.
// <note role=warning>
// Since interpretation of the keyword value string is done with the standard
// input right-shift operator, specialisations are necessary for non-standard
// cases like Bool. They are provided. String is supposed to be handled by
// standard Aipsrc.
// </note>
// </templating>
//
// <motivation>
// Programs need a way to interact with the AipsrcValue files.
// </motivation>
//
// <thrown>
// <li>AipsError if the environment variables HOME and/or AIPSPATH not set.
// </thrown>
//
// <todo asof="1997/08/07">
// </todo>
template <class T> class AipsrcValue : public Aipsrc {
public:
//# Constructors
// Default constructor
// <note role=tip>
// A constructor (and destructor) have been provided to be able to generate
// a (routine-level) static register list. This had to be done since
// static data members are not yet implemented in the gcc compiler for
// templated classes. Once they are available the <tt>tlist</tt> and
// <tt>ntlst</tt> data can become static, constructor and desctructor and
// all references to the init() method can disappear.
// </note>
AipsrcValue();
//# Destructor
// See note with constructor
~AipsrcValue();
//# Member functions
// The <src>find()</src> functions will, given a keyword, return the value
// of a matched keyword found in the files. If no match found the
// function will be False, and the default returned if specified.
// <group>
static Bool find(T &value, const String &keyword);
static Bool find(T &value, const String &keyword, const T &deflt);
// </group>
// These <src>find()</src> functions will, given a keyword, read the value
// of a matched keyword as a Quantity. If no unit has been given in the
// keyword value, the defun Unit will be assumed. The value returned
// will be converted to the resun Unit. If no match found, the default
// value is returned (see example above).
// <group>
static Bool find(T &value, const String &keyword,
const Unit &defun, const Unit &resun);
static Bool find(T &value, const String &keyword,
const Unit &defun, const Unit &resun,
const T &deflt);
// </group>
// Functions to register keywords for later use in get() and set(). The
// returned value is the index for get() and set().
// <group>
static uInt registerRC(const String &keyword,
const T &deflt);
static uInt registerRC(const String &keyword,
const Unit &defun, const Unit &resun,
const T &deflt);
// </group>
// Gets are like find, but using registered integers rather than names. The
// aipsrc file is read only once, and values can be set as well.
// <group>
static const T &get(uInt keyword);
// </group>
// Sets allow registered values to be set
// <group>
static void set(uInt keyword, const T &deflt);
// </group>
// Save registered value to <src>$HOME/.aipsrc</src>
static void save(uInt keyword);
private:
//# Data
// The global AipsrcValue object
static AipsrcValue myp_p;
static Mutex theirMutex;
// Register list
// <group>
Block<T> tlst;
Block<String> ntlst;
// </group>
//# Constructors
// Copy constructor (not implemented)
AipsrcValue<T> &operator=(const AipsrcValue<T> &other);
//# Copy assignment (not implemented)
AipsrcValue(const AipsrcValue<T> &other);
//# General member functions
};
template <>
Bool AipsrcValue<String>::find(String &value,
const String &keyword,
const Unit &defun, const Unit &resun);
#define AipsrcValue_Bool AipsrcValue
// <summary> Specialization of AipsrcValue for Bool </summary>
// <synopsis>
// <note role=warning>
// The name <src>AipsrcValue_Bool</src> is only for cxx2html
// documentation problems. Use <src>AipsrcValue</src> in your code.</note>
// </synopsis>
template <> class AipsrcValue_Bool<Bool> : public Aipsrc {
public:
AipsrcValue_Bool();
~AipsrcValue_Bool();
static Bool find(Bool &value, const String &keyword);
static Bool find(Bool &value, const String &keyword, const Bool &deflt);
static uInt registerRC(const String &keyword, const Bool &deflt);
static const Bool &get(uInt keyword);
static void set(uInt keyword, const Bool &deflt);
static void save(uInt keyword);
private:
static AipsrcValue_Bool myp_p;
static Mutex theirMutex;
Block<Bool> tlst;
Block<String> ntlst;
AipsrcValue_Bool<Bool> &operator=(const AipsrcValue_Bool<Bool> &other);
AipsrcValue_Bool(const AipsrcValue_Bool<Bool> &other);
};
#undef AipsrcValue_Bool
//# Declare extern templates for often used types.
#ifdef AIPS_CXX11
extern template class AipsrcValue<Bool>;
extern template class AipsrcValue<Int>;
extern template class AipsrcValue<Double>;
extern template class AipsrcValue<String>;
#endif
} //# NAMESPACE CASACORE - END
#ifndef CASACORE_NO_AUTO_TEMPLATES
#include <casacore/casa/System/AipsrcValue.tcc>
#endif //# CASACORE_NO_AUTO_TEMPLATES
#endif
|