USGS

Isis 3.0 Object Programmers' Reference

Home

Application.h

Go to the documentation of this file.
00001 #if !defined(Application_h)
00002 #define Application_h
00003 
00027 #include <sys/types.h>
00028 #include <unistd.h>
00029 #include <sys/socket.h>
00030 #include <sys/un.h>
00031 
00032 #include <iostream>
00033 #include <fstream>
00034 #include <QString>
00035 #include <string>
00036 #include <ctime>
00037 #include "Pvl.h"
00038 #include "UserInterface.h"
00039 
00040 namespace Isis {
00041   class Gui;
00042   class Progress;
00043 
00079   class Application {
00080     public:
00081       Application (int argc, char *argv[]);
00082       ~Application ();
00083 
00084       int Exec(void (*funct)());
00085       PvlGroup Accounting();
00086       PvlObject History();
00087 
00088       static UserInterface &GetUserInterface();
00089       static void Log(PvlGroup &results);
00090       static void GuiLog(Pvl &results);
00091       static void GuiLog(PvlGroup &results);
00092       static void GuiLog(std::string &results);
00093       static std::string Name();
00094 
00095       void RegisterGuiHelpers(std::map<std::string,void*> helpers){ p_guiHelpers = helpers; };
00096       void* GetGuiHelper(std::string helper) { return p_guiHelpers[helper];};
00097 
00098       void GuiReportError(Isis::iException &e);
00099 
00100       void Exec(const std::string &program, const std::string &parameters);
00101 
00102       static std::string UserName();
00103       static std::string HostName();
00104       static std::string DateTime(time_t *curtime=0);
00105       
00106     private:
00107       int p_BatchlistPass;
00108       int DirectIO();
00109       int PageFaults();
00110       int ProcessSwaps();
00111 
00112       time_t p_startTime;
00113       clock_t p_startClock;
00114       std::string p_datetime;
00115       int p_startDirectIO;
00116       int p_startPageFaults;
00117       int p_startProcessSwaps;
00118 
00119       UserInterface *p_ui;  
00120 
00121       static bool HasParent ();
00122       static void SendParentData (const std::string code, const std::string &message);
00123       void SendParentErrors (Isis::PvlObject &errors);
00124 
00125       friend class Gui;
00126       void FunctionCleanup();
00127       int FunctionError(Isis::iException &e);
00128 
00129       friend class Progress;
00130       void UpdateProgress(const std::string &text, bool print);
00131       void UpdateProgress(int percent, bool print);
00132       void ProcessGuiEvents ();
00133 
00134       void ParentFork(const std::string &command, const std::string &program);
00135       void ChildFork(const std::string &command);
00136       void EstablishConnections();
00137       void WaitForCommand (int childSocket);
00138 
00139       int p_socket;
00140       static int p_childSocket;
00141       pid_t p_pid;
00142       std::string p_buffer;
00143       std::string p_socketFile;
00144       struct sockaddr_un p_socketName;
00145       std::vector<std::string> p_queue;
00146       std::map<std::string,void*> p_guiHelpers;
00147 
00148       static QString p_appName;
00149   };
00150 
00151   extern Application *iApp;
00152 };
00153 
00154 #endif