Line data Source code
1 : // -*- C++ -*- 2 : //# AppRC.h: Definition of the AppRC class 3 : //# Copyright (C) 1997,1998,1999,2000,2001,2002,2003 4 : //# Associated Universities, Inc. Washington DC, USA. 5 : //# 6 : //# This library is free software; you can redistribute it and/or modify it 7 : //# under the terms of the GNU Library General Public License as published by 8 : //# the Free Software Foundation; either version 2 of the License, or (at your 9 : //# option) any later version. 10 : //# 11 : //# This library is distributed in the hope that it will be useful, but WITHOUT 12 : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 : //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 14 : //# License for more details. 15 : //# 16 : //# You should have received a copy of the GNU Library General Public License 17 : //# along with this library; if not, write to the Free Software Foundation, 18 : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 19 : //# 20 : //# Correspondence concerning AIPS++ should be addressed as follows: 21 : //# Internet email: aips2-request@nrao.edu. 22 : //# Postal address: AIPS++ Project Office 23 : //# National Radio Astronomy Observatory 24 : //# 520 Edgemont Road 25 : //# Charlottesville, VA 22903-2475 USA 26 : //# 27 : //# $Id$ 28 : #ifndef SYNTHESIS_APPRC_H 29 : #define SYNTHESIS_APPRC_H 30 : 31 : #include <casacore/casa/aips.h> 32 : #include <casacore/casa/System/Casarc.h> 33 : #include <sstream> 34 : #include <iostream> 35 : #include <unistd.h> 36 : 37 : using namespace std; 38 : 39 : namespace casa { //# NAMESPACE CASA - BEGIN 40 : class AppRC 41 : { 42 : public: 43 0 : AppRC() 44 0 : :rc_p(NULL), addPID_p(false), deleteFile_p(false), 45 0 : id_p() 46 0 : {init("", addPID_p, deleteFile_p);}; 47 : 48 : AppRC(const string& filename, 49 : const casacore::Bool addPID=false, 50 : const casacore::Bool deleteFile=false) 51 : :rc_p(NULL), deleteFile_p(deleteFile), id_p() 52 : {init(filename,addPID,deleteFile_p);}; 53 : 54 : ~AppRC(); 55 : 56 : ///The environment variable is assumed in MB if that is used 57 : //returns Bytes available (reason why it is a double) 58 : static casacore::Double getMemoryAvailable(string envVarName="CASA_MAX_MEMORY"); 59 : void setID(const string& id) {id_p=id;}; 60 : void init(const string& filename, const casacore::Bool addPID=false, 61 : const casacore::Bool deleteFile=true); 62 : 63 : string get(const string& name); 64 : string get(const string& name, casacore::Int& val); 65 : string get(const string& name, casacore::Float& val); 66 : string get(const string& name, casacore::Double& val); 67 : void put(const string& name, const string& val); 68 : void put(const string& name, const casacore::Int& val); 69 : void put(const string& name, const casacore::Float& val); 70 : void put(const string& name, const casacore::Double& val); 71 : 72 : private: 73 : casacore::Casarc *rc_p; 74 : casacore::CasarcCleanup rcCleanup; 75 : pid_t myPID_p /*, myTID_p*/; 76 : casacore::Bool addPID_p,deleteFile_p; 77 : string fileName_p, id_p; 78 0 : void setPID() {/*myTID_p = gettid_p ();*/ myPID_p = getpid ();} 79 : }; 80 : 81 : }; //# NAMESPACE CASA - END 82 : 83 : #endif //