|
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...
|
|
Class to read the casa general resource files.
Intended use:
Public interface
Review Status
- Reviewed By:
- wyoung
- Date Reviewed:
- 1996/11/25
- Test programs:
- tAipsrc
Prerequisite
Etymology
A class for getting values from the casa resource files
Synopsis
The static Aipsrc class can get information from the casa resource files. It has the same functionality as getrc (c program used for Casacore installation scripts).
In addition it acts as a central clearing house between system and software by providing functionality to obtain Casacore system parameters (like AIPSPATH elements), and the possibility of storing system wide information provided by a class for reference by other classes.
The format of a line in a resource file is:
# Line starting with an # in column 1 is a comment (as is an empty line)
keyword: value
keyword: value
The keyword (starting at first non-blank) consists in general of keyword fields separated by periods:
printer.ps.page
measures.precession.d_interval
measures.nutation.d_interval
and, by preference, in lower case (but search is case sensitive) with an _
as word-parts separator.
The keyword and value are separated by a :
. The value is the string from the first non-whitespace character after the separator to the end of the line. Interpretation of the string is in general the program's responsibility, but special find()
calls (see below) exist to aid.
Any part of the keyword string can be replaced by a wildcard *
to indicate all values with that structure (e.g. *.d_interval
would indicate in the example above both the precession and the nutation d_interval
.
A match between a keyword to be found and a keyword in the resource files will be the first match (taking wildcards into account) encountered in the search through the resource files. The resource files to be looked at can be defined in the environment variable CASARCFILES. If undefined, the resource files searched are (in the given order):
~/.casarc
~/.casa/rc
~/.aipsrc
$AIPSROOT/.aipsrc
$AIPSHOST/aipsrc
$AIPSSITE/aipsrc
$AIPSARCH/aipsrc
It is not an error for any of the aipsrc files to be absent or empty. However, it is an error if HOME has not been set: an exception will occur. AIPSPATH will in general be read from the global environment variables, but can, before any other Aipsrc
related call, be set with the setAipsPath()
call.
If AIPSPATH is not set in either way, it is set to the home directory.
The basic interaction with the class is with the static keyword match function
A set of
are available to interpret the string value found. (see AipsrcValue).
All the find
functions have the ability to set a default if there is no match, while also unit conversion is possible.
The Bool return indicates if the keyword was found, and, in the case of the interpretative finds, if an 'important' format error was found (e.g. '+12a' will be accepted as a Double, with a result of '12', since the standard double conversion in >>
will produce this result.)
Caution: The search keyword (unlike the file keyword) has no wildcards; The real name should, of course, be looked for;
To aid in other places, the following (static) methods are available to get the requested information (derived from HOME
and AIPSPATH
, computer system information and/or aipsrc keywords):
Other, numeric, system information can be found in AipsrcValue.
Given an AIPSPATH of
/epp/aips++ sun4sol_gnu epping norma
aipsSite will return
/epp/aips++/sun4sol_gnu/epping
.
The basic find above reacts with the aipsrc files available. If regular access is necessary (e.g. a lot of routines have to check independently a certain integration time limit), keywords can be registered to enable:
-
fast access with integer code, rather than string
-
ability to set values from programs if no aipsrc information given (a dynamic default)
-
update the
$HOME/.aipsrc
keyword/value list with save()
Tip: The registered value is never equal to zero, hence a zero value can be used to check if registration is done; Also, registering the same keyword twice is safe, and will produce the same value;
When saving a keyword/value pair in $HOME/.aipsrc
, the old version is saved in $HOME/.aipsrc.old
, before the keyword/value pair is prepended to the file. A limited number of edits of the same keyword is preserved only (default 5, changeable with the user.aipsrc.edit.keep
keyword.
Example
String printerPage;
printerPage = "notSet";
};
A more convenient way of accomplishing the same result is:
Here the final argument is the default to use if the keyword is not found at all.
If you often want to know, dynamically, the current 'printer.ps.page' value, you could do something like:
Motivation
Programs need a way to interact with the aipsrc files.
Thrown Exceptions
-
AipsError if the environment variables HOME and/or AIPSPATH not set.
Definition at line 219 of file Aipsrc.h.