00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef G4UIGainServer_h
00032 #define G4UIGainServer_h 1
00033
00034 #ifndef WIN32
00035
00036 #include <stdio.h>
00037 #include <sys/types.h>
00038 #include <sys/socket.h>
00039
00040 #include <netinet/in.h>
00041 #include <unistd.h>
00042
00043 #include <iostream>
00044 #include <fstream>
00045 #include "globals.hh"
00046 #include "G4UImanager.hh"
00047 #include "G4VBasicShell.hh"
00048
00049 #define SOCK_NAME "/tmp/socket"
00050 #define DEFAULT_PORT 40000;
00051
00052 enum UImode { terminal_mode , java_mode, tcl_mode };
00053 enum ChangeOfTree { notChanged=0, added, deleted, addedAndDeleted };
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 class G4UIGainServer : public G4VBasicShell {
00065 private:
00066 G4String prefix;
00067 G4String promptCharacter;
00068 G4UImanager* UI;
00069 UImode uiMode;
00070 G4String JVersion;
00071 G4String TVersion;
00072
00073
00074
00075
00076
00077 G4bool iExit;
00078 G4bool iCont;
00079
00080
00081 int socketD[3];
00082 int port;
00083 struct sockaddr_in saddr;
00084 struct sockaddr_in caddr;
00085 int len;
00086 int ret;
00087 char buf[1024];
00088
00089
00090 void GetNewTreeStructure( G4UIcommandTree*,int recursiveLevel);
00091 void GetNewTreeValues( G4UIcommandTree*,int recursiveLevel);
00092
00093 std::vector<G4String> previousTreeCommands;
00094 std::vector<G4String> newTreeCommands;
00095 std::vector<G4String> previousTreeParams;
00096 std::vector<G4String> newTreeParams;
00097 std::vector<G4UIcommand*> previousTreePCP;
00098 std::vector<G4UIcommand*> newTreePCP;
00099
00100 public:
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 G4UIsession* SessionStart();
00114 virtual void PauseSessionStart(const G4String& msg);
00115 virtual G4int ReceiveG4cout(const G4String& coutString);
00116 virtual G4int ReceiveG4cerr(const G4String& cerrString);
00117
00118 public:
00119
00120 G4UIGainServer();
00121
00122 ~G4UIGainServer();
00123
00124
00125
00126 void SessionTerminate();
00127 void Prompt(G4String);
00128 G4String GetCommand();
00129
00130 private:
00131 virtual void ExecuteCommand(const G4String& aCommand);
00132 virtual G4bool GetHelpChoice(G4int& aInt);
00133 virtual void ExitHelp() const;
00134 bool SetUPServer();
00135 void WaitingConnection();
00136 void CloseConnection();
00137
00138 void ChangeDirectory(G4String);
00139 void ListDirectory(G4String);
00140 void TerminalHelp(G4String);
00141 G4String ModifyPrefix(G4String);
00142 G4UIcommandTree * FindDirPath(G4String);
00143 void ShowCurrent(G4String);
00144 G4String GetFullPath(G4String);
00145
00146 void SendCommandProperties(G4UIcommandTree *);
00147 void SendParameterProperties(G4UIcommandTree *);
00148 void SendAParamProperty(G4UIcommand *);
00149 void SendATclParamProperty(G4UIcommand *);
00150 void CodeGenJavaTree(G4UIcommandTree *,int recursiveLevel);
00151 void CodeGenJavaParams(G4UIcommandTree *,int recursiveLevel);
00152 void CodeGenTclTree(G4UIcommandTree *, int recursiveLevel);
00153 void CodeGenTclParams(G4UIcommandTree *, int recursiveLevel);
00154 void SendDisableList(G4UIcommandTree *, int recursiveLevel);
00155
00156 void NotifyStateChange(void);
00157 void NotifyCommandUpdate(void);
00158 void NotifyParameterUpdate(G4UIcommand *);
00159
00160 int CommandUpdated(void);
00161 void UpdateState(void);
00162 void UpdateParamVal(void);
00163
00164
00165
00166 };
00167
00168 #endif
00169
00170 #endif
00171
00172