casacore
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
casacore::AipsrcValue< T > Class Template Reference

More...

#include <AipsrcValue.h>

Public Member Functions

 AipsrcValue ()
 Default constructor
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 tlist and ntlst data can become static, constructor and desctructor and all references to the init() method can disappear;
More...
 
 ~AipsrcValue ()
 See note with constructor. More...
 
Bool find (String &value, const String &keyword, const Unit &defun, const Unit &resun)
 

Static Public Member Functions

static Bool find (T &value, const String &keyword)
 The find() functions will, given a keyword, return the value of a matched keyword found in the files. More...
 
static Bool find (T &value, const String &keyword, const T &deflt)
 
static Bool find (T &value, const String &keyword, const Unit &defun, const Unit &resun)
 These find() functions will, given a keyword, read the value of a matched keyword as a Quantity. More...
 
static Bool find (T &value, const String &keyword, const Unit &defun, const Unit &resun, const T &deflt)
 
static uInt registerRC (const String &keyword, const T &deflt)
 Functions to register keywords for later use in get() and set(). More...
 
static uInt registerRC (const String &keyword, const Unit &defun, const Unit &resun, const T &deflt)
 
static const T & get (uInt keyword)
 Gets are like find, but using registered integers rather than names. More...
 
static void set (uInt keyword, const T &deflt)
 Sets allow registered values to be set. More...
 
static void save (uInt keyword)
 Save registered value to $HOME/.aipsrc More...
 

Private Member Functions

AipsrcValue< T > & operator= (const AipsrcValue< T > &other)
 Copy constructor (not implemented) More...
 
 AipsrcValue (const AipsrcValue< T > &other)
 

Private Attributes

Block< T > tlst
 Register list. More...
 
Block< Stringntlst
 

Static Private Attributes

static AipsrcValue myp_p
 The global AipsrcValue object. More...
 
static Mutex theirMutex
 

Detailed Description

template<class T>
class casacore::AipsrcValue< T >

Class to read values from the Aipsrc general resource files

Intended use:

Public interface

Review Status

Reviewed By:
mhaller
Date Reviewed:
1997/10/08
Test programs:
tAipsrcValue

Prerequisite

Etymology

A class for getting values from the Aipsrc files

Synopsis

The static AipsrcValue class can get typed values from the Aipsrc resource files.
The basic interaction with the class is with the static keyword match functions:

Bool AipsrcValue<Type>::find(Type &result, const String &keyword)
Bool AipsrcValue<Type>::find(Type &result, const String &keyword,
const Type &deflt)

comparable to the standard (String) Aipsrc find.
If the resource file contains a multi-valued keyword, use the AipsrcVector class instead.

The class is templated. For ease of use typedefs are provided for:

In addition to the above finds, special finds:

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)

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.

find(x, "time.offset", "h", "d");

will return:

The class has registerRC, get, set functions as described in Aipsrc. 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 Bool, where True 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 Aipsrc class for single values, and a specialisation exists for the AipsrcVector case.

Example

String tzoff; // result of keyword find
if (!AipsrcValue<Double>::find(tzoff, "time.zone.offset")) { // look for key
tzoff = -5;
};

A more convenient way of accomplishing the same result is:

AipsrcDouble::find(tzoff, "time.zone.offset", -5);

or even:

AipsrcDouble::find(tzoff, "time.zone.offset",
"h", "h", -5);

Here the final argument is the default to use if the keyword is not found at all.

Template Type Argument Requirements

Motivation

Programs need a way to interact with the AipsrcValue files.

Thrown Exceptions

Definition at line 157 of file AipsrcValue.h.

Constructor & Destructor Documentation

◆ AipsrcValue() [1/2]

template<class T >
casacore::AipsrcValue< T >::AipsrcValue ( )

Default constructor
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 tlist and ntlst data can become static, constructor and desctructor and all references to the init() method can disappear;

◆ ~AipsrcValue()

template<class T >
casacore::AipsrcValue< T >::~AipsrcValue ( )

See note with constructor.

◆ AipsrcValue() [2/2]

