G4UIExecutive.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // $Id$
00027 //
00028 // ====================================================================
00029 //   G4UIExecutive.hh
00030 //
00031 //   This class helps automatic instantiation of user session
00032 //   according to your environment variable like G4UI_USE_XXX.
00033 //
00034 //   Usage in main():
00035 //
00036 //   ...
00037 //   #include "G4UIExecutive.hh"
00038 //
00039 //   int main(int argc, char** argv)
00040 //   {
00041 //     ...
00042 //     G4UIExecutive* myapp = new G4UIExecutive(argc, argv);
00043 //     if (session->IsGUI())
00044 //       // Do any extra for a GUI session
00045 //
00046 //     myapp-> SessionStart();
00047 //     ...
00048 //     delete myapp;
00049 //     ...
00050 //
00051 // ====================================================================
00052 #ifndef G4UI_EXECUTIVE_HH
00053 #define G4UI_EXECUTIVE_HH
00054 
00055 #include "G4VUIshell.hh"
00056 #include <map>
00057 
00058 class G4UIsession;
00059 
00060 class G4UIExecutive {
00061 public:
00062   G4UIExecutive(G4int argc, char** argv, const G4String& type = "");
00063   ~G4UIExecutive();
00064 
00065   G4UIsession* GetSession() const;
00066 
00067   G4bool IsGUI() const;
00068 
00069   void SetPrompt(const G4String& prompt);
00070   void SetLsColor(TermColorIndex dirColor, TermColorIndex cmdColor);
00071 
00072   void SessionStart();
00073 
00074 private:
00075   enum SessionType { kNone, kQt, kXm, kWin32, kWt, kGag, kTcsh, kCsh };
00076   SessionType selected;
00077 
00078   G4UIsession* session;
00079   G4VUIshell* shell;
00080 
00081   G4bool isGUI;
00082 
00083   std::map<G4String, G4String> sessionMap;
00084 
00085   void SelectSessionByArg(const G4String& stype);
00086   void SelectSessionByEnv();
00087   void SelectSessionByFile(const G4String& appname);
00088   void SelectSessionByBestGuess();
00089 };
00090 
00091 // ====================================================================
00092 inline G4UIsession* G4UIExecutive::GetSession() const
00093 {
00094   return session;
00095 }
00096 
00097 inline G4bool G4UIExecutive::IsGUI() const
00098 {
00099   return isGUI;
00100 }
00101 
00102 #endif

Generated on Mon May 27 17:50:06 2013 for Geant4 by  doxygen 1.4.7