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