Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

JobCEnv.h

Go to the documentation of this file.
00001 
00002 // $Id: JobCEnv.h,v 1.17 2005/06/06 15:52:19 bv Exp $
00003 //
00004 // A class which encapsulates information about the conditions (the
00005 // "environment") in which the job is running.
00006 //
00007 // messier@huhepl.harvard.edu
00009 #ifndef JOBCENV_H
00010 #define JOBCENV_H
00011 #ifndef VECTOR
00012 #include <vector>
00013 #define VECTOR
00014 #endif
00015 #ifndef STRING
00016 #include <string>
00017 #define STRING
00018 #endif
00019 #ifndef CTIME
00020 #include <ctime>
00021 #define CTIME
00022 #endif
00023 
00024 class MomNavigator;
00025 class JobController;
00026 class JobCRootEnv;
00027 
00028 class JobCEnv
00029 {
00030 public:
00031   ~JobCEnv();
00032   
00033   // Command line arguments
00034   int           GetArgc()                    const;
00035   char* const*  GetArgv()                    const;
00036   const char*   GetArgv(int i)               const;
00037   const char*   GetModuleHelpList()          const;
00038   const char*   GetMacroFile(unsigned int i) const;
00039   const char*   GetFileName(int i)           const;
00040   int           GetNfile()                   const;
00041   const char*   GetDefaultOutputFileName()   const;
00042   bool          HaveInaccessibleFile() const;
00043 
00044   // Run limits
00045   bool ContinueRun(int n)      const;
00046   bool CheckTimeLimit(int* t)  const;
00047   bool CheckRecordLimit(int n) const;
00048   
00049   // Run mode
00050   bool IsBatch() const;
00051   
00052   // Set run mode parameters
00053   int RunRootApp();
00054 
00055   static JobCEnv& Instance();
00056   static JobCEnv& Instance(int argc, char** argv);
00057 
00058   // Helper class to handle deletion of singleton
00059   struct Cleaner {
00060     void ClassIsUsed() { }; // Dummy method to keep compilers quiet
00061     ~Cleaner() {
00062       if (JobCEnv::fInstance) {
00063         delete JobCEnv::fInstance;
00064         JobCEnv::fInstance = 0;
00065       }
00066     }
00067   };
00068   friend struct Cleaner;
00069 
00070 private:
00071   JobCEnv();
00072   JobCEnv(int argc, char** argv);
00073 
00074   void AddDataFile(const char *filename);
00075   void AddMacroFile(const char *filelist);
00076   void CreateInteractiveMom();
00077   void DeleteInteractiveMom();
00078   void ProcessCommandLine(int argc, char *const *argv);
00079   void SetTimeLimit(const char* timelimit);
00080   void SetSignalHandlers();
00081   
00082   // Information from command line
00083   int                      fArgc;          // Command line argument
00084   char* const*             fArgv;          // Command line arguments
00085   const char*              fModuleHelpList;// List of modules from -H option
00086   std::vector<std::string> fDataFileList;  // Files from command line
00087   std::vector<std::string> fMacroFileList; // Macros listed on the cmd line
00088   std::string              fDfltOutFile;   // Default name for output files
00089 
00090   // Information about run limits
00091   time_t                   fTimeStart;     // Time job started
00092   double                   fTimeLimit;     // Time limit of job
00093   int                      fRecordLimit;   // Limit on number of records
00094 
00095   // Information concerning run mode
00096   bool                     fIsBatch;       // Is this a batch job?
00097 
00098   // Data needed for ROOT use
00099   JobCRootEnv*             fRootEnv;       // ROOT data
00100 
00101   // The sole instance of the class
00102   static JobCEnv* fInstance;
00103 };
00104 
00105 #endif // JOBCENV_H
00106 

Generated on Mon Feb 15 11:06:48 2010 for loon by  doxygen 1.3.9.1