casacore
Loading...
Searching...
No Matches
AppInfo.h
Go to the documentation of this file.
1//# AppInfo.h: General information for applications
2//# Copyright (C) 1996,1997
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: casa-feedback@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#ifndef CASA_APPINFO_H
27#define CASA_APPINFO_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Arrays/ArrayFwd.h>
32#include <casacore/casa/System/AipsrcValue.h>
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36//# Forward declarations
37class String;
38
39// <summary>
40// General information for applications.
41// </summary>
42
43// <use visibility=export>
44
45// <reviewed reviewer="wbrouw" date="1997/10/30" tests="tAppInfo" demos="">
46// </reviewed>
47
48// <prerequisite>
49// <li> <linkto class=Aipsrc>Aipsrc</linkto> class
50// </prerequisite>
51//
52// <synopsis>
53// This class provides general information that an application might want to
54// know about its processing environment. This will be based either on
55// information coded into <linkto class=Aipsrc>aipsrc</linkto> variables, or
56// on information which can be obtained directly from some other source. For
57// example, the time zone will generally be obtained from the host OS, but it
58// can be overridden by an <linkto class=Aipsrc>aipsrc</linkto> variable if
59// necessary.
60//
61// Generally speaking, this class is provided to hide the details of how the
62// information is encoded into an <linkto class=Aipsrc>aipsrc</linkto> variables
63// and to avoid having to change applications if the information moves from
64// being coded into a variable to being deduced at runtime.
65//
66// It is expected that the information which is available from this class will
67// accrete with time.
68// </synopsis>
69//
70// <motivation>
71// Further encapsulate information which is usually in aipsrc variables.
72// </motivation>
73//
74// <thrown>
75// <li> AipsError if abs(timeZone()) > 0.625
76// </thrown>
77//
78// <todo asof="1997/11/11">
79// </todo>
80
81class AppInfo {
82public:
83 // Return a list of directory names into which the user may write data. If
84 // <src>minimumFreeSpace</src> is set (>0) then only directories with at
85 // least that much free space (in megabytes) are returned. If the aipsrc
86 // variable <src>user.directories.work</src> is set, the candidate
87 // directories are taken from that variable, otherwise the current working
88 // directory (".") is chosen if it exists and is writeable, otherwise /tmp
89 // is the candidate. Only one of "." and "/tmp" is chosen, not both.
90 //
91 // If no suitable directories are found (i.e., writable directories with
92 // enough free space), a zero-length vector is returned. A warning is
93 // issued to the logging system for directories which do not exist or are
94 // not writable.
95 static Vector<String> workDirectories(uInt minimumFreeSpaceInMB=0);
96
97 // Choose a workDirectory with at least <src>minimumFreeSpace</src> MB of
98 // free space available. It uses <src>workDirectories</src>. If there is
99 // more than one valid directory it arranges to choose different
100 // directories in succession in an attempt to spread out the I/O. That is,
101 // on the first call it will return directory1, on the second it will
102 // return directory2, etc. in a cyclical fashion. One can imagine more
103 // elaborate algorithms than this, however this should suffice for some
104 // time, if not forever.
105 // <thrown>
106 // <li> An <linkto class=AipsError>AipsError</linkto> is thrown if no
107 // directory with enough free space is found.
108 // </thrown>
109 static String workDirectory(uInt minimumFreeSpaceInMB=0);
110
111 // This function returns a fully qualified filename for a non-existent file
112 // in a work directory with enough free space. That is, you can create a
113 // temporary file with the name returned from this function. This function
114 // calls <src>workDirectory</src> and then appends a unique (file does not
115 // exist) filename. By default the prefix of temporary file name is
116 // <src>aipstmp_</src>, but you can override this if you choose.
117 // <thrown>
118 // <li> An <linkto class=AipsError>AipsError</linkto> is thrown if no
119 // directory with enough free space is found.
120 // </thrown>
121 static String workFileName(uInt minimumFreeSpaceInMB=0,
122 const String &filenamePrefix="aipstmp_");
123
124 // Return the local time zone offset in day fractions. This value has to be
125 // added to UTC to get local time. Generally the OS supplied value will be
126 // used, however it can be overridden with
127 // <src>system.time.tzoffset</src> if necessary.
128 static Double timeZone();
129private:
130 //# Data
132 static uInt tz_r;
133 //# Methods
134 // Force an initialization of the AppInfo values.
135 static void init();
136};
137
138//# Inlines
139
142
143
144} //# NAMESPACE CASACORE - END
145
146#endif
static const T & get(uInt keyword)
Gets are like find, but using registered integers rather than names.
static Bool need_init_p
Definition AppInfo.h:131
static Vector< String > workDirectories(uInt minimumFreeSpaceInMB=0)
Return a list of directory names into which the user may write data.
static void init()
Force an initialization of the AppInfo values.
static String workFileName(uInt minimumFreeSpaceInMB=0, const String &filenamePrefix="aipstmp_")
This function returns a fully qualified filename for a non-existent file in a work directory with eno...
static uInt tz_r
Definition AppInfo.h:132
static Double timeZone()
Return the local time zone offset in day fractions.
Definition AppInfo.h:140
static String workDirectory(uInt minimumFreeSpaceInMB=0)
Choose a workDirectory with at least minimumFreeSpace MB of free space available.
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
double Double
Definition aipstype.h:53