Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4UIGainServer.hh
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4UIGainServer.hh 66892 2013-01-17 10:57:59Z gunter $
28 //
29 
30 
31 #ifndef G4UIGainServer_h
32 #define G4UIGainServer_h 1
33 
34 #ifndef WIN32
35 
36 #include <stdio.h>
37 #include <sys/types.h>
38 #include <sys/socket.h>
39 //#include <sys/un.h>
40 #include <netinet/in.h>
41 #include <unistd.h>
42 
43 #include <iostream>
44 #include <fstream>
45 #include "globals.hh"
46 #include "G4UImanager.hh"
47 #include "G4VBasicShell.hh"
48 
49 #define SOCK_NAME "/tmp/socket"
50 #define DEFAULT_PORT 40000;
51 
54 
55 // class description:
56 //
57 // This class is similar to G4UIGAG.
58 // While G4UIGAG provides direct connection to GAG via pipe,
59 // G4UIGainServer provides socket connection to remote Gain client.
60 // Gain = Geant4 adaptive interface for network
61 // Its usage is same as G4UIGAG, except that Geant4 application waits
62 // a connection from a Gain client.
63 
64 class G4UIGainServer : public G4VBasicShell {
65 private:
72 
73  // shell
74  // G4VUIshell* shell;
75 
76  // program states
79 
80  // need for socket
81  int socketD[3];
82  int port;
83  struct sockaddr_in saddr;
84  struct sockaddr_in caddr;
85  int len;
86  int ret;
87  char buf[1024];
88 
89  // --- the following are used by Notify*Update() and *Updated()
90  void GetNewTreeStructure( G4UIcommandTree*,int recursiveLevel);
91  void GetNewTreeValues( G4UIcommandTree*,int recursiveLevel);
92 
93  std::vector<G4String> previousTreeCommands;
94  std::vector<G4String> newTreeCommands;
95  std::vector<G4String> previousTreeParams;
96  std::vector<G4String> newTreeParams;
97  std::vector<G4UIcommand*> previousTreePCP;
98  std::vector<G4UIcommand*> newTreePCP;
99 
100 public:
101  // These methods are implementation of corresponding virtual methods
102  // of G4UIsession class.
103 
104  // A GainServer session "gainSession" is instantiated.
105  // G4cout stream is redirected by default to the constructed instance.
106  // Usage: G4UIsession * gainSession = new G4UIGainServer();
107  // "gainSession" is started.
108  // Usage: gainSession->SessionStart();
109  // "gainSession" is deleted.
110  // Usage: delete gainSession;
111  //
112 
114  virtual void PauseSessionStart(const G4String& msg);
115  virtual G4int ReceiveG4cout(const G4String& coutString);
116  virtual G4int ReceiveG4cerr(const G4String& cerrString);
117 
118 public:
119  // G4UIGainServer(G4VUIshell* aShell=0);
120  G4UIGainServer();
121  //G4UIGainServer(void){}
122  ~G4UIGainServer();
123  //~G4UIGainServer(void){}
124 
125  // void SetPrompt(const G4String& prompt);
126  void SessionTerminate();
127  void Prompt(G4String);
129 
130 private:
131  virtual void ExecuteCommand(const G4String& aCommand);
132  virtual G4bool GetHelpChoice(G4int& aInt);
133  virtual void ExitHelp() const;
134  bool SetUPServer();
135  void WaitingConnection();
136  void CloseConnection();
137 
139  void ListDirectory(G4String);
140  void TerminalHelp(G4String);
143  void ShowCurrent(G4String);
145 
150  void CodeGenJavaTree(G4UIcommandTree *,int recursiveLevel);
151  void CodeGenJavaParams(G4UIcommandTree *,int recursiveLevel);
152  void CodeGenTclTree(G4UIcommandTree *, int recursiveLevel);
153  void CodeGenTclParams(G4UIcommandTree *, int recursiveLevel);
154  void SendDisableList(G4UIcommandTree *, int recursiveLevel);
155 
156  void NotifyStateChange(void);
157  void NotifyCommandUpdate(void);
159 
160  int CommandUpdated(void);
161  void UpdateState(void);
162  void UpdateParamVal(void); // if param is updated,
163  // call NotifyParameterUpdate()
164 
165 
166 };
167 
168 #endif
169 
170 #endif
171 
172 
void SendDisableList(G4UIcommandTree *, int recursiveLevel)
void SendATclParamProperty(G4UIcommand *)
UImode
Definition: G4UIGAG.hh:44
virtual void PauseSessionStart(const G4String &msg)
void CodeGenJavaParams(G4UIcommandTree *, int recursiveLevel)
void Prompt(G4String)
void NotifyParameterUpdate(G4UIcommand *)
void NotifyStateChange(void)
virtual void ExecuteCommand(const G4String &aCommand)
G4UIcommandTree * FindDirPath(G4String)
void GetNewTreeStructure(G4UIcommandTree *, int recursiveLevel)
void SendAParamProperty(G4UIcommand *)
void WaitingConnection()
void CodeGenTclTree(G4UIcommandTree *, int recursiveLevel)
std::vector< G4UIcommand * > newTreePCP
G4UIsession * SessionStart()
char buf[1024]
virtual G4int ReceiveG4cout(const G4String &coutString)
void CodeGenJavaTree(G4UIcommandTree *, int recursiveLevel)
struct sockaddr_in saddr
G4String GetCommand()
virtual void ExitHelp() const
void UpdateParamVal(void)
bool G4bool
Definition: G4Types.hh:79
std::vector< G4UIcommand * > previousTreePCP
void GetNewTreeValues(G4UIcommandTree *, int recursiveLevel)
G4String promptCharacter
Definition: G4UIGAG.hh:45
void CloseConnection()
void UpdateState(void)
void ListDirectory(G4String)
G4String ModifyPrefix(G4String)
void NotifyCommandUpdate(void)
struct sockaddr_in caddr
virtual G4int ReceiveG4cerr(const G4String &cerrString)
std::vector< G4String > newTreeCommands
int CommandUpdated(void)
int G4int
Definition: G4Types.hh:78
void SendParameterProperties(G4UIcommandTree *)
void CodeGenTclParams(G4UIcommandTree *, int recursiveLevel)
void ShowCurrent(G4String)
virtual G4bool GetHelpChoice(G4int &aInt)
G4UImanager * UI
std::vector< G4String > previousTreeParams
ChangeOfTree
Definition: G4UIGAG.hh:45
void ChangeDirectory(G4String)
G4String GetFullPath(G4String)
std::vector< G4String > previousTreeCommands
void SendCommandProperties(G4UIcommandTree *)
void TerminalHelp(G4String)
std::vector< G4String > newTreeParams