casacore
|
#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... | |
Static Public Member Functions inherited from casacore::Aipsrc | |
static Bool | find (String &value, const String &keyword) |
static Bool | findNoHome (String &value, const String &keyword) |
static Bool | find (uInt &value, const String &keyword, Int Nname, const String tname[]) |
These finds check a (possible) value of the keyword against a list of coded values provided, and return an index into the list (N if not found). More... | |
static Bool | find (uInt &value, const String &keyword, const Vector< String > &tname) |
static Bool | find (String &value, const String &keyword, const String &deflt) |
This find usually saves you some lines of code, since you can supply the default you want to use when no such keyword is defined. More... | |
static Bool | findNoHome (String &value, const String &keyword, const String &deflt) |
static Bool | find (uInt &value, const String &keyword, Int Nname, const String tname[], const String &deflt) |
static Bool | find (uInt &value, const String &keyword, const Vector< String > &tname, const String &deflt) |
static Bool | findDir (String &foundDir, const String &lastPart="", const Vector< String > &prepends=Vector< String >(), const Vector< String > &appends=Vector< String >(), Bool useStds=True) |
Sets foundDir to the first /firstPart/lastPart path that it finds present on the system, where /firstPart comes from, in order, this list: contents of prepends. More... | |
static uInt | registerRC (const String &keyword, const String &deflt) |
Functions to register keywords for later use in get() and set(). More... | |
static uInt | registerRC (const String &keyword, Int Nname, const String tname[], const String &deflt) |
static uInt | registerRC (const String &keyword, const Vector< String > &tname, const String &deflt) |
static const String & | get (uInt keyword) |
Gets are like find, but using registered integers rather than names. More... | |
static const uInt & | get (uInt &code, uInt keyword) |
get for code More... | |
static void | set (uInt keyword, const String &deflt) |
Sets allow registered values to be set. More... | |
static void | set (uInt keyword, Int Nname, const String tname[], const String &deflt) |
static void | set (uInt keyword, const Vector< String > &tname, const String &deflt) |
static void | save (uInt keyword) |
Save a registered keyword value to $HOME/.aipsrc More... | |
static void | save (uInt keyword, const String tname[]) |
static void | save (uInt keyword, const Vector< String > &tname) |
static void | setAipsPath (const String &path=String()) |
Set an AIPSPATH that should be used in stead of a global AIPSPATH. More... | |
static const String & | aipsRoot () |
Returns the appropriate Casacore or system variable values. More... | |
static const String & | aipsArch () |
static const String & | aipsSite () |
static const String & | aipsHost () |
static const String & | aipsHome () |
Returns: ~/aips++ More... | |
static void | reRead () |
The reRead() function will reinitialise the static maps and read the aipsrc files again. More... | |
static Double | lastRead () |
static const Block< String > & | values () |
The following functions return the full lists of available data. More... | |
static const Block< String > & | patterns () |
static void | show (ostream &oStream) |
The following show() function, useful for debugging, outputs all keyword/value pairs found. More... | |
static void | show () |
Prints all info on cout. More... | |
static uInt | genRestore (Vector< String > &namlst, Vector< String > &vallst, const String &fileList) |
The following set is a general set of functions. More... | |
static void | genSave (Vector< String > &namlst, Vector< String > &vallst, const String &fnam) |
Save the names/values in file. More... | |
static void | genSet (Vector< String > &namlst, Vector< String > &vallst, const String &nam, const String &val) |
Set (new or overwrite) keyword/value pair. More... | |
static Bool | genUnSet (Vector< String > &namlst, Vector< String > &vallst, const String &nam) |
Remove a keyword from list (False if not in list) More... | |
static Bool | genGet (String &val, Vector< String > &namlst, Vector< String > &vallst, const String &nam) |
Get the value of a keyword. 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< String > | ntlst |
Static Private Attributes | |
static AipsrcValue | myp_p |
The global AipsrcValue object. More... | |
static std::mutex | theirMutex |
Additional Inherited Members | |
Static Protected Member Functions inherited from casacore::Aipsrc | |
static Bool | find (String &value, const String &keyword, uInt start) |
Actual find function. More... | |
static Bool | findNoParse (String &value, const String &keyword, uInt start) |
Actual find function to use during parse() without recursing into parse() More... | |
static uInt | registerRC (const String &keyword, Block< String > &nlst) |
The registration function. More... | |
static void | save (const String keyword, const String val) |
Actual saving. More... | |
Class to read values from the Aipsrc general resource files
Public interface
A class for getting values from the Aipsrc files
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:
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:
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.
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.
A more convenient way of accomplishing the same result is:
or even:
Here the final argument is the default to use if the keyword is not found at all.
>>
defined. Programs need a way to interact with the AipsrcValue files.
Definition at line 159 of file AipsrcValue.h.
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;
casacore::AipsrcValue< T >::~AipsrcValue | ( | ) |
See note with constructor.
|
private |
Bool casacore::AipsrcValue< String >::find | ( | String & | value, |
const String & | keyword, | ||
const Unit & | defun, | ||
const Unit & | resun | ||
) |
|
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.
|
static |
|
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).
|
static |
|
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().
|
private |
Copy constructor (not implemented)
|
static |
|
static |
|
static |
Save registered value to $HOME/.aipsrc
|
static |
Sets allow registered values to be set.
|
staticprivate |
The global AipsrcValue object.
Definition at line 224 of file AipsrcValue.h.
|
private |
Definition at line 229 of file AipsrcValue.h.
|
staticprivate |
Definition at line 225 of file AipsrcValue.h.
|
private |
Register list.
Definition at line 228 of file AipsrcValue.h.