| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|---|
| 2 | <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
|---|
| 3 | <title>G4UIGainServer.cc Source File</title>
|
|---|
| 4 | <link href="doxygen.css" rel="stylesheet" type="text/css">
|
|---|
| 5 | </head><body>
|
|---|
| 6 | <!-- Generated by Doxygen 1.3.4 -->
|
|---|
| 7 | <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a></div>
|
|---|
| 8 | <h1>G4UIGainServer.cc</h1><a href="G4UIGainServer_8cc.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">//</span>
|
|---|
| 9 | 00002 <span class="comment">// ********************************************************************</span>
|
|---|
| 10 | 00003 <span class="comment">// * License and Disclaimer *</span>
|
|---|
| 11 | 00004 <span class="comment">// * *</span>
|
|---|
| 12 | 00005 <span class="comment">// * The Geant4 software is copyright of the Copyright Holders of *</span>
|
|---|
| 13 | 00006 <span class="comment">// * the Geant4 Collaboration. It is provided under the terms and *</span>
|
|---|
| 14 | 00007 <span class="comment">// * conditions of the Geant4 Software License, included in the file *</span>
|
|---|
| 15 | 00008 <span class="comment">// * LICENSE and available at http://cern.ch/geant4/license . These *</span>
|
|---|
| 16 | 00009 <span class="comment">// * include a list of copyright holders. *</span>
|
|---|
| 17 | 00010 <span class="comment">// * *</span>
|
|---|
| 18 | 00011 <span class="comment">// * Neither the authors of this software system, nor their employing *</span>
|
|---|
| 19 | 00012 <span class="comment">// * institutes,nor the agencies providing financial support for this *</span>
|
|---|
| 20 | 00013 <span class="comment">// * work make any representation or warranty, express or implied, *</span>
|
|---|
| 21 | 00014 <span class="comment">// * regarding this software system or assume any liability for its *</span>
|
|---|
| 22 | 00015 <span class="comment">// * use. Please see the license in the file LICENSE and URL above *</span>
|
|---|
| 23 | 00016 <span class="comment">// * for the full disclaimer and the limitation of liability. *</span>
|
|---|
| 24 | 00017 <span class="comment">// * *</span>
|
|---|
| 25 | 00018 <span class="comment">// * This code implementation is the result of the scientific and *</span>
|
|---|
| 26 | 00019 <span class="comment">// * technical work of the GEANT4 collaboration. *</span>
|
|---|
| 27 | 00020 <span class="comment">// * By using, copying, modifying or distributing the software (or *</span>
|
|---|
| 28 | 00021 <span class="comment">// * any work based on the software) you agree to acknowledge its *</span>
|
|---|
| 29 | 00022 <span class="comment">// * use in resulting scientific publications, and indicate your *</span>
|
|---|
| 30 | 00023 <span class="comment">// * acceptance of all terms of the Geant4 Software license. *</span>
|
|---|
| 31 | 00024 <span class="comment">// ********************************************************************</span>
|
|---|
| 32 | 00025 <span class="comment">//</span>
|
|---|
| 33 | 00026 <span class="comment">//</span>
|
|---|
| 34 | 00027 <span class="comment">// 12/06/2002 G4UIGainServer H. MInamimoto and H. Yoshida created</span>
|
|---|
| 35 | 00028 <span class="comment">// $Id: G4UIGainServer.cc,v 1.10 2006/06/29 19:09:25 gunter Exp $</span>
|
|---|
| 36 | 00029 <span class="comment">// $Name: geant4-08-01-patch-01 $</span>
|
|---|
| 37 | 00030 <span class="comment">//</span>
|
|---|
| 38 | 00031 <span class="preprocessor">#ifndef WIN32</span>
|
|---|
| 39 | 00032 <span class="preprocessor"></span>
|
|---|
| 40 | 00033 <span class="preprocessor">#include "<a class="code" href="G4UIGainServer_8hh.html">G4UIGainServer.hh</a>"</span>
|
|---|
| 41 | 00034 <span class="preprocessor">#include <netdb.h></span>
|
|---|
| 42 | 00035
|
|---|
| 43 | 00036 <span class="preprocessor">#include <sstream></span>
|
|---|
| 44 | 00037 <span class="preprocessor">#include "G4StateManager.hh"</span>
|
|---|
| 45 | 00038 <span class="preprocessor">#include "G4UIcommandTree.hh"</span>
|
|---|
| 46 | 00039 <span class="preprocessor">#include "G4UIcommand.hh"</span>
|
|---|
| 47 | 00040 <span class="preprocessor">#include "G4UIcommandStatus.hh"</span>
|
|---|
| 48 | 00041
|
|---|
| 49 | 00042
|
|---|
| 50 | <a name="l00044"></a><a class="code" href="classG4UIGainServer.html#a4">00044</a> <a class="code" href="classG4UIGainServer.html#a4">G4UIGainServer::G4UIGainServer</a>()
|
|---|
| 51 | 00046 {
|
|---|
| 52 | 00047 <a class="code" href="classG4UIGainServer.html#r5">TVersion</a> =<span class="stringliteral">"T1.0a"</span>; <a class="code" href="classG4UIGainServer.html#r4">JVersion</a>=<span class="stringliteral">"J1.0a"</span>;
|
|---|
| 53 | 00048 <a class="code" href="classG4UIGainServer.html#r0">prefix</a> = <span class="stringliteral">"/"</span>;
|
|---|
| 54 | 00049
|
|---|
| 55 | 00050 <a class="code" href="classG4UIGainServer.html#r9">port</a> = DEFAULT_PORT;
|
|---|
| 56 | 00051 <span class="keywordflow">while</span>(<a class="code" href="classG4UIGainServer.html#d5">SetUPServer</a>() == <span class="keyword">false</span>){
|
|---|
| 57 | 00052 G4cout<<<span class="stringliteral">"can't get the port no. "</span><<<a class="code" href="classG4UIGainServer.html#r9">port</a><<<span class="stringliteral">" Now, try to get the next port "</span><<<a class="code" href="classG4UIGainServer.html#r9">port</a>+1<<G4endl;
|
|---|
| 58 | 00053 <a class="code" href="classG4UIGainServer.html#r9">port</a>++;
|
|---|
| 59 | 00054 }
|
|---|
| 60 | 00055
|
|---|
| 61 | 00056
|
|---|
| 62 | 00057 <a class="code" href="classG4UIGainServer.html#r2">UI</a>= G4UImanager::GetUIpointer();
|
|---|
| 63 | 00058 <a class="code" href="classG4UIGainServer.html#r2">UI</a>-> SetSession(<span class="keyword">this</span>);
|
|---|
| 64 | 00059 <a class="code" href="classG4UIGainServer.html#r2">UI</a>-> SetCoutDestination(<span class="keyword">this</span>);
|
|---|
| 65 | 00060
|
|---|
| 66 | 00061 G4StateManager* statM = G4StateManager::GetStateManager();
|
|---|
| 67 | 00062 <a class="code" href="classG4UIGainServer.html#r1">promptCharacter</a> = statM->GetStateString(statM->GetCurrentState());
|
|---|
| 68 | 00063 <a class="code" href="classG4UIGainServer.html#r3">uiMode</a> = <a class="code" href="G4UIGAG_8hh.html#a7a0">terminal_mode</a>;
|
|---|
| 69 | 00064
|
|---|
| 70 | 00065 <a class="code" href="classG4UIGainServer.html#r6">iExit</a>= FALSE;
|
|---|
| 71 | 00066 <a class="code" href="classG4UIGainServer.html#r7">iCont</a>= FALSE;
|
|---|
| 72 | 00067
|
|---|
| 73 | 00068 G4UIcommandTree* tree = <a class="code" href="classG4UIGainServer.html#r2">UI</a>->GetTree();
|
|---|
| 74 | 00069 <a class="code" href="classG4UIGainServer.html#d0">GetNewTreeStructure</a>(tree,0);
|
|---|
| 75 | 00070 <a class="code" href="classG4UIGainServer.html#d1">GetNewTreeValues</a>(tree,0);
|
|---|
| 76 | 00071 <a class="code" href="classG4UIGainServer.html#r15">previousTreeCommands</a> = <a class="code" href="classG4UIGainServer.html#r16">newTreeCommands</a>;
|
|---|
| 77 | 00072 <a class="code" href="classG4UIGainServer.html#r17">previousTreeParams</a> = <a class="code" href="classG4UIGainServer.html#r18">newTreeParams</a>;
|
|---|
| 78 | 00073 <a class="code" href="classG4UIGainServer.html#r19">previousTreePCP</a> = <a class="code" href="classG4UIGainServer.html#r20">newTreePCP</a>;
|
|---|
| 79 | 00074
|
|---|
| 80 | 00075 }
|
|---|
| 81 | 00076
|
|---|
| 82 | <a name="l00078"></a><a class="code" href="classG4UIGainServer.html#a5">00078</a> <a class="code" href="classG4UIGainServer.html#a5">G4UIGainServer::~G4UIGainServer</a>()
|
|---|
| 83 | 00079
|
|---|
| 84 | 00080 {
|
|---|
| 85 | 00081
|
|---|
| 86 | 00082 <span class="keywordflow">if</span>(G4UImanager::GetUIpointer()) {
|
|---|
| 87 | 00083 <a class="code" href="classG4UIGainServer.html#r2">UI</a>-> SetSession(NULL);
|
|---|
| 88 | 00084 <a class="code" href="classG4UIGainServer.html#r2">UI</a>-> SetCoutDestination(NULL);
|
|---|
| 89 | 00085 }
|
|---|
| 90 | 00086
|
|---|
| 91 | 00087 <span class="keywordflow">if</span>(G4UImanager::GetUIpointer()!=0){
|
|---|
| 92 | 00088 <a class="code" href="classG4UIGainServer.html#r2">UI</a>->SetSession(NULL);
|
|---|
| 93 | 00089 <a class="code" href="classG4UIGainServer.html#r2">UI</a>->SetCoutDestination(NULL);
|
|---|
| 94 | 00090 }
|
|---|
| 95 | 00091 }
|
|---|
| 96 | 00092
|
|---|
| 97 | 00093
|
|---|
| 98 | <a name="l00095"></a><a class="code" href="classG4UIGainServer.html#a0">00095</a> G4UIsession* <a class="code" href="classG4UIGainServer.html#a0">G4UIGainServer::SessionStart</a>()
|
|---|
| 99 | 00097 {
|
|---|
| 100 | 00098 G4String newCommand;
|
|---|
| 101 | 00099
|
|---|
| 102 | 00100 G4StateManager* statM = G4StateManager::GetStateManager();
|
|---|
| 103 | 00101 <a class="code" href="classG4UIGainServer.html#r1">promptCharacter</a> = statM->GetStateString(statM->GetCurrentState());
|
|---|
| 104 | 00102
|
|---|
| 105 | 00103 <a class="code" href="classG4UIGainServer.html#r6">iExit</a>= TRUE;
|
|---|
| 106 | 00104
|
|---|
| 107 | 00105 <a class="code" href="classG4UIGainServer.html#d6">WaitingConnection</a>();
|
|---|
| 108 | 00106 <span class="keywordflow">while</span>(<a class="code" href="classG4UIGainServer.html#r6">iExit</a>){
|
|---|
| 109 | 00107 newCommand= <a class="code" href="classG4UIGainServer.html#a8">GetCommand</a>();
|
|---|
| 110 | 00108 <a class="code" href="classG4UIGainServer.html#d2">ExecuteCommand</a>(newCommand);
|
|---|
| 111 | 00109 }
|
|---|
| 112 | 00110 <span class="keywordflow">return</span> NULL;
|
|---|
| 113 | 00111 }
|
|---|
| 114 | 00112
|
|---|
| 115 | <a name="l00114"></a><a class="code" href="classG4UIGainServer.html#a1">00114</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIGainServer.html#a1">G4UIGainServer::PauseSessionStart</a>(G4String msg)
|
|---|
| 116 | 00116 {
|
|---|
| 117 | 00117 <a class="code" href="classG4UIGainServer.html#r1">promptCharacter</a> = msg;
|
|---|
| 118 | 00118 G4cout<<<span class="stringliteral">"@@PROMPT \""</span><<<a class="code" href="classG4UIGainServer.html#r1">promptCharacter</a><<<span class="stringliteral">"\""</span><<G4endl;
|
|---|
| 119 | 00119
|
|---|
| 120 | 00120 <a class="code" href="classG4UIGainServer.html#r7">iCont</a>= TRUE;
|
|---|
| 121 | 00121
|
|---|
| 122 | 00122 G4String newCommand= <a class="code" href="classG4UIGainServer.html#a8">GetCommand</a>();
|
|---|
| 123 | 00123 <span class="keywordflow">while</span>(<a class="code" href="classG4UIGainServer.html#r7">iCont</a>){
|
|---|
| 124 | 00124 <a class="code" href="classG4UIGainServer.html#d2">ExecuteCommand</a>(newCommand);
|
|---|
| 125 | 00125 newCommand= <a class="code" href="classG4UIGainServer.html#a8">GetCommand</a>();
|
|---|
| 126 | 00126 strcpy(<a class="code" href="classG4UIGainServer.html#r14">buf</a>,<span class="stringliteral">"nowIdle"</span>);
|
|---|
| 127 | 00127 write(<a class="code" href="classG4UIGainServer.html#r8">socketD</a>[1],<a class="code" href="classG4UIGainServer.html#r14">buf</a>,strlen(<a class="code" href="classG4UIGainServer.html#r14">buf</a>));
|
|---|
| 128 | 00128 }
|
|---|
| 129 | 00129 }
|
|---|
| 130 | 00130
|
|---|
| 131 | <a name="l00132"></a><a class="code" href="classG4UIGainServer.html#d2">00132</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIGainServer.html#d2">G4UIGainServer::ExecuteCommand</a>(G4String aCommand)
|
|---|
| 132 | 00134 {
|
|---|
| 133 | 00135 <span class="keywordflow">if</span>(aCommand.length()<2) <span class="keywordflow">return</span>;
|
|---|
| 134 | 00136
|
|---|
| 135 | 00137 G4UIcommandTree* tree = <a class="code" href="classG4UIGainServer.html#r2">UI</a>->GetTree();
|
|---|
| 136 | 00138 <span class="keywordflow">if</span>(aCommand.length()<2) <span class="keywordflow">return</span>;
|
|---|
| 137 | 00139 G4int returnVal = <a class="code" href="classG4UIGainServer.html#r2">UI</a>->ApplyCommand(aCommand);
|
|---|
| 138 | 00140 G4int paramIndex = returnVal % 100;
|
|---|
| 139 | 00141 <span class="comment">// 0 - 98 : paramIndex-th parameter is invalid</span>
|
|---|
| 140 | 00142 <span class="comment">// 99 : convination of parameters is invalid</span>
|
|---|
| 141 | 00143 G4int commandStatus = returnVal - paramIndex;
|
|---|
| 142 | 00144
|
|---|
| 143 | 00145 <a class="code" href="classG4UIGainServer.html#d28">UpdateState</a>();
|
|---|
| 144 | 00146
|
|---|
| 145 | 00147 <span class="keywordflow">if</span>(<a class="code" href="classG4UIGainServer.html#r3">uiMode</a> != <a class="code" href="G4UIGAG_8hh.html#a7a0">terminal_mode</a>){
|
|---|
| 146 | 00148 <span class="keywordflow">switch</span>(commandStatus) {
|
|---|
| 147 | 00149 <span class="keywordflow">case</span> fCommandSucceeded:
|
|---|
| 148 | 00150 <a class="code" href="classG4UIGainServer.html#d0">GetNewTreeStructure</a>(tree,0);
|
|---|
| 149 | 00151 <a class="code" href="classG4UIGainServer.html#d1">GetNewTreeValues</a>(tree,0);
|
|---|
| 150 | 00152 <span class="keywordflow">if</span>(<a class="code" href="classG4UIGainServer.html#d27">CommandUpdated</a>()){
|
|---|
| 151 | 00153 <a class="code" href="classG4UIGainServer.html#d25">NotifyCommandUpdate</a>();
|
|---|
| 152 | 00154 } <span class="keywordflow">else</span>{
|
|---|
| 153 | 00155 <a class="code" href="classG4UIGainServer.html#d29">UpdateParamVal</a>();
|
|---|
| 154 | 00156 }
|
|---|
| 155 | 00157 <a class="code" href="classG4UIGainServer.html#r15">previousTreeCommands</a> = <a class="code" href="classG4UIGainServer.html#r16">newTreeCommands</a>;
|
|---|
| 156 | 00158 <a class="code" href="classG4UIGainServer.html#r17">previousTreeParams</a> = <a class="code" href="classG4UIGainServer.html#r18">newTreeParams</a>;
|
|---|
| 157 | 00159 <a class="code" href="classG4UIGainServer.html#r19">previousTreePCP</a> = <a class="code" href="classG4UIGainServer.html#r20">newTreePCP</a>;
|
|---|
| 158 | 00160 <span class="keywordflow">break</span>;
|
|---|
| 159 | 00161 <span class="keywordflow">case</span> fCommandNotFound:
|
|---|
| 160 | 00162 G4cerr << <span class="stringliteral">"@@ErrResult \" <"</span> << <a class="code" href="classG4UIGainServer.html#r2">UI</a>->SolveAlias(aCommand) << <span class="stringliteral">"> not found.\""</span> << G4endl;
|
|---|
| 161 | 00163 <span class="keywordflow">break</span>;
|
|---|
| 162 | 00164 <span class="keywordflow">case</span> fIllegalApplicationState:
|
|---|
| 163 | 00165 G4cerr << <span class="stringliteral">"@@ErrResult \"illegal application state -- command refused.\""</span> << G4endl;
|
|---|
| 164 | 00166 <span class="keywordflow">break</span>;
|
|---|
| 165 | 00167 <span class="keywordflow">case</span> fParameterOutOfRange:
|
|---|
| 166 | 00168 G4cout << <span class="stringliteral">"@@ErrResult \"Parameter Out of Range.\""</span> << G4endl;
|
|---|
| 167 | 00169 <span class="keywordflow">break</span>;
|
|---|
| 168 | 00170 <span class="keywordflow">case</span> fParameterUnreadable:
|
|---|
| 169 | 00171 G4cout << <span class="stringliteral">"@@ErrResult \"Parameter is wrong type and/or is not omittable.\""</span><<G4endl;
|
|---|
| 170 | 00172 <span class="keywordflow">break</span>;
|
|---|
| 171 | 00173 <span class="keywordflow">case</span> fParameterOutOfCandidates:
|
|---|
| 172 | 00174 G4cerr << <span class="stringliteral">"@@ErrResult \"Parameter is out of candidate.\""</span> << G4endl;
|
|---|
| 173 | 00175 <span class="keywordflow">break</span>;
|
|---|
| 174 | 00176 <span class="keywordflow">case</span> fAliasNotFound:
|
|---|
| 175 | 00177 <span class="keywordflow">default</span>:
|
|---|
| 176 | 00178 G4cerr << <span class="stringliteral">"command refused ("</span> << commandStatus << <span class="stringliteral">")"</span> << G4endl;
|
|---|
| 177 | 00179 }
|
|---|
| 178 | 00180 }
|
|---|
| 179 | 00181 }
|
|---|
| 180 | 00182
|
|---|
| 181 | <a name="l00184"></a><a class="code" href="classG4UIGainServer.html#a8">00184</a> G4String <a class="code" href="classG4UIGainServer.html#a8">G4UIGainServer::GetCommand</a>()
|
|---|
| 182 | 00186 {
|
|---|
| 183 | 00187 G4String newCommand;
|
|---|
| 184 | 00188 G4String nullString;
|
|---|
| 185 | 00189
|
|---|
| 186 | 00190 <span class="keywordflow">while</span>( 1 )
|
|---|
| 187 | 00191 {
|
|---|
| 188 | 00192 G4UIcommandTree* tree = <a class="code" href="classG4UIGainServer.html#r2">UI</a>->GetTree();
|
|---|
| 189 | 00193 <span class="keywordflow">if</span> ( <a class="code" href="classG4UIGainServer.html#r3">uiMode</a> != <a class="code" href="G4UIGAG_8hh.html#a7a0">terminal_mode</a> ){
|
|---|
| 190 | 00194 G4cout << <span class="stringliteral">"@@PROMPT \""</span> << <a class="code" href="classG4UIGainServer.html#r1">promptCharacter</a> << <span class="stringliteral">"\""</span> << G4endl;
|
|---|
| 191 | 00195 }
|
|---|
| 192 | 00196 <span class="keywordflow">if</span> ( <a class="code" href="classG4UIGainServer.html#r3">uiMode</a> != <a class="code" href="G4UIGAG_8hh.html#a7a1">java_mode</a> ){
|
|---|
| 193 | 00197 G4cout << <a class="code" href="classG4UIGainServer.html#r1">promptCharacter</a> << <span class="stringliteral">"> "</span> << G4endl;
|
|---|
| 194 | 00198 }<span class="keywordflow">else</span>{
|
|---|
| 195 | 00199 G4cout << <span class="stringliteral">"@@Ready"</span> << G4endl;
|
|---|
| 196 | 00200 }
|
|---|
| 197 | 00201
|
|---|
| 198 | 00202
|
|---|
| 199 | 00205 read(<a class="code" href="classG4UIGainServer.html#r8">socketD</a>[1],<a class="code" href="classG4UIGainServer.html#r14">buf</a>,1024);
|
|---|
| 200 | 00206 newCommand=<a class="code" href="classG4UIGainServer.html#r14">buf</a>;
|
|---|
| 201 | 00207 <span class="comment">//DEBUG cout<<"->"<<newCommand<<"<-"<<newCommand.length()<<G4endl;</span>
|
|---|
| 202 | 00208 <span class="comment">//newCommand.readLine( G4cin, FALSE );</span>
|
|---|
| 203 | 00211 <span class="comment"></span>
|
|---|
| 204 | 00212
|
|---|
| 205 | 00213
|
|---|
| 206 | 00214 <span class="keywordflow">if</span> (!G4cin.good()) { G4cin.clear(); newCommand = nullString; <a class="code" href="classG4UIGainServer.html#r6">iExit</a>=<span class="keyword">false</span>;<span class="keywordflow">break</span>;}
|
|---|
| 207 | 00215
|
|---|
| 208 | 00216 newCommand = newCommand.strip(G4String::leading);
|
|---|
| 209 | 00217 <span class="keywordflow">if</span>( newCommand.length() < 1) { <span class="keywordflow">break</span>; }
|
|---|
| 210 | 00218
|
|---|
| 211 | 00219 <span class="keywordflow">while</span>( newCommand(newCommand.length()-1) == <span class="charliteral">'_'</span> )
|
|---|
| 212 | 00220 {
|
|---|
| 213 | 00221 G4String newLine;
|
|---|
| 214 | 00222 newCommand.remove(newCommand.length()-1);
|
|---|
| 215 | 00223 newLine.readLine( G4cin );
|
|---|
| 216 | 00224 <span class="keywordflow">if</span> (!G4cin.good()) { G4cin.clear(); newCommand = nullString; <a class="code" href="classG4UIGainServer.html#r6">iExit</a>=<span class="keyword">false</span>;<span class="keywordflow">break</span>;}
|
|---|
| 217 | 00225 newCommand.append(newLine);
|
|---|
| 218 | 00226 }
|
|---|
| 219 | 00227
|
|---|
| 220 | 00228 G4String nC = newCommand.strip(G4String::leading);
|
|---|
| 221 | 00229 <span class="keywordflow">if</span>( nC.length() < 1) { <span class="keywordflow">break</span>; }
|
|---|
| 222 | 00230
|
|---|
| 223 | 00231 <span class="comment">// -------------------- nC.toUpper();</span>
|
|---|
| 224 | 00232 <span class="keywordflow">if</span>( nC == <span class="stringliteral">"@@GainmodeJAVA"</span> ) {
|
|---|
| 225 | 00233 <a class="code" href="classG4UIGainServer.html#r3">uiMode</a> = <a class="code" href="G4UIGAG_8hh.html#a7a1">java_mode</a>;
|
|---|
| 226 | 00234 G4cout << G4endl << <span class="stringliteral">"@@Version "</span> << <a class="code" href="classG4UIGainServer.html#r4">JVersion</a> << G4endl;
|
|---|
| 227 | 00235 <a class="code" href="classG4UIGainServer.html#d15">SendCommandProperties</a>(tree);
|
|---|
| 228 | 00236 <a class="code" href="classG4UIGainServer.html#d24">NotifyStateChange</a>();
|
|---|
| 229 | 00237 }
|
|---|
| 230 | 00238 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( nC == <span class="stringliteral">"@@GainmodeTcl"</span> ) {
|
|---|
| 231 | 00239 <a class="code" href="classG4UIGainServer.html#r3">uiMode</a> = <a class="code" href="G4UIGAG_8hh.html#a7a2">tcl_mode</a>;
|
|---|
| 232 | 00240 G4cout << G4endl << <span class="stringliteral">"@@Version "</span> << <a class="code" href="classG4UIGainServer.html#r5">TVersion</a> << G4endl;
|
|---|
| 233 | 00241 <a class="code" href="classG4UIGainServer.html#d15">SendCommandProperties</a>(tree);
|
|---|
| 234 | 00242 <a class="code" href="classG4UIGainServer.html#d24">NotifyStateChange</a>();
|
|---|
| 235 | 00243 }
|
|---|
| 236 | 00244 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( nC(0) == <span class="charliteral">'#'</span> )
|
|---|
| 237 | 00245 { G4cout << nC << G4endl; }
|
|---|
| 238 | 00246
|
|---|
| 239 | 00247 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( nC == <span class="stringliteral">"ls"</span> || nC(0,3) == <span class="stringliteral">"ls "</span> )
|
|---|
| 240 | 00248 { <a class="code" href="classG4UIGainServer.html#d9">ListDirectory</a>( nC ); }
|
|---|
| 241 | 00249 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( nC == <span class="stringliteral">"pwd"</span> )
|
|---|
| 242 | 00250 { G4cout << <span class="stringliteral">"Current Working Directory : "</span> << <a class="code" href="classG4UIGainServer.html#r0">prefix</a> << G4endl; }
|
|---|
| 243 | 00251 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( nC(0,2) == <span class="stringliteral">"cd"</span> || nC(0,3) == <span class="stringliteral">"cd "</span> )
|
|---|
| 244 | 00252 { <a class="code" href="classG4UIGainServer.html#d8">ChangeDirectory</a>( nC ); }
|
|---|
| 245 | 00253 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( nC == <span class="stringliteral">"help"</span> || nC(0,5) == <span class="stringliteral">"help "</span>)
|
|---|
| 246 | 00254 { <a class="code" href="classG4UIGainServer.html#d10">TerminalHelp</a>( nC ); }
|
|---|
| 247 | 00255 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( nC(0) == <span class="charliteral">'?'</span> )
|
|---|
| 248 | 00256 { <a class="code" href="classG4UIGainServer.html#d13">ShowCurrent</a>( nC ); }
|
|---|
| 249 | 00257 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( nC(0,4) == <span class="stringliteral">"hist"</span> || nC == <span class="stringliteral">"history"</span>)
|
|---|
| 250 | 00258 {
|
|---|
| 251 | 00259 G4int nh = <a class="code" href="classG4UIGainServer.html#r2">UI</a>->GetNumberOfHistory();
|
|---|
| 252 | 00260 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0;i<nh;i++)
|
|---|
| 253 | 00261 { G4cout << i << <span class="stringliteral">": "</span> << <a class="code" href="classG4UIGainServer.html#r2">UI</a>->GetPreviousCommand(i) << G4endl; }
|
|---|
| 254 | 00262 }
|
|---|
| 255 | 00263 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( nC(0) == <span class="charliteral">'!'</span> )
|
|---|
| 256 | 00264 {
|
|---|
| 257 | 00265 G4String ss = nC(1,nC.length()-1);
|
|---|
| 258 | 00266 G4int vl;
|
|---|
| 259 | 00267 <span class="keyword">const</span> <span class="keywordtype">char</span>* tt = ss;
|
|---|
| 260 | 00268 std::istringstream is((<span class="keywordtype">char</span>*)tt);
|
|---|
| 261 | 00269 is >> vl;
|
|---|
| 262 | 00270 G4int nh = <a class="code" href="classG4UIGainServer.html#r2">UI</a>->GetNumberOfHistory();
|
|---|
| 263 | 00271 <span class="keywordflow">if</span>(vl>=0 && vl<nh)
|
|---|
| 264 | 00272 {
|
|---|
| 265 | 00273 newCommand = <a class="code" href="classG4UIGainServer.html#r2">UI</a>->GetPreviousCommand(vl);
|
|---|
| 266 | 00274 G4cout << newCommand << G4endl;
|
|---|
| 267 | 00275 <span class="keywordflow">break</span>;
|
|---|
| 268 | 00276 }
|
|---|
| 269 | 00277 <span class="keywordflow">else</span>
|
|---|
| 270 | 00278 { G4cerr << <span class="stringliteral">"history "</span> << vl << <span class="stringliteral">" is not found."</span> << G4endl; }
|
|---|
| 271 | 00279 }
|
|---|
| 272 | 00280 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( nC(0,4) == <span class="stringliteral">"exit"</span> )
|
|---|
| 273 | 00281 {
|
|---|
| 274 | 00282 <span class="keywordflow">if</span>( <a class="code" href="classG4UIGainServer.html#r7">iCont</a> )
|
|---|
| 275 | 00283 {
|
|---|
| 276 | 00284 <span class="keywordflow">if</span> ( <a class="code" href="classG4UIGainServer.html#r3">uiMode</a> == <a class="code" href="G4UIGAG_8hh.html#a7a0">terminal_mode</a>){
|
|---|
| 277 | 00285 G4cerr << <span class="stringliteral">"You are now processing RUN."</span> << G4endl;
|
|---|
| 278 | 00286 G4cerr << <span class="stringliteral">"Please abrot it using \"/run/abort\" command first"</span> << G4endl;
|
|---|
| 279 | 00287 G4cerr << <span class="stringliteral">" and use \"continue\" command until the application"</span> << G4endl;
|
|---|
| 280 | 00288 G4cerr << <span class="stringliteral">" becomes to Idle."</span> << G4endl;
|
|---|
| 281 | 00289 }<span class="keywordflow">else</span>{
|
|---|
| 282 | 00290 G4cout << <span class="stringliteral">"@@ErrResult \"You are now processing RUN.\""</span> << G4endl;
|
|---|
| 283 | 00291 }
|
|---|
| 284 | 00292 }
|
|---|
| 285 | 00293 <span class="keywordflow">else</span>
|
|---|
| 286 | 00294 {
|
|---|
| 287 | 00295 close(<a class="code" href="classG4UIGainServer.html#r8">socketD</a>[1]);
|
|---|
| 288 | 00296 close(<a class="code" href="classG4UIGainServer.html#r8">socketD</a>[2]);
|
|---|
| 289 | 00297 <a class="code" href="classG4UIGainServer.html#r6">iExit</a> = <span class="keyword">false</span>;
|
|---|
| 290 | 00298 newCommand = nullString;
|
|---|
| 291 | 00299 <span class="keywordflow">break</span>;
|
|---|
| 292 | 00300 }
|
|---|
| 293 | 00301 }
|
|---|
| 294 | 00302 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( nC == <span class="stringliteral">"cont"</span> || nC == <span class="stringliteral">"continue"</span> )
|
|---|
| 295 | 00303 {
|
|---|
| 296 | 00304 <a class="code" href="classG4UIGainServer.html#r7">iCont</a> = <span class="keyword">false</span>;
|
|---|
| 297 | 00305 newCommand = nullString;
|
|---|
| 298 | 00306 <span class="keywordflow">break</span>;
|
|---|
| 299 | 00307 }
|
|---|
| 300 | 00308 <span class="keywordflow">else</span>
|
|---|
| 301 | 00309 { <span class="keywordflow">break</span>; }
|
|---|
| 302 | 00310 }
|
|---|
| 303 | 00311 <span class="keywordflow">return</span> <a class="code" href="classG4UIGainServer.html#d14">GetFullPath</a>(newCommand);
|
|---|
| 304 | 00312 }
|
|---|
| 305 | 00313
|
|---|
| 306 | <a name="l00315"></a><a class="code" href="classG4UIGainServer.html#a2">00315</a> G4int <a class="code" href="classG4UIGainServer.html#a2">G4UIGainServer::ReceiveG4cout</a>(G4String coutString)
|
|---|
| 307 | 00317 {
|
|---|
| 308 | 00318 <span class="keywordflow">if</span>(<a class="code" href="classG4UIGainServer.html#r8">socketD</a>[1]>0){
|
|---|
| 309 | 00319 write(<a class="code" href="classG4UIGainServer.html#r8">socketD</a>[1],coutString,coutString.length());
|
|---|
| 310 | 00320 }
|
|---|
| 311 | 00321 <span class="keywordflow">return</span> 0;
|
|---|
| 312 | 00322
|
|---|
| 313 | 00323
|
|---|
| 314 | 00324
|
|---|
| 315 | 00325
|
|---|
| 316 | 00326
|
|---|
| 317 | 00327
|
|---|
| 318 | 00328
|
|---|
| 319 | 00329 <span class="comment">//std::cout << coutString << std::flush;</span>
|
|---|
| 320 | 00330 <span class="comment">//return 0;</span>
|
|---|
| 321 | 00331 }
|
|---|
| 322 | 00332
|
|---|
| 323 | <a name="l00334"></a><a class="code" href="classG4UIGainServer.html#a3">00334</a> G4int <a class="code" href="classG4UIGainServer.html#a3">G4UIGainServer::ReceiveG4cerr</a>(G4String cerrString)
|
|---|
| 324 | 00336 {
|
|---|
| 325 | 00337 <span class="keywordflow">if</span>(<a class="code" href="classG4UIGainServer.html#r8">socketD</a>[2]>0){
|
|---|
| 326 | 00338 write(<a class="code" href="classG4UIGainServer.html#r8">socketD</a>[2],cerrString,cerrString.length());
|
|---|
| 327 | 00339 }
|
|---|
| 328 | 00340 <span class="keywordflow">return</span> 0;
|
|---|
| 329 | 00341
|
|---|
| 330 | 00342
|
|---|
| 331 | 00343
|
|---|
| 332 | 00344 <span class="comment">//std::cerr << cerrString << std::flush;</span>
|
|---|
| 333 | 00345 <span class="comment">//return 0;</span>
|
|---|
| 334 | 00346 }
|
|---|
| 335 | 00347
|
|---|
| 336 | <a name="l00349"></a><a class="code" href="classG4UIGainServer.html#d3">00349</a> G4bool <a class="code" href="classG4UIGainServer.html#d3">G4UIGainServer::GetHelpChoice</a>(G4int& aInt)
|
|---|
| 337 | 00351 {
|
|---|
| 338 | 00352 G4cin >> aInt;
|
|---|
| 339 | 00353 <span class="keywordflow">if</span>(!G4cin.good()){
|
|---|
| 340 | 00354 G4cin.clear();
|
|---|
| 341 | 00355 G4cin.ignore(30,<span class="charliteral">'\n'</span>);
|
|---|
| 342 | 00356 <span class="keywordflow">return</span> FALSE;
|
|---|
| 343 | 00357 }
|
|---|
| 344 | 00358 <span class="keywordflow">return</span> TRUE;
|
|---|
| 345 | 00359 }
|
|---|
| 346 | 00360
|
|---|
| 347 | <a name="l00362"></a><a class="code" href="classG4UIGainServer.html#d4">00362</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIGainServer.html#d4">G4UIGainServer::ExitHelp</a>()
|
|---|
| 348 | 00364 {
|
|---|
| 349 | 00365 <span class="keywordtype">char</span> temp[100];
|
|---|
| 350 | 00366 G4cin.getline(temp, 100);
|
|---|
| 351 | 00367 }
|
|---|
| 352 | 00368
|
|---|
| 353 | <a name="l00370"></a><a class="code" href="classG4UIGainServer.html#d5">00370</a> <span class="keywordtype">bool</span> <a class="code" href="classG4UIGainServer.html#d5">G4UIGainServer::SetUPServer</a>(){
|
|---|
| 354 | 00372
|
|---|
| 355 | 00373 <a class="code" href="classG4UIGainServer.html#r8">socketD</a>[0] = socket(AF_INET,SOCK_STREAM,0);
|
|---|
| 356 | 00374
|
|---|
| 357 | 00375 <span class="keywordflow">if</span>(<a class="code" href="classG4UIGainServer.html#r8">socketD</a>[0]<0){
|
|---|
| 358 | 00376 perror(<span class="stringliteral">"server:socket"</span>);
|
|---|
| 359 | 00377 <span class="keywordflow">return</span> (<span class="keyword">false</span>);
|
|---|
| 360 | 00378 <span class="comment">//exit(1);</span>
|
|---|
| 361 | 00379 }
|
|---|
| 362 | 00380
|
|---|
| 363 | 00381 memset( (<span class="keywordtype">char</span> *)&<a class="code" href="classG4UIGainServer.html#r10">saddr</a>,<span class="charliteral">'\0'</span>,<span class="keyword">sizeof</span>(saddr)) ;
|
|---|
| 364 | 00382
|
|---|
| 365 | 00383 saddr.sin_family = AF_INET;
|
|---|
| 366 | 00384 saddr.sin_addr.s_addr = INADDR_ANY;
|
|---|
| 367 | 00385 saddr.sin_port = htons(<a class="code" href="classG4UIGainServer.html#r9">port</a>);
|
|---|
| 368 | 00386 unlink(SOCK_NAME);
|
|---|
| 369 | 00387
|
|---|
| 370 | 00388 <span class="keywordflow">if</span>(bind(<a class="code" href="classG4UIGainServer.html#r8">socketD</a>[0] , (<span class="keyword">struct</span> sockaddr *)&saddr , <span class="keyword">sizeof</span>(saddr))<0){
|
|---|
| 371 | 00389 perror(<span class="stringliteral">"bind"</span>);
|
|---|
| 372 | 00390 <span class="keywordflow">return</span> (<span class="keyword">false</span>);
|
|---|
| 373 | 00391 <span class="comment">//exit(1);</span>
|
|---|
| 374 | 00392 }
|
|---|
| 375 | 00393 <span class="keywordflow">else</span>{ G4cout<<<span class="stringliteral">"G4GainServer waiting at "</span><<<a class="code" href="classG4UIGainServer.html#r9">port</a><<G4endl; }
|
|---|
| 376 | 00394
|
|---|
| 377 | 00395 <span class="keywordflow">if</span>(listen(<a class="code" href="classG4UIGainServer.html#r8">socketD</a>[0],1)<0){
|
|---|
| 378 | 00396 perror(<span class="stringliteral">"listen"</span>);
|
|---|
| 379 | 00397 <span class="keywordflow">return</span> (<span class="keyword">false</span>);
|
|---|
| 380 | 00398 <span class="comment">//exit(1);</span>
|
|---|
| 381 | 00399 }
|
|---|
| 382 | 00400
|
|---|
| 383 | 00401 <span class="keywordflow">return</span> (<span class="keyword">true</span>);
|
|---|
| 384 | 00402 }
|
|---|
| 385 | 00403
|
|---|
| 386 | <a name="l00405"></a><a class="code" href="classG4UIGainServer.html#d6">00405</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIGainServer.html#d6">G4UIGainServer::WaitingConnection</a>(){
|
|---|
| 387 | 00407 <a class="code" href="classG4UIGainServer.html#r12">len</a> = <span class="keyword">sizeof</span>(<a class="code" href="classG4UIGainServer.html#r11">caddr</a>);
|
|---|
| 388 | 00408
|
|---|
| 389 | 00409 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=1;i<=2;i++){
|
|---|
| 390 | 00410 <span class="preprocessor">#if defined __APPLE__ && (__GNUC__<4)</span>
|
|---|
| 391 | 00411 <span class="preprocessor"></span> <span class="keywordflow">if</span>((<a class="code" href="classG4UIGainServer.html#r8">socketD</a>[i] = accept(<a class="code" href="classG4UIGainServer.html#r8">socketD</a>[0], (<span class="keyword">struct</span> sockaddr *)&<a class="code" href="classG4UIGainServer.html#r11">caddr</a>,(<span class="keywordtype">int</span> *)&<a class="code" href="classG4UIGainServer.html#r12">len</a>))<0){
|
|---|
| 392 | 00412 <span class="preprocessor">#else</span>
|
|---|
| 393 | 00413 <span class="preprocessor"></span> <span class="keywordflow">if</span>((<a class="code" href="classG4UIGainServer.html#r8">socketD</a>[i] = accept(<a class="code" href="classG4UIGainServer.html#r8">socketD</a>[0], (<span class="keyword">struct</span> sockaddr *)&caddr,(socklen_t *)&<a class="code" href="classG4UIGainServer.html#r12">len</a>))<0){
|
|---|
| 394 | 00414 <span class="preprocessor">#endif</span>
|
|---|
| 395 | 00415 <span class="preprocessor"></span> G4cerr<<<span class="stringliteral">"accept:"</span><<i<<G4endl;
|
|---|
| 396 | 00416 exit(1);
|
|---|
| 397 | 00417 }
|
|---|
| 398 | 00418 }
|
|---|
| 399 | 00419 close(<a class="code" href="classG4UIGainServer.html#r8">socketD</a>[0]);
|
|---|
| 400 | 00420 }
|
|---|
| 401 | 00421
|
|---|
| 402 | 00423 G4String <a class="code" href="classG4UIGainServer.html#d14">G4UIGainServer::GetFullPath</a>(G4String aNewCommand){
|
|---|
| 403 | 00425 G4String newCommand = aNewCommand.strip(G4String::both);
|
|---|
| 404 | 00426 G4String tmpString;
|
|---|
| 405 | 00427 <span class="keywordflow">if</span>( newCommand(0) == <span class="charliteral">'/'</span> )
|
|---|
| 406 | 00428 { tmpString = newCommand; }
|
|---|
| 407 | 00429 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( newCommand(0,3) == <span class="stringliteral">"../"</span> )
|
|---|
| 408 | 00430 {
|
|---|
| 409 | 00431 G4String tmpPrefix = <a class="code" href="classG4UIGainServer.html#r0">prefix</a>;
|
|---|
| 410 | 00432 <span class="comment">/*G4int*/</span> <span class="keywordtype">unsigned</span> i_direc = 0;
|
|---|
| 411 | 00433 <span class="keywordflow">while</span>( i_direc < newCommand.length() )
|
|---|
| 412 | 00434 {
|
|---|
| 413 | 00435 <span class="keywordflow">if</span>( newCommand(i_direc,3) == <span class="stringliteral">"../"</span> )
|
|---|
| 414 | 00436 {
|
|---|
| 415 | 00437 i_direc += 3;
|
|---|
| 416 | 00438 prefix = <a class="code" href="classG4UIGainServer.html#d11">ModifyPrefix</a>( G4String(<span class="stringliteral">"../"</span>) );
|
|---|
| 417 | 00439 }
|
|---|
| 418 | 00440 <span class="keywordflow">else</span>
|
|---|
| 419 | 00441 { <span class="keywordflow">break</span>; }
|
|---|
| 420 | 00442 }
|
|---|
| 421 | 00443 tmpString = prefix;
|
|---|
| 422 | 00444 tmpString.append( newCommand( i_direc, newCommand.length()-i_direc ) );
|
|---|
| 423 | 00445 prefix = tmpPrefix;
|
|---|
| 424 | 00446 }
|
|---|
| 425 | 00447 <span class="keywordflow">else</span>
|
|---|
| 426 | 00448 {
|
|---|
| 427 | 00449 tmpString = <a class="code" href="classG4UIGainServer.html#r0">prefix</a>;
|
|---|
| 428 | 00450 tmpString.append( newCommand );
|
|---|
| 429 | 00451 }
|
|---|
| 430 | 00452 <span class="keywordflow">return</span> tmpString;
|
|---|
| 431 | 00453 }
|
|---|
| 432 | 00454
|
|---|
| 433 | 00456 <span class="keywordtype">void</span> <a class="code" href="classG4UIGainServer.html#a6">G4UIGainServer::SessionTerminate</a>(){
|
|---|
| 434 | 00458 G4cout<<<span class="stringliteral">"***** Terminal session end *****"</span><<G4endl;
|
|---|
| 435 | 00459 }
|
|---|
| 436 | 00460
|
|---|
| 437 | 00461
|
|---|
| 438 | 00463 <span class="keywordtype">void</span> <a class="code" href="classG4UIGainServer.html#d13">G4UIGainServer::ShowCurrent</a>(G4String newCommand){
|
|---|
| 439 | 00465 G4String theCommand = <a class="code" href="classG4UIGainServer.html#d14">GetFullPath</a>(newCommand(1,newCommand.length()-1));
|
|---|
| 440 | 00466 G4String curV = <a class="code" href="classG4UIGainServer.html#r2">UI</a>->GetCurrentValues(theCommand);
|
|---|
| 441 | 00467 <span class="keywordflow">if</span>( ! (curV.isNull()||curV(0)==<span class="charliteral">'\0'</span> ) ) {
|
|---|
| 442 | 00468 <span class="keywordflow">if</span> (<a class="code" href="classG4UIGainServer.html#r3">uiMode</a> == <a class="code" href="G4UIGAG_8hh.html#a7a0">terminal_mode</a>){
|
|---|
| 443 | 00469 G4cout << <span class="stringliteral">"Current value(s) of the parameter(s) : "</span> << curV << G4endl;
|
|---|
| 444 | 00470 }<span class="keywordflow">else</span>{
|
|---|
| 445 | 00471 G4cout << <span class="stringliteral">"@@CurrentValue "</span> << curV << G4endl;
|
|---|
| 446 | 00472 }
|
|---|
| 447 | 00473 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="classG4UIGainServer.html#r3">uiMode</a> == <a class="code" href="G4UIGAG_8hh.html#a7a0">terminal_mode</a>){
|
|---|
| 448 | 00474 G4cout << <span class="stringliteral">"Current value is not available."</span> << G4endl;
|
|---|
| 449 | 00475 } <span class="keywordflow">else</span> {
|
|---|
| 450 | 00476 G4cout << <span class="stringliteral">"@@ErrResult \"Current value is not available.\""</span> << G4endl;
|
|---|
| 451 | 00477 }
|
|---|
| 452 | 00478 }
|
|---|
| 453 | 00479
|
|---|
| 454 | 00481 <span class="keywordtype">void</span> <a class="code" href="classG4UIGainServer.html#d8">G4UIGainServer::ChangeDirectory</a>(G4String newCommand){
|
|---|
| 455 | 00483 G4String savedPrefix = <a class="code" href="classG4UIGainServer.html#r0">prefix</a>;
|
|---|
| 456 | 00484 <span class="keywordflow">if</span>( newCommand.length() <= 3 )
|
|---|
| 457 | 00485 { prefix = <span class="stringliteral">"/"</span>; }
|
|---|
| 458 | 00486 <span class="keywordflow">else</span>
|
|---|
| 459 | 00487 {
|
|---|
| 460 | 00488 G4String aNewPrefix = newCommand(3,newCommand.length()-3);
|
|---|
| 461 | 00489 G4String newPrefix = aNewPrefix.strip(G4String::both);
|
|---|
| 462 | 00490 <span class="keywordflow">if</span>( newPrefix(0) == <span class="charliteral">'/'</span> )
|
|---|
| 463 | 00491 { prefix = newPrefix; }
|
|---|
| 464 | 00492 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( newPrefix(0) != <span class="charliteral">'.'</span> )
|
|---|
| 465 | 00493 {
|
|---|
| 466 | 00494 prefix += newPrefix;
|
|---|
| 467 | 00495 }
|
|---|
| 468 | 00496 <span class="keywordflow">else</span>
|
|---|
| 469 | 00497 { prefix = <a class="code" href="classG4UIGainServer.html#d11">ModifyPrefix</a>( newPrefix ); }
|
|---|
| 470 | 00498 }
|
|---|
| 471 | 00499 <span class="keywordflow">if</span>( <a class="code" href="classG4UIGainServer.html#r0">prefix</a>( prefix.length() - 1 ) != <span class="charliteral">'/'</span> )
|
|---|
| 472 | 00500 { prefix += <span class="stringliteral">"/"</span>; }
|
|---|
| 473 | 00501 <span class="keywordflow">if</span>( <a class="code" href="classG4UIGainServer.html#d12">FindDirPath</a>( prefix ) == NULL )
|
|---|
| 474 | 00502 {
|
|---|
| 475 | 00503 G4cout << <span class="stringliteral">"Directory <"</span> << prefix << <span class="stringliteral">"> is not found."</span> << G4endl;
|
|---|
| 476 | 00504 prefix = savedPrefix;
|
|---|
| 477 | 00505 }
|
|---|
| 478 | 00506 }
|
|---|
| 479 | 00508 <span class="keywordtype">void</span> <a class="code" href="classG4UIGainServer.html#d9">G4UIGainServer::ListDirectory</a>(G4String newCommand){
|
|---|
| 480 | 00510 G4String targetDir(<span class="charliteral">'\0'</span>);
|
|---|
| 481 | 00511 <span class="keywordflow">if</span>( newCommand.length() <= 3 )
|
|---|
| 482 | 00512 { targetDir = <a class="code" href="classG4UIGainServer.html#r0">prefix</a>; }
|
|---|
| 483 | 00513 <span class="keywordflow">else</span>
|
|---|
| 484 | 00514 {
|
|---|
| 485 | 00515 G4String newPrefix = newCommand(3,newCommand.length()-3);
|
|---|
| 486 | 00516 newPrefix.strip(G4String::both);
|
|---|
| 487 | 00517 <span class="keywordflow">if</span>( newPrefix(0) == <span class="charliteral">'/'</span> )
|
|---|
| 488 | 00518 { targetDir = newPrefix; }
|
|---|
| 489 | 00519 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( newPrefix(0) != <span class="charliteral">'.'</span> )
|
|---|
| 490 | 00520 {
|
|---|
| 491 | 00521 targetDir = <a class="code" href="classG4UIGainServer.html#r0">prefix</a>;
|
|---|
| 492 | 00522 targetDir += newPrefix;
|
|---|
| 493 | 00523 }
|
|---|
| 494 | 00524 <span class="keywordflow">else</span>
|
|---|
| 495 | 00525 { targetDir = <a class="code" href="classG4UIGainServer.html#d11">ModifyPrefix</a>( newPrefix ); }
|
|---|
| 496 | 00526 }
|
|---|
| 497 | 00527 <span class="keywordflow">if</span>( targetDir( targetDir.length() - 1 ) != <span class="charliteral">'/'</span> )
|
|---|
| 498 | 00528 { targetDir += <span class="stringliteral">"/"</span>; }
|
|---|
| 499 | 00529 G4UIcommandTree * commandTree = <a class="code" href="classG4UIGainServer.html#d12">FindDirPath</a>( targetDir );
|
|---|
| 500 | 00530 <span class="keywordflow">if</span>( commandTree == NULL )
|
|---|
| 501 | 00531 { G4cout << <span class="stringliteral">"Directory <"</span> << targetDir << <span class="stringliteral">"> is not found."</span> << G4endl; }
|
|---|
| 502 | 00532 <span class="keywordflow">else</span>
|
|---|
| 503 | 00533 { commandTree->ListCurrent(); }
|
|---|
| 504 | 00534 }
|
|---|
| 505 | 00535
|
|---|
| 506 | 00537 <span class="keywordtype">void</span> <a class="code" href="classG4UIGainServer.html#d10">G4UIGainServer::TerminalHelp</a>(G4String newCommand){
|
|---|
| 507 | 00539 G4UIcommandTree* treeTop = <a class="code" href="classG4UIGainServer.html#r2">UI</a>->GetTree();
|
|---|
| 508 | 00540 <span class="keywordtype">unsigned</span> i = newCommand.index(<span class="stringliteral">" "</span>);
|
|---|
| 509 | 00541
|
|---|
| 510 | 00542 <span class="keywordflow">if</span>(i!=std::string::npos){
|
|---|
| 511 | 00543 G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
|
|---|
| 512 | 00544 newValue.strip(G4String::both);
|
|---|
| 513 | 00545 <span class="keywordflow">if</span>(newValue(0)!=<span class="charliteral">'/'</span>){
|
|---|
| 514 | 00546 newValue.prepend(<a class="code" href="classG4UIGainServer.html#r0">prefix</a>);
|
|---|
| 515 | 00547 }
|
|---|
| 516 | 00548 G4UIcommand* theCommand = treeTop->FindPath(newValue);
|
|---|
| 517 | 00549 <span class="keywordflow">if</span>(theCommand !=NULL){
|
|---|
| 518 | 00550 theCommand->List();
|
|---|
| 519 | 00551 <span class="keywordflow">return</span>;
|
|---|
| 520 | 00552 }
|
|---|
| 521 | 00553 <span class="keywordflow">else</span>{
|
|---|
| 522 | 00554 G4cout<<<span class="stringliteral">"Command<"</span> << newValue << <span class="stringliteral">"is not found."</span><<G4endl;
|
|---|
| 523 | 00555 <span class="keywordflow">return</span>;
|
|---|
| 524 | 00556 }
|
|---|
| 525 | 00557 }
|
|---|
| 526 | 00558
|
|---|
| 527 | 00559 G4UIcommandTree* floor[10];
|
|---|
| 528 | 00560 floor[0] = treeTop;
|
|---|
| 529 | 00561 <span class="keywordtype">int</span> iFloor = 0;
|
|---|
| 530 | 00562 <span class="keywordtype">unsigned</span> prefixIndex = 1;
|
|---|
| 531 | 00563 <span class="keywordflow">while</span>(prefixIndex<<a class="code" href="classG4UIGainServer.html#r0">prefix</a>.length()-1){
|
|---|
| 532 | 00564 <span class="keywordtype">int</span> ii = <a class="code" href="classG4UIGainServer.html#r0">prefix</a>.index(<span class="stringliteral">"/"</span>,prefixIndex);
|
|---|
| 533 | 00565 floor[iFloor+1]=
|
|---|
| 534 | 00566 floor[iFloor]->GetTree(G4String(<a class="code" href="classG4UIGainServer.html#r0">prefix</a>(0,ii+1)));
|
|---|
| 535 | 00567 prefixIndex = ii+1;
|
|---|
| 536 | 00568 iFloor++;
|
|---|
| 537 | 00569 }
|
|---|
| 538 | 00570 floor[iFloor]->ListCurrentWithNum();
|
|---|
| 539 | 00571 <span class="keywordflow">while</span>(1){
|
|---|
| 540 | 00572 <span class="keywordtype">int</span> i;
|
|---|
| 541 | 00573 G4cout<<G4endl <<<span class="stringliteral">"Type the number (0:end, -n:n level back) :"</span><<std::flush;
|
|---|
| 542 | 00574 G4cin >> i;
|
|---|
| 543 | 00575 <span class="keywordflow">if</span>(!G4cin.good()){
|
|---|
| 544 | 00576 G4cin.clear();
|
|---|
| 545 | 00577 G4cin.ignore(30,<span class="charliteral">'\n'</span>);
|
|---|
| 546 | 00578 G4cout<<G4endl <<<span class="stringliteral">"Not a number,once more"</span><<G4endl; <span class="keywordflow">continue</span>;
|
|---|
| 547 | 00579 }
|
|---|
| 548 | 00580 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(i<0){
|
|---|
| 549 | 00581 iFloor += i;
|
|---|
| 550 | 00582 <span class="keywordflow">if</span>(iFloor <0) iFloor =0;
|
|---|
| 551 | 00583 floor[iFloor]->ListCurrentWithNum(); <span class="keywordflow">continue</span>;
|
|---|
| 552 | 00584 }
|
|---|
| 553 | 00585 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(i==0){<span class="keywordflow">break</span>;}
|
|---|
| 554 | 00586 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(i>0){
|
|---|
| 555 | 00587 <span class="keywordtype">int</span> n_tree = floor[iFloor]->GetTreeEntry();
|
|---|
| 556 | 00588 <span class="keywordflow">if</span>(i>n_tree){
|
|---|
| 557 | 00589 <span class="keywordflow">if</span>(i<=n_tree+floor[iFloor]->GetCommandEntry()){
|
|---|
| 558 | 00590 floor[iFloor]->GetCommand(i-n_tree)->List();
|
|---|
| 559 | 00591 }
|
|---|
| 560 | 00592 }
|
|---|
| 561 | 00593 <span class="keywordflow">else</span>{
|
|---|
| 562 | 00594 floor[iFloor+1] = floor[iFloor]->GetTree(i);
|
|---|
| 563 | 00595 iFloor++;
|
|---|
| 564 | 00596 floor[iFloor]->ListCurrentWithNum();
|
|---|
| 565 | 00597 }
|
|---|
| 566 | 00598 }
|
|---|
| 567 | 00599 }
|
|---|
| 568 | 00600 G4cout<<<span class="stringliteral">"Exit from Help."</span><<G4endl <<G4endl;
|
|---|
| 569 | 00601 G4cout<<G4endl;
|
|---|
| 570 | 00602 <span class="keywordtype">char</span> temp[100];
|
|---|
| 571 | 00603 G4cin.getline(temp,100);
|
|---|
| 572 | 00604 }
|
|---|
| 573 | 00605
|
|---|
| 574 | 00606
|
|---|
| 575 | 00608 G4String <a class="code" href="classG4UIGainServer.html#d11">G4UIGainServer::ModifyPrefix</a>(G4String newCommand){
|
|---|
| 576 | 00610 G4String newPrefix = <a class="code" href="classG4UIGainServer.html#r0">prefix</a>;
|
|---|
| 577 | 00611 <span class="keywordflow">while</span>(1){
|
|---|
| 578 | 00612 <span class="keywordflow">if</span>(newCommand(0,2) ==<span class="stringliteral">".."</span>){
|
|---|
| 579 | 00613 <span class="keywordflow">if</span>(newPrefix !=<span class="stringliteral">"/"</span>){
|
|---|
| 580 | 00614 G4String tmpString = newPrefix(0,newPrefix.length()-1);
|
|---|
| 581 | 00615 newPrefix = newPrefix(0,tmpString.last(<span class="charliteral">'/'</span>)+1);
|
|---|
| 582 | 00616 }
|
|---|
| 583 | 00617 }
|
|---|
| 584 | 00618 <span class="keywordflow">else</span>{
|
|---|
| 585 | 00619 newPrefix += newCommand;
|
|---|
| 586 | 00620 <span class="keywordflow">break</span>;
|
|---|
| 587 | 00621 }
|
|---|
| 588 | 00622 <span class="keywordflow">if</span>(newCommand == <span class="stringliteral">".."</span> || newCommand == <span class="stringliteral">"../"</span>){
|
|---|
| 589 | 00623 <span class="keywordflow">break</span>;
|
|---|
| 590 | 00624 }
|
|---|
| 591 | 00625 newCommand=newCommand(3,newCommand.length()-3);
|
|---|
| 592 | 00626 }
|
|---|
| 593 | 00627 <span class="keywordflow">return</span> newPrefix;
|
|---|
| 594 | 00628 }
|
|---|
| 595 | 00629
|
|---|
| 596 | 00631 G4UIcommandTree* <a class="code" href="classG4UIGainServer.html#d12">G4UIGainServer::FindDirPath</a>(G4String newCommand){
|
|---|
| 597 | 00633 G4UIcommandTree * comTree = <a class="code" href="classG4UIGainServer.html#r2">UI</a>->GetTree();
|
|---|
| 598 | 00634 <span class="comment">/*int*/</span> <span class="keywordtype">unsigned</span> idx = 1;
|
|---|
| 599 | 00635 <span class="keywordflow">while</span>( idx < newCommand.length()-1 )
|
|---|
| 600 | 00636 {
|
|---|
| 601 | 00637 <span class="keywordtype">int</span> i = newCommand.index(<span class="stringliteral">"/"</span>,idx);
|
|---|
| 602 | 00638 comTree = comTree->GetTree(G4String(newCommand(0,i+1)));
|
|---|
| 603 | 00639 <span class="keywordflow">if</span>( comTree == NULL )
|
|---|
| 604 | 00640 { <span class="keywordflow">return</span> NULL; }
|
|---|
| 605 | 00641 idx = i+1;
|
|---|
| 606 | 00642 }
|
|---|
| 607 | 00643 <span class="keywordflow">return</span> comTree;
|
|---|
| 608 | 00644 }
|
|---|
| 609 | 00645
|
|---|
| 610 | 00647
|
|---|
| 611 | 00649 <span class="keywordtype">void</span> <a class="code" href="classG4UIGainServer.html#d15">G4UIGainServer::SendCommandProperties</a>(G4UIcommandTree* tree){
|
|---|
| 612 | 00651 <span class="keywordflow">if</span>( tree == NULL ) {
|
|---|
| 613 | 00652 G4cerr << <span class="stringliteral">"GetTree() returnes null."</span> << G4endl;
|
|---|
| 614 | 00653 <span class="keywordflow">return</span>;
|
|---|
| 615 | 00654 }
|
|---|
| 616 | 00655 <span class="keywordflow">if</span> (<a class="code" href="classG4UIGainServer.html#r3">uiMode</a> == <a class="code" href="G4UIGAG_8hh.html#a7a1">java_mode</a>){
|
|---|
| 617 | 00656 G4cout << <span class="stringliteral">"@@JTreeBegin"</span> << G4endl;
|
|---|
| 618 | 00657 <a class="code" href="classG4UIGainServer.html#d19">CodeGenJavaTree</a>(tree, 0);
|
|---|
| 619 | 00658 G4cout << <span class="stringliteral">"@@JTreeEnd"</span> << G4endl;
|
|---|
| 620 | 00659 <a class="code" href="classG4UIGainServer.html#d20">CodeGenJavaParams</a>(tree, 0);
|
|---|
| 621 | 00660 }<span class="keywordflow">else</span>{}
|
|---|
| 622 | 00661 }
|
|---|
| 623 | 00662
|
|---|
| 624 | 00664 <span class="keywordtype">void</span> <a class="code" href="classG4UIGainServer.html#d16">G4UIGainServer::SendParameterProperties</a>(G4UIcommandTree* tree){
|
|---|
| 625 | 00666 <span class="keywordflow">if</span>( tree == NULL ) {
|
|---|
| 626 | 00667 G4cerr << <span class="stringliteral">"GetTree() returnes null."</span> << G4endl;
|
|---|
| 627 | 00668 <span class="keywordflow">return</span>;
|
|---|
| 628 | 00669 }
|
|---|
| 629 | 00670 <span class="keywordflow">if</span> (<a class="code" href="classG4UIGainServer.html#r3">uiMode</a> == <a class="code" href="G4UIGAG_8hh.html#a7a1">java_mode</a>){
|
|---|
| 630 | 00671 <a class="code" href="classG4UIGainServer.html#d20">CodeGenJavaParams</a>(tree, 0);
|
|---|
| 631 | 00672 }<span class="keywordflow">else</span>{ }
|
|---|
| 632 | 00673 }
|
|---|
| 633 | 00674
|
|---|
| 634 | 00676 <span class="keywordtype">void</span> <a class="code" href="classG4UIGainServer.html#d19">G4UIGainServer::CodeGenJavaTree</a>(G4UIcommandTree* tree,<span class="keywordtype">int</span> level){
|
|---|
| 635 | 00678 <span class="keywordtype">int</span> treeEntry, commandEntry;
|
|---|
| 636 | 00679 treeEntry = tree->GetTreeEntry();
|
|---|
| 637 | 00680 commandEntry = tree->GetCommandEntry();
|
|---|
| 638 | 00681
|
|---|
| 639 | 00682 <span class="keywordflow">if</span>(level!=0) {
|
|---|
| 640 | 00683 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0; i<commandEntry; i++){
|
|---|
| 641 | 00684 G4cout << tree->GetCommand(i+1)->GetCommandPath() << G4endl;
|
|---|
| 642 | 00685 }
|
|---|
| 643 | 00686 }
|
|---|
| 644 | 00687 <span class="keywordflow">if</span>(treeEntry == 0) <span class="keywordflow">return</span>; <span class="comment">//end recursion</span>
|
|---|
| 645 | 00688
|
|---|
| 646 | 00689 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> j=0; j<treeEntry; j++){
|
|---|
| 647 | 00690 <a class="code" href="classG4UIGainServer.html#d19">CodeGenJavaTree</a>(tree->GetTree(j+1), level+1);
|
|---|
| 648 | 00691 }
|
|---|
| 649 | 00692 }
|
|---|
| 650 | 00693
|
|---|
| 651 | 00695 <span class="keywordtype">void</span> <a class="code" href="classG4UIGainServer.html#d20">G4UIGainServer::CodeGenJavaParams</a>(G4UIcommandTree* tree,<span class="keywordtype">int</span> level){
|
|---|
| 652 | 00697 <span class="keywordtype">int</span> treeEntry,commandEntry,i;
|
|---|
| 653 | 00698 G4UIcommandTree* treeLink;
|
|---|
| 654 | 00699
|
|---|
| 655 | 00700 treeEntry = tree->GetTreeEntry();
|
|---|
| 656 | 00701 commandEntry = tree->GetCommandEntry();
|
|---|
| 657 | 00702
|
|---|
| 658 | 00703 <span class="keywordflow">for</span>(i=0;i<commandEntry; i++){
|
|---|
| 659 | 00704 <a class="code" href="classG4UIGainServer.html#d17">SendAParamProperty</a>(tree->GetCommand(i+1));
|
|---|
| 660 | 00705 }
|
|---|
| 661 | 00706 <span class="keywordflow">if</span>(treeEntry ==0) <span class="keywordflow">return</span>;
|
|---|
| 662 | 00707
|
|---|
| 663 | 00708 <span class="keywordflow">for</span>(i=0;i<treeEntry; i++){
|
|---|
| 664 | 00709 treeLink = tree->GetTree(i+1);
|
|---|
| 665 | 00710 G4cout<<<span class="stringliteral">"@@JDirGuieBegin"</span><<G4endl;
|
|---|
| 666 | 00711 G4cout<<treeLink->GetPathName()<<G4endl <<treeLink->GetTitle()<<G4endl;
|
|---|
| 667 | 00712 G4cout<<<span class="stringliteral">"@@JDirGuideEnd"</span><<G4endl;
|
|---|
| 668 | 00713 <a class="code" href="classG4UIGainServer.html#d20">CodeGenJavaParams</a>(treeLink,level+1);
|
|---|
| 669 | 00714 }
|
|---|
| 670 | 00715 }
|
|---|
| 671 | 00716
|
|---|
| 672 | 00718 <span class="keywordtype">void</span> <a class="code" href="classG4UIGainServer.html#d17">G4UIGainServer::SendAParamProperty</a>(G4UIcommand* Comp){
|
|---|
| 673 | 00720 <span class="keywordtype">int</span> guidanceEntry, parameterEntry;
|
|---|
| 674 | 00721 G4String title, title2;
|
|---|
| 675 | 00722 G4UIparameter * prp;
|
|---|
| 676 | 00723 <span class="keywordtype">char</span> c[2];
|
|---|
| 677 | 00724 guidanceEntry = Comp->GetGuidanceEntries();
|
|---|
| 678 | 00725 parameterEntry = Comp->GetParameterEntries();
|
|---|
| 679 | 00726 G4cout << <span class="stringliteral">"@@JParamBegin"</span> << G4endl;
|
|---|
| 680 | 00727 G4cout << Comp->GetCommandPath() << G4endl;
|
|---|
| 681 | 00728 G4cout << guidanceEntry << G4endl;
|
|---|
| 682 | 00729 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j=0; j<guidanceEntry; j++){
|
|---|
| 683 | 00730 title = Comp->GetGuidanceLine(j);
|
|---|
| 684 | 00731 title2 = <span class="stringliteral">""</span>;
|
|---|
| 685 | 00732 <span class="keywordflow">if</span> (title != <span class="stringliteral">""</span>){
|
|---|
| 686 | 00733 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0; i< (<span class="keywordtype">int</span>)title.length(); i++){
|
|---|
| 687 | 00734 c[0]=title(i);
|
|---|
| 688 | 00735 c[1]= <span class="charliteral">'\0'</span>;
|
|---|
| 689 | 00736 <span class="keywordflow">if</span> ( c[0] == <span class="charliteral">'\n'</span> || c[0] == <span class="charliteral">'\r'</span>) {
|
|---|
| 690 | 00737 c[0]= <span class="charliteral">' '</span>;
|
|---|
| 691 | 00738 }
|
|---|
| 692 | 00739 title2.append(c);
|
|---|
| 693 | 00740 }
|
|---|
| 694 | 00741 }
|
|---|
| 695 | 00742 G4cout << title2 << G4endl;
|
|---|
| 696 | 00743 }
|
|---|
| 697 | 00744 G4cout << Comp->GetRange() << G4endl;
|
|---|
| 698 | 00745 G4cout << parameterEntry << G4endl;
|
|---|
| 699 | 00746 <span class="keywordflow">for</span>( <span class="keywordtype">int</span> par=0; par<parameterEntry; par++) {
|
|---|
| 700 | 00747 prp = (G4UIparameter *)Comp->GetParameter(par);
|
|---|
| 701 | 00748 G4cout << prp->GetParameterName() << G4endl;
|
|---|
| 702 | 00749 G4cout << prp->GetParameterGuidance() << G4endl;
|
|---|
| 703 | 00750 G4cout << prp->GetParameterType() << G4endl;
|
|---|
| 704 | 00751 G4cout << prp->IsOmittable() << G4endl;
|
|---|
| 705 | 00752 G4cout << prp->GetDefaultValue() << G4endl;
|
|---|
| 706 | 00753 G4cout << prp->GetParameterRange() << G4endl;
|
|---|
| 707 | 00754 G4cout << prp->GetParameterCandidates() << G4endl;
|
|---|
| 708 | 00755 }
|
|---|
| 709 | 00756 G4cout << <span class="stringliteral">"@@JParamEnd"</span> << G4endl;
|
|---|
| 710 | 00757 }
|
|---|
| 711 | 00758
|
|---|
| 712 | 00760 <span class="keywordtype">void</span> <a class="code" href="classG4UIGainServer.html#d23">G4UIGainServer::SendDisableList</a>(G4UIcommandTree* tree,<span class="keywordtype">int</span> level){
|
|---|
| 713 | 00762 <span class="keywordtype">int</span> treeEntry, commandEntry;
|
|---|
| 714 | 00763 G4UIcommand * Comp;
|
|---|
| 715 | 00764 treeEntry = tree->GetTreeEntry();
|
|---|
| 716 | 00765 commandEntry = tree->GetCommandEntry();
|
|---|
| 717 | 00766
|
|---|
| 718 | 00767 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> com=0; com<commandEntry; com++) {
|
|---|
| 719 | 00768 Comp = tree->GetCommand(com+1);
|
|---|
| 720 | 00769 <span class="keywordflow">if</span>( Comp->IsAvailable()==<span class="keyword">false</span> ) {
|
|---|
| 721 | 00770 G4cout << Comp->GetCommandPath()<<G4endl;
|
|---|
| 722 | 00771 }
|
|---|
| 723 | 00772 }
|
|---|
| 724 | 00773 <span class="keywordflow">if</span>( treeEntry == 0 ) <span class="keywordflow">return</span>; <span class="comment">// end recursion</span>
|
|---|
| 725 | 00774
|
|---|
| 726 | 00775 <span class="keywordflow">for</span>( <span class="keywordtype">int</span> i=0; i<treeEntry; i++) {
|
|---|
| 727 | 00776 <a class="code" href="classG4UIGainServer.html#d23">SendDisableList</a>(tree->GetTree(i+1), level+1);
|
|---|
| 728 | 00777 <span class="comment">// be sure the function name is the same</span>
|
|---|
| 729 | 00778 }
|
|---|
| 730 | 00779 }
|
|---|
| 731 | 00780
|
|---|
| 732 | 00781
|
|---|
| 733 | 00782
|
|---|
| 734 | 00783 <span class="comment">//####### update check routines ####################################</span>
|
|---|
| 735 | 00784
|
|---|
| 736 | 00786 <span class="keywordtype">void</span> <a class="code" href="classG4UIGainServer.html#d28">G4UIGainServer::UpdateState</a>(<span class="keywordtype">void</span>){
|
|---|
| 737 | 00788 <span class="keyword">static</span> G4ApplicationState previousState= G4State_PreInit;
|
|---|
| 738 | 00789 G4ApplicationState newState;
|
|---|
| 739 | 00790 G4StateManager *statM = G4StateManager::GetStateManager();
|
|---|
| 740 | 00791 newState = statM->GetCurrentState();
|
|---|
| 741 | 00792 <span class="keywordflow">if</span>( newState != previousState )
|
|---|
| 742 | 00793 {
|
|---|
| 743 | 00794 <a class="code" href="classG4UIGainServer.html#d24">NotifyStateChange</a>();
|
|---|
| 744 | 00795 previousState = newState;
|
|---|
| 745 | 00796 }
|
|---|
| 746 | 00797 }
|
|---|
| 747 | 00798
|
|---|
| 748 | 00800 <span class="keywordtype">void</span> <a class="code" href="classG4UIGainServer.html#d24">G4UIGainServer::NotifyStateChange</a>(<span class="keywordtype">void</span>)
|
|---|
| 749 | 00802 {
|
|---|
| 750 | 00803 G4String stateString;
|
|---|
| 751 | 00804 G4StateManager * statM = G4StateManager::GetStateManager();
|
|---|
| 752 | 00805 G4UIcommandTree * tree = <a class="code" href="classG4UIGainServer.html#r2">UI</a>->GetTree();
|
|---|
| 753 | 00806 stateString = statM->GetStateString(statM->GetCurrentState());
|
|---|
| 754 | 00807 <span class="keywordflow">if</span> ( <a class="code" href="classG4UIGainServer.html#r3">uiMode</a> != <a class="code" href="G4UIGAG_8hh.html#a7a0">terminal_mode</a> ){
|
|---|
| 755 | 00808 G4cout << <span class="stringliteral">"@@State \""</span> << stateString << <span class="stringliteral">"\""</span> << G4endl;
|
|---|
| 756 | 00809 G4cout << <span class="stringliteral">"@@DisableListBegin"</span><<G4endl;
|
|---|
| 757 | 00810 <a class="code" href="classG4UIGainServer.html#d23">SendDisableList</a>(tree, 0);
|
|---|
| 758 | 00811 G4cout << <span class="stringliteral">"@@DisableListEnd"</span> <<G4endl;
|
|---|
| 759 | 00812 }
|
|---|
| 760 | 00813 }
|
|---|
| 761 | 00814
|
|---|
| 762 | 00816 <span class="keywordtype">void</span> <a class="code" href="classG4UIGainServer.html#d25">G4UIGainServer::NotifyCommandUpdate</a>(<span class="keywordtype">void</span>)
|
|---|
| 763 | 00818 {
|
|---|
| 764 | 00819 G4UIcommandTree * tree = <a class="code" href="classG4UIGainServer.html#r2">UI</a>->GetTree();
|
|---|
| 765 | 00820 <a class="code" href="classG4UIGainServer.html#d15">SendCommandProperties</a>(tree);
|
|---|
| 766 | 00821 }
|
|---|
| 767 | 00822
|
|---|
| 768 | 00824 <span class="keywordtype">void</span> <a class="code" href="classG4UIGainServer.html#d26">G4UIGainServer::NotifyParameterUpdate</a>(G4UIcommand* com)
|
|---|
| 769 | 00826 {
|
|---|
| 770 | 00827 <a class="code" href="classG4UIGainServer.html#d17">SendAParamProperty</a>(com);
|
|---|
| 771 | 00828 }
|
|---|
| 772 | 00829
|
|---|
| 773 | 00831 <span class="keywordtype">int</span> <a class="code" href="classG4UIGainServer.html#d27">G4UIGainServer::CommandUpdated</a>(<span class="keywordtype">void</span>){
|
|---|
| 774 | 00833 <span class="keywordtype">int</span> <a class="code" href="G4UIGAG_8hh.html#a8a4">added</a>=0, <a class="code" href="G4UIGAG_8hh.html#a8a5">deleted</a>=0;
|
|---|
| 775 | 00834 <span class="keywordtype">int</span> pEntry= <a class="code" href="classG4UIGainServer.html#r15">previousTreeCommands</a>.size();
|
|---|
| 776 | 00835 <span class="keywordtype">int</span> nEntry= <a class="code" href="classG4UIGainServer.html#r16">newTreeCommands</a>.size();
|
|---|
| 777 | 00836 <span class="keywordtype">int</span> i,j;
|
|---|
| 778 | 00837 <span class="keywordflow">for</span>( i=0; i<pEntry; i++) { <span class="comment">// check deleted command(s)</span>
|
|---|
| 779 | 00838 <span class="keywordflow">for</span>( j=0; j<nEntry; j++) {
|
|---|
| 780 | 00839 <span class="keywordflow">if</span>( <a class="code" href="classG4UIGainServer.html#r15">previousTreeCommands</a>[i] == <a class="code" href="classG4UIGainServer.html#r16">newTreeCommands</a>[j]) <span class="keywordflow">break</span>;
|
|---|
| 781 | 00840 }
|
|---|
| 782 | 00841 <span class="keywordflow">if</span>( j==nEntry ) {
|
|---|
| 783 | 00842 <a class="code" href="G4UIGAG_8hh.html#a8a5">deleted</a> = 1;
|
|---|
| 784 | 00843 <span class="comment">//G4cout <<"deleted: "<< previousTreeCommands(i) << G4endl;</span>
|
|---|
| 785 | 00844 }
|
|---|
| 786 | 00845 }
|
|---|
| 787 | 00846 <span class="keywordflow">for</span>( i=0; i<nEntry; i++) { <span class="comment">// check added command(s)</span>
|
|---|
| 788 | 00847 <span class="keywordflow">for</span>( j=0; j<pEntry; j++) {
|
|---|
| 789 | 00848 <span class="keywordflow">if</span>( <a class="code" href="classG4UIGainServer.html#r16">newTreeCommands</a>[i] == <a class="code" href="classG4UIGainServer.html#r15">previousTreeCommands</a>[j]) <span class="keywordflow">break</span>;
|
|---|
| 790 | 00849 }
|
|---|
| 791 | 00850 <span class="keywordflow">if</span>( j==pEntry ) {
|
|---|
| 792 | 00851 <a class="code" href="G4UIGAG_8hh.html#a8a4">added</a> = 1;
|
|---|
| 793 | 00852 <span class="comment">// G4cout <<"added: "<< newTreeCommands(i) << G4endl;</span>
|
|---|
| 794 | 00853 }
|
|---|
| 795 | 00854 }
|
|---|
| 796 | 00855 <span class="keywordflow">if</span>( <a class="code" href="G4UIGAG_8hh.html#a8a4">added</a> && <a class="code" href="G4UIGAG_8hh.html#a8a5">deleted</a>==0 ) {G4cout<<<span class="stringliteral">"c added"</span><<G4endl;<span class="keywordflow">return</span> <a class="code" href="G4UIGAG_8hh.html#a8a4">added</a>;}
|
|---|
| 797 | 00856 <span class="keywordflow">if</span>( <a class="code" href="G4UIGAG_8hh.html#a8a4">added</a>==0 && <a class="code" href="G4UIGAG_8hh.html#a8a5">deleted</a> ) {G4cout<<<span class="stringliteral">"c deleted"</span><<G4endl;<span class="keywordflow">return</span> <a class="code" href="G4UIGAG_8hh.html#a8a5">deleted</a>;}
|
|---|
| 798 | 00857 <span class="keywordflow">if</span>( <a class="code" href="G4UIGAG_8hh.html#a8a4">added</a> && <a class="code" href="G4UIGAG_8hh.html#a8a5">deleted</a> ) {G4cout<<<span class="stringliteral">"c add/deleted"</span><<G4endl;<span class="keywordflow">return</span> <a class="code" href="G4UIGAG_8hh.html#a8a6">addedAndDeleted</a>;}
|
|---|
| 799 | 00858 <span class="keywordflow">return</span> <a class="code" href="G4UIGAG_8hh.html#a8a3">notChanged</a>;
|
|---|
| 800 | 00859 }
|
|---|
| 801 | 00860
|
|---|
| 802 | 00862 <span class="keywordtype">void</span> <a class="code" href="classG4UIGainServer.html#d0">G4UIGainServer::GetNewTreeStructure</a>(G4UIcommandTree * tree, <span class="keywordtype">int</span> level) {
|
|---|
| 803 | 00864 G4String commandPath;
|
|---|
| 804 | 00865 G4String title;
|
|---|
| 805 | 00866 G4String pathName; <span class="comment">//tree name</span>
|
|---|
| 806 | 00867 G4UIcommandTree * t;
|
|---|
| 807 | 00868 <span class="keywordtype">int</span> treeEntry = tree->GetTreeEntry();
|
|---|
| 808 | 00869 <span class="keywordtype">int</span> commandEntry = tree->GetCommandEntry();
|
|---|
| 809 | 00870
|
|---|
| 810 | 00871 <span class="keywordflow">if</span>( level==0 ) { <a class="code" href="classG4UIGainServer.html#r16">newTreeCommands</a>.clear();}
|
|---|
| 811 | 00872 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> com=0; com<commandEntry; com++){
|
|---|
| 812 | 00873 commandPath = tree->GetCommand(com+1)->GetCommandPath();
|
|---|
| 813 | 00874 title = tree->GetCommand(com+1)->GetTitle();
|
|---|
| 814 | 00875 <a class="code" href="classG4UIGainServer.html#r16">newTreeCommands</a>.push_back( commandPath + <span class="stringliteral">" "</span> + title );
|
|---|
| 815 | 00876 }
|
|---|
| 816 | 00877
|
|---|
| 817 | 00878 <span class="keywordflow">if</span>(treeEntry == 0) <span class="keywordflow">return</span>; <span class="comment">//end recursion</span>
|
|---|
| 818 | 00879
|
|---|
| 819 | 00880 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0; i< treeEntry; i++){
|
|---|
| 820 | 00881 t = tree->GetTree(i+1);
|
|---|
| 821 | 00882 pathName = t->GetPathName();
|
|---|
| 822 | 00883 title = t->GetTitle();
|
|---|
| 823 | 00884 <a class="code" href="classG4UIGainServer.html#r16">newTreeCommands</a>.push_back( pathName + <span class="stringliteral">" "</span> + title );
|
|---|
| 824 | 00885 <a class="code" href="classG4UIGainServer.html#d0">GetNewTreeStructure</a>(t, level+1);
|
|---|
| 825 | 00886 }
|
|---|
| 826 | 00887 }
|
|---|
| 827 | 00888
|
|---|
| 828 | 00890 <span class="keywordtype">void</span> <a class="code" href="classG4UIGainServer.html#d29">G4UIGainServer::UpdateParamVal</a>(<span class="keywordtype">void</span>) {
|
|---|
| 829 | 00892 <span class="comment">// call NotifyParameterUpdate() if the value of each</span>
|
|---|
| 830 | 00893 <span class="comment">// command/parameter is updated.</span>
|
|---|
| 831 | 00894 <span class="comment">// assuming the command structure is not changed.</span>
|
|---|
| 832 | 00895 <span class="keywordtype">int</span> pEntry= <a class="code" href="classG4UIGainServer.html#r17">previousTreeParams</a>.size();
|
|---|
| 833 | 00896 <span class="keywordtype">int</span> nEntry= <a class="code" href="classG4UIGainServer.html#r18">newTreeParams</a>.size();
|
|---|
| 834 | 00897 <span class="keywordtype">int</span> i;
|
|---|
| 835 | 00898 G4UIcommand* Comp;
|
|---|
| 836 | 00899 <span class="keywordflow">if</span> (pEntry != nEntry) <span class="keywordflow">return</span>;
|
|---|
| 837 | 00900 <span class="keywordflow">for</span>( i=0; i<nEntry; i++) {
|
|---|
| 838 | 00901 <span class="keywordflow">if</span>( <a class="code" href="classG4UIGainServer.html#r17">previousTreeParams</a>[i] != <a class="code" href="classG4UIGainServer.html#r18">newTreeParams</a>[i]){
|
|---|
| 839 | 00902 Comp = <a class="code" href="classG4UIGainServer.html#r20">newTreePCP</a>[i];
|
|---|
| 840 | 00903 G4cout << Comp->GetCommandPath()
|
|---|
| 841 | 00904 << <span class="stringliteral">" command is updated."</span> <<G4endl;
|
|---|
| 842 | 00905 <a class="code" href="classG4UIGainServer.html#d26">NotifyParameterUpdate</a>(Comp);
|
|---|
| 843 | 00906 }
|
|---|
| 844 | 00907 }
|
|---|
| 845 | 00908 }
|
|---|
| 846 | 00909
|
|---|
| 847 | 00911 <span class="keywordtype">void</span> <a class="code" href="classG4UIGainServer.html#d1">G4UIGainServer::GetNewTreeValues</a>( G4UIcommandTree * tree, <span class="keywordtype">int</span> level){ <span class="comment">// recursive</span>
|
|---|
| 848 | 00913 <span class="comment"></span> G4String commandPath;
|
|---|
| 849 | 00914 G4String pathName; <span class="comment">//tree name</span>
|
|---|
| 850 | 00915 G4UIcommandTree * t;
|
|---|
| 851 | 00916 <span class="keywordtype">int</span> parameterEntry;
|
|---|
| 852 | 00917 <span class="keywordtype">int</span> treeEntry = tree->GetTreeEntry();
|
|---|
| 853 | 00918 <span class="keywordtype">int</span> commandEntry = tree->GetCommandEntry();
|
|---|
| 854 | 00919 G4UIcommand * Comp;
|
|---|
| 855 | 00920 G4UIparameter * prp;
|
|---|
| 856 | 00921 G4String param, str(<span class="stringliteral">" "</span>);
|
|---|
| 857 | 00922
|
|---|
| 858 | 00923 <span class="keywordflow">if</span>( level==0 ) { <a class="code" href="classG4UIGainServer.html#r18">newTreeParams</a>.clear(); }
|
|---|
| 859 | 00924 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> com=0; com<commandEntry; com++) {
|
|---|
| 860 | 00925 Comp = tree->GetCommand(com+1);
|
|---|
| 861 | 00926 commandPath = Comp->GetCommandPath();
|
|---|
| 862 | 00927 parameterEntry = Comp->GetParameterEntries();
|
|---|
| 863 | 00928 param = commandPath +<span class="stringliteral">" "</span>;
|
|---|
| 864 | 00929 <span class="keywordflow">for</span>( <span class="keywordtype">int</span> par=0; par< parameterEntry; par++) {
|
|---|
| 865 | 00930 prp = (G4UIparameter *)Comp->GetParameter(par);
|
|---|
| 866 | 00931 param += prp->GetParameterName() +<span class="stringliteral">" "</span>;
|
|---|
| 867 | 00932 str(0) = prp->GetParameterType();
|
|---|
| 868 | 00933 param += str + <span class="stringliteral">" "</span>;
|
|---|
| 869 | 00934 param += prp->GetDefaultValue() +<span class="stringliteral">" "</span>;
|
|---|
| 870 | 00935 param += prp->GetParameterRange() +<span class="stringliteral">" "</span>;
|
|---|
| 871 | 00936 param += prp->GetParameterCandidates();
|
|---|
| 872 | 00937 }
|
|---|
| 873 | 00938 <a class="code" href="classG4UIGainServer.html#r18">newTreeParams</a>.push_back( param + <span class="stringliteral">"\n"</span>);
|
|---|
| 874 | 00939 <a class="code" href="classG4UIGainServer.html#r20">newTreePCP</a>.push_back( Comp );
|
|---|
| 875 | 00940 }
|
|---|
| 876 | 00941 <span class="keywordflow">if</span>( treeEntry == 0 ) <span class="keywordflow">return</span>; <span class="comment">// end recursion</span>
|
|---|
| 877 | 00942 <span class="keywordflow">for</span>( <span class="keywordtype">int</span> i=0; i< treeEntry; i++) {
|
|---|
| 878 | 00943 t = tree->GetTree(i+1);
|
|---|
| 879 | 00944 <a class="code" href="classG4UIGainServer.html#d1">GetNewTreeValues</a>(t, level+1);
|
|---|
| 880 | 00945 }
|
|---|
| 881 | 00946 }
|
|---|
| 882 | 00947
|
|---|
| 883 | 00948
|
|---|
| 884 | 00949 <span class="preprocessor">#endif</span>
|
|---|
| 885 | 00950 <span class="preprocessor"></span>
|
|---|
| 886 | 00951
|
|---|
| 887 | 00952
|
|---|
| 888 | 00953
|
|---|
| 889 | 00954
|
|---|
| 890 | 00955
|
|---|
| 891 | 00956
|
|---|
| 892 | 00957
|
|---|
| 893 | 00958
|
|---|
| 894 | 00959
|
|---|
| 895 | 00960
|
|---|
| 896 | 00961
|
|---|
| 897 | </pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri Jun 22 11:07:02 2007 by
|
|---|
| 898 | <a href="http://www.doxygen.org/index.html">
|
|---|
| 899 | <img src="doxygen.png" alt="doxygen" align="middle" border=0 >
|
|---|
| 900 | </a>1.3.4 </small></address>
|
|---|
| 901 | </body>
|
|---|
| 902 | </html>
|
|---|