template<class T >
casacore::AipsrcValue< T >::AipsrcValue ( const AipsrcValue< T > &  other)
private

Member Function Documentation

◆ find() [1/5]

Bool casacore::AipsrcValue< String >::find ( String value,
const String keyword,
const Unit defun,
const Unit resun 
)

◆ find() [2/5]

template<class T >
static Bool casacore::AipsrcValue< T >::find ( T &  value,
const String keyword 
)
static

The find() 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.

◆ find() [3/5]

template<class T >
static Bool casacore::AipsrcValue< T >::find ( T &  value,
const String keyword,
const T &  deflt 
)
static

◆ find() [4/5]

template<class T >
static Bool casacore::AipsrcValue< T >::find ( T &  value,
const String keyword,
const Unit defun,
const Unit resun 
)
static

These find() 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).

◆ find() [5/5]

template<class T >
static Bool casacore::AipsrcValue< T >::find ( T &  value,
const String keyword,
const Unit defun,
const Unit resun,
const T &  deflt 
)
static

◆ get()

template<class T >
static const T& casacore::AipsrcValue< T >::get ( uInt  keyword)
static

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.

Referenced by casacore::AppInfo::timeZone().

◆ operator=()

template<class T >
AipsrcValue<T>& casacore::AipsrcValue< T >::operator= ( const AipsrcValue< T > &  other)
private

Copy constructor (not implemented)

◆ registerRC() [1/2]

template<class T >
static uInt casacore::AipsrcValue< T >::registerRC ( const String keyword,
const T &  deflt 
)
static

Functions to register keywords for later use in get() and set().

The returned value is the index for get() and set().

◆ registerRC() [2/2]

template<class T >
static uInt casacore::AipsrcValue< T >::registerRC ( const String keyword,
const Unit defun,
const Unit resun,
const T &  deflt 
)
static

◆ save()

template<class T >
static void casacore::AipsrcValue< T >::save ( uInt  keyword)
static

Save registered value to $HOME/.aipsrc

◆ set()

template<class T >
static void casacore::AipsrcValue< T >::set ( uInt  keyword,
const T &  deflt 
)
static

Sets allow registered values to be set.

Member Data Documentation

◆ myp_p

template<class T >
AipsrcValue casacore::AipsrcValue< T >::myp_p
staticprivate

The global AipsrcValue object.

Definition at line 222 of file AipsrcValue.h.

◆ ntlst

template<class T >
Block<String> casacore::AipsrcValue< T >::ntlst
private

Definition at line 227 of file AipsrcValue.h.

◆ theirMutex

template<class T >
Mutex casacore::AipsrcValue< T >::theirMutex
staticprivate

Definition at line 223 of file AipsrcValue.h.

◆ tlst

template<class T >
Block<T> casacore::AipsrcValue< T >::tlst
private

Register list.

Definition at line 226 of file AipsrcValue.h.


The documentation for this class was generated from the following files:
casacore::AipsrcBool
AipsrcValue< Bool > AipsrcBool
Definition: Aipsrc.h:47
casacore::AipsrcInt
AipsrcValue< Int > AipsrcInt
Definition: Aipsrc.h:46
casacore::AipsrcVInt
AipsrcVector< Int > AipsrcVInt
Definition: Aipsrc.h:50
casacore::AipsrcString
Aipsrc AipsrcString
Definition: Aipsrc.h:48
casacore::Double
double Double
Definition: aipstype.h:55
casacore::AipsrcValue::find
static Bool find(T &value, const String &keyword)
The find() functions will, given a keyword, return the value of a matched keyword found in the files.
casacore::AipsrcVDouble
AipsrcVector< Double > AipsrcVDouble
Definition: Aipsrc.h:49
casacore::AipsrcVBool
AipsrcVector< Bool > AipsrcVBool
Definition: Aipsrc.h:51
casacore::AipsrcVString
AipsrcVector< String > AipsrcVString
Definition: Aipsrc.h:52
casacore::Bool
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::AipsrcDouble
AipsrcValue< Double > AipsrcDouble
Definition: Aipsrc.h:42