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