Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4UIGainServer.cc
이 파일의 문서화 페이지로 가기
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 // 12/06/2002 G4UIGainServer H. MInamimoto and H. Yoshida created
28 // $Id: G4UIGainServer.cc 110933 2018-06-26 08:09:42Z gcosmo $
29 //
30 #ifndef WIN32
31 
32 #include "G4UIGainServer.hh"
33 #include <netdb.h>
34 
35 #include <sstream>
36 #include "G4StateManager.hh"
37 #include "G4UIcommandTree.hh"
38 #include "G4UIcommand.hh"
39 #include "G4UIcommandStatus.hh"
40 
41 
45 {
46  TVersion ="T1.0a"; JVersion="J1.0a";
47  prefix = "/";
48 
50  while(SetUPServer() == false){
51  G4cout<<"can't get the port no. "<<port<<" Now, try to get the next port "<<port+1<<G4endl;
52  port++;
53  }
54 
55 
57  UI-> SetSession(this);
58  UI-> SetCoutDestination(this);
59 
63 
64  iExit= FALSE;
65  iCont= FALSE;
66 
67  G4UIcommandTree* tree = UI->GetTree();
68  GetNewTreeStructure(tree,0);
69  GetNewTreeValues(tree,0);
73 
74 }
75 
78 {
80 
82  UI-> SetSession(NULL);
83  UI-> SetCoutDestination(NULL);
84  }
85 
87  UI->SetSession(NULL);
88  UI->SetCoutDestination(NULL);
89  }
90 }
91 
92 
96 {
97  G4String newCommand;
98 
101 
102  iExit= TRUE;
103 
105  while(iExit){
106  newCommand= GetCommand();
107  ExecuteCommand(newCommand);
108  }
109  return NULL;
110 }
111 
115 {
116  promptCharacter = msg;
117  G4cout<<"@@PROMPT \""<<promptCharacter<<"\""<<G4endl;
118 
119  iCont= TRUE;
120 
121  G4String newCommand= GetCommand();
122  while(iCont){
123  ExecuteCommand(newCommand);
124  newCommand= GetCommand();
125  strcpy(buf,"nowIdle");
126  ssize_t rc = write(socketD[1],buf,strlen(buf));
127  if (rc < 0) {}
128  }
129 }
130 
134 {
135  if(aCommand.length()<2) return;
136 
137  G4UIcommandTree* tree = UI->GetTree();
138  if(aCommand.length()<2) return;
139  G4int returnVal = UI->ApplyCommand(aCommand);
140  G4int paramIndex = returnVal % 100;
141  // 0 - 98 : paramIndex-th parameter is invalid
142  // 99 : convination of parameters is invalid
143  G4int commandStatus = returnVal - paramIndex;
144 
145  UpdateState();
146 
147  if(uiMode != terminal_mode){
148  switch(commandStatus) {
149  case fCommandSucceeded:
150  GetNewTreeStructure(tree,0);
151  GetNewTreeValues(tree,0);
152  if(CommandUpdated()){
154  } else{
155  UpdateParamVal();
156  }
160  break;
161  case fCommandNotFound:
162  G4cerr << "@@ErrResult \" <" << UI->SolveAlias(aCommand) << "> not found.\"" << G4endl;
163  break;
165  G4cerr << "@@ErrResult \"illegal application state -- command refused.\"" << G4endl;
166  break;
168  G4cout << "@@ErrResult \"Parameter Out of Range.\"" << G4endl;
169  break;
171  G4cout << "@@ErrResult \"Parameter is wrong type and/or is not omittable.\""<<G4endl;
172  break;
174  G4cerr << "@@ErrResult \"Parameter is out of candidate.\"" << G4endl;
175  break;
176  case fAliasNotFound:
177  default:
178  G4cerr << "command refused (" << commandStatus << ")" << G4endl;
179  }
180  }
181 }
182 
186 {
187  G4String newCommand;
188  G4String nullString;
189 
190  while( 1 )
191  {
192  G4UIcommandTree* tree = UI->GetTree();
193  if ( uiMode != terminal_mode ){
194  G4cout << "@@PROMPT \"" << promptCharacter << "\"" << G4endl;
195  }
196  if ( uiMode != java_mode ){
197  G4cout << promptCharacter << "> " << G4endl;
198  }else{
199  G4cout << "@@Ready" << G4endl;
200  }
201 
202 
205  ssize_t rc = read(socketD[1],buf,1024);
206  if ( rc < 0 ) {}
207  newCommand=buf;
208  //DEBUG cout<<"->"<<newCommand<<"<-"<<newCommand.length()<<G4endl;
209  //newCommand.readLine( G4cin, FALSE );
212 
213 
214 
215  if (!G4cin.good()) { G4cin.clear(); newCommand = nullString; iExit=false;break;}
216 
217  newCommand = newCommand.strip(G4String::leading);
218  if( newCommand.length() < 1) { break; }
219 
220  while( newCommand(newCommand.length()-1) == '_' )
221  {
222  G4String newLine;
223  newCommand.remove(newCommand.length()-1);
224  newLine.readLine( G4cin );
225  if (!G4cin.good()) { G4cin.clear(); newCommand = nullString; iExit=false;break;}
226  newCommand.append(newLine);
227  }
228 
229  G4String nC = newCommand.strip(G4String::leading);
230  if( nC.length() < 1) { break; }
231 
232  // -------------------- nC.toUpper();
233  if( nC == "@@GainmodeJAVA" ) {
234  uiMode = java_mode;
235  G4cout << G4endl << "@@Version " << JVersion << G4endl;
236  SendCommandProperties(tree);
238  }
239  else if( nC == "@@GainmodeTcl" ) {
240  uiMode = tcl_mode;
241  G4cout << G4endl << "@@Version " << TVersion << G4endl;
242  SendCommandProperties(tree);
244  }
245  else if( nC(0) == '#' )
246  { G4cout << nC << G4endl; }
247 
248  else if( nC == "ls" || nC(0,3) == "ls " )
249  { ListDirectory( nC ); }
250  else if( nC == "pwd" )
251  { G4cout << "Current Working Directory : " << prefix << G4endl; }
252  else if( nC(0,2) == "cd" || nC(0,3) == "cd " )
253  { ChangeDirectory( nC ); }
254  else if( nC == "help" || nC(0,5) == "help ")
255  { TerminalHelp( nC ); }
256  else if( nC(0) == '?' )
257  { ShowCurrent( nC ); }
258  else if( nC(0,4) == "hist" || nC == "history")
259  {
260  G4int nh = UI->GetNumberOfHistory();
261  for(int i=0;i<nh;i++)
262  { G4cout << i << ": " << UI->GetPreviousCommand(i) << G4endl; }
263  }
264  else if( nC(0) == '!' )
265  {
266  G4String ss = nC(1,nC.length()-1);
267  G4int vl;
268  const char* tt = ss;
269  std::istringstream is((char*)tt);
270  is >> vl;
271  G4int nh = UI->GetNumberOfHistory();
272  if(vl>=0 && vl<nh)
273  {
274  newCommand = UI->GetPreviousCommand(vl);
275  G4cout << newCommand << G4endl;
276  break;
277  }
278  else
279  { G4cerr << "history " << vl << " is not found." << G4endl; }
280  }
281  else if( nC(0,4) == "exit" )
282  {
283  if( iCont )
284  {
285  if ( uiMode == terminal_mode){
286  G4cerr << "You are now processing RUN." << G4endl;
287  G4cerr << "Please abrot it using \"/run/abort\" command first" << G4endl;
288  G4cerr << " and use \"continue\" command until the application" << G4endl;
289  G4cerr << " becomes to Idle." << G4endl;
290  }else{
291  G4cout << "@@ErrResult \"You are now processing RUN.\"" << G4endl;
292  }
293  }
294  else
295  {
296  close(socketD[1]);
297  close(socketD[2]);
298  iExit = false;
299  newCommand = nullString;
300  break;
301  }
302  }
303  else if( nC == "cont" || nC == "continue" )
304  {
305  iCont = false;
306  newCommand = nullString;
307  break;
308  }
309  else
310  { break; }
311  }
312  return GetFullPath(newCommand);
313 }
314 
318 {
319  if(socketD[1]>0){
320  ssize_t rc = write(socketD[1],coutString,coutString.length());
321  if ( rc < 0 ){}
322  }
323  return 0;
324 
325  //std::cout << coutString << std::flush;
326  //return 0;
327 }
328 
332 {
333  if(socketD[2]>0){
334  ssize_t rc = write(socketD[2],cerrString,cerrString.length());
335  if ( rc < 0 ) {}
336  }
337  return 0;
338 
339  //std::cerr << cerrString << std::flush;
340  //return 0;
341 }
342 
346 {
347  G4cin >> aInt;
348  if(!G4cin.good()){
349  G4cin.clear();
350  G4cin.ignore(30,'\n');
351  return FALSE;
352  }
353  return TRUE;
354 }
355 
359 {
360  char temp[100];
361  G4cin.getline(temp, 100);
362 }
363 
367 
368  socketD[0] = socket(AF_INET,SOCK_STREAM,0);
369 
370  if(socketD[0]<0){
371  perror("server:socket");
372  return (false);
373  //exit(1);
374  }
375 
376  memset( (char *)&saddr,'\0',sizeof(saddr)) ;
377 
378  saddr.sin_family = AF_INET;
379  saddr.sin_addr.s_addr = INADDR_ANY;
380  saddr.sin_port = htons(port);
381  unlink(SOCK_NAME);
382 
383  if(bind(socketD[0] , (struct sockaddr *)&saddr , sizeof(saddr))<0){
384  perror("bind");
385  return (false);
386  //exit(1);
387  }
388  else{ G4cout<<"G4GainServer waiting at "<<port<<G4endl; }
389 
390  if(listen(socketD[0],1)<0){
391  perror("listen");
392  return (false);
393  //exit(1);
394  }
395 
396  return (true);
397 }
398 
402  len = sizeof(caddr);
403 
404  for(int i=1;i<=2;i++){
405 #if defined __APPLE__ && (__GNUC__<4)
406  if((socketD[i] = accept(socketD[0], (struct sockaddr *)&caddr,(int *)&len))<0){
407 #else
408  if((socketD[i] = accept(socketD[0], (struct sockaddr *)&caddr,(socklen_t *)&len))<0){
409 #endif
410  G4cerr<<"accept:"<<i<<G4endl;
411  //exit(1);
412  G4Exception("G4UIGainServer::WaitingConnection()",
413  "UI0004",
415  "Invalid Socket. Cannot establish connection");
416  }
417  }
418  close(socketD[0]);
419 }
420 
424  G4String newCommand = aNewCommand.strip(G4String::both);
425  G4String tmpString;
426  if( newCommand(0) == '/' )
427  { tmpString = newCommand; }
428  else if( newCommand(0,3) == "../" )
429  {
430  G4String tmpPrefix = prefix;
431  /*G4int*/ unsigned i_direc = 0;
432  while( i_direc < newCommand.length() )
433  {
434  if( newCommand(i_direc,3) == "../" )
435  {
436  i_direc += 3;
437  prefix = ModifyPrefix( G4String("../") );
438  }
439  else
440  { break; }
441  }
442  tmpString = prefix;
443  tmpString.append( newCommand( i_direc, newCommand.length()-i_direc ) );
444  prefix = tmpPrefix;
445  }
446  else
447  {
448  tmpString = prefix;
449  tmpString.append( newCommand );
450  }
451  return tmpString;
452 }
453 
457  G4cout<<"***** Terminal session end *****"<<G4endl;
458 }
459 
460 
464  G4String theCommand = GetFullPath(newCommand(1,newCommand.length()-1));
465  G4String curV = UI->GetCurrentValues(theCommand);
466  if( ! (curV.isNull()||curV(0)=='\0' ) ) {
467  if (uiMode == terminal_mode){
468  G4cout << "Current value(s) of the parameter(s) : " << curV << G4endl;
469  }else{
470  G4cout << "@@CurrentValue " << curV << G4endl;
471  }
472  } else if (uiMode == terminal_mode){
473  G4cout << "Current value is not available." << G4endl;
474  } else {
475  G4cout << "@@ErrResult \"Current value is not available.\"" << G4endl;
476  }
477 }
478 
482  G4String savedPrefix = prefix;
483  if( newCommand.length() <= 3 )
484  { prefix = "/"; }
485  else
486  {
487  G4String aNewPrefix = newCommand(3,newCommand.length()-3);
488  G4String newPrefix = aNewPrefix.strip(G4String::both);
489  if( newPrefix(0) == '/' )
490  { prefix = newPrefix; }
491  else if( newPrefix(0) != '.' )
492  {
493  prefix += newPrefix;
494  }
495  else
496  { prefix = ModifyPrefix( newPrefix ); }
497  }
498  if( prefix( prefix.length() - 1 ) != '/' )
499  { prefix += "/"; }
500  if( FindDirPath( prefix ) == NULL )
501  {
502  G4cout << "Directory <" << prefix << "> is not found." << G4endl;
503  prefix = savedPrefix;
504  }
505 }
509  G4String targetDir('\0');
510  if( newCommand.length() <= 3 )
511  { targetDir = prefix; }
512  else
513  {
514  G4String newPrefix = newCommand(3,newCommand.length()-3);
515  newPrefix.strip(G4String::both);
516  if( newPrefix(0) == '/' )
517  { targetDir = newPrefix; }
518  else if( newPrefix(0) != '.' )
519  {
520  targetDir = prefix;
521  targetDir += newPrefix;
522  }
523  else
524  { targetDir = ModifyPrefix( newPrefix ); }
525  }
526  if( targetDir( targetDir.length() - 1 ) != '/' )
527  { targetDir += "/"; }
528  G4UIcommandTree * commandTree = FindDirPath( targetDir );
529  if( commandTree == NULL )
530  { G4cout << "Directory <" << targetDir << "> is not found." << G4endl; }
531  else
532  { commandTree->ListCurrent(); }
533 }
534 
538  G4UIcommandTree* treeTop = UI->GetTree();
539  str_size i = newCommand.index(" ");
540 
541  if(i!=std::string::npos){
542  G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
543  newValue.strip(G4String::both);
544  if(newValue(0)!='/'){
545  newValue.prepend(prefix);
546  }
547  G4UIcommand* theCommand = treeTop->FindPath(newValue);
548  if(theCommand !=NULL){
549  theCommand->List();
550  return;
551  }
552  else{
553  G4cout<<"Command<" << newValue << "is not found."<<G4endl;
554  return;
555  }
556  }
557 
558  G4UIcommandTree* floor[10];
559  floor[0] = treeTop;
560  int iFloor = 0;
561  unsigned prefixIndex = 1;
562  while(prefixIndex<prefix.length()-1){
563  int ii = prefix.index("/",prefixIndex);
564  floor[iFloor+1]=
565  floor[iFloor]->GetTree(G4String(prefix(0,ii+1)));
566  prefixIndex = ii+1;
567  iFloor++;
568  }
569  floor[iFloor]->ListCurrentWithNum();
570  while(1){
571  int j;
572  G4cout<<G4endl <<"Type the number (0:end, -n:n level back) :"<<std::flush;
573  G4cin >> j;
574  if(!G4cin.good()){
575  G4cin.clear();
576  G4cin.ignore(30,'\n');
577  G4cout<<G4endl <<"Not a number,once more"<<G4endl; continue;
578  }
579  else if(j<0){
580  iFloor += j;
581  if(iFloor <0) iFloor =0;
582  floor[iFloor]->ListCurrentWithNum(); continue;
583  }
584  else if(j==0){break;}
585  else if(j>0){
586  int n_tree = floor[iFloor]->GetTreeEntry();
587  if(j>n_tree){
588  if(j<=n_tree+floor[iFloor]->GetCommandEntry()){
589  floor[iFloor]->GetCommand(j-n_tree)->List();
590  }
591  }
592  else{
593  floor[iFloor+1] = floor[iFloor]->GetTree(j);
594  iFloor++;
595  floor[iFloor]->ListCurrentWithNum();
596  }
597  }
598  }
599  G4cout<<"Exit from Help."<<G4endl <<G4endl;
600  G4cout<<G4endl;
601  char temp[100];
602  G4cin.getline(temp,100);
603 }
604 
605 
609  G4String newPrefix = prefix;
610  while(1){
611  if(newCommand(0,2) ==".."){
612  if(newPrefix !="/"){
613  G4String tmpString = newPrefix(0,newPrefix.length()-1);
614  newPrefix = newPrefix(0,tmpString.last('/')+1);
615  }
616  }
617  else{
618  newPrefix += newCommand;
619  break;
620  }
621  if(newCommand == ".." || newCommand == "../"){
622  break;
623  }
624  newCommand=newCommand(3,newCommand.length()-3);
625  }
626  return newPrefix;
627 }
628 
632  G4UIcommandTree * comTree = UI->GetTree();
633  /*int*/ unsigned idx = 1;
634  while( idx < newCommand.length()-1 )
635  {
636  int i = newCommand.index("/",idx);
637  comTree = comTree->GetTree(G4String(newCommand(0,i+1)));
638  if( comTree == NULL )
639  { return NULL; }
640  idx = i+1;
641  }
642  return comTree;
643 }
644 
646 
650  if( tree == NULL ) {
651  G4cerr << "GetTree() returnes null." << G4endl;
652  return;
653  }
654  if (uiMode == java_mode){
655  G4cout << "@@JTreeBegin" << G4endl;
656  CodeGenJavaTree(tree, 0);
657  G4cout << "@@JTreeEnd" << G4endl;
658  CodeGenJavaParams(tree, 0);
659  }else{}
660 }
661 
665  if( tree == NULL ) {
666  G4cerr << "GetTree() returnes null." << G4endl;
667  return;
668  }
669  if (uiMode == java_mode){
670  CodeGenJavaParams(tree, 0);
671  }else{ }
672 }
673 
677  int treeEntry, commandEntry;
678  treeEntry = tree->GetTreeEntry();
679  commandEntry = tree->GetCommandEntry();
680 
681  if(level!=0) {
682  for(int i=0; i<commandEntry; i++){
683  G4cout << tree->GetCommand(i+1)->GetCommandPath() << G4endl;
684  }
685  }
686  if(treeEntry == 0) return; //end recursion
687 
688  for(int j=0; j<treeEntry; j++){
689  CodeGenJavaTree(tree->GetTree(j+1), level+1);
690  }
691 }
692 
696  int treeEntry,commandEntry,i;
697  G4UIcommandTree* treeLink;
698 
699  treeEntry = tree->GetTreeEntry();
700  commandEntry = tree->GetCommandEntry();
701 
702  for(i=0;i<commandEntry; i++){
703  SendAParamProperty(tree->GetCommand(i+1));
704  }
705  if(treeEntry ==0) return;
706 
707  for(i=0;i<treeEntry; i++){
708  treeLink = tree->GetTree(i+1);
709  G4cout<<"@@JDirGuieBegin"<<G4endl;
710  G4cout<<treeLink->GetPathName()<<G4endl <<treeLink->GetTitle()<<G4endl;
711  G4cout<<"@@JDirGuideEnd"<<G4endl;
712  CodeGenJavaParams(treeLink,level+1);
713  }
714 }
715 
719  int guidanceEntry, parameterEntry;
720  G4String title, title2;
721  G4UIparameter * prp;
722  char c[2];
723  guidanceEntry = Comp->GetGuidanceEntries();
724  parameterEntry = Comp->GetParameterEntries();
725  G4cout << "@@JParamBegin" << G4endl;
726  G4cout << Comp->GetCommandPath() << G4endl;
727  G4cout << guidanceEntry << G4endl;
728  for (int j=0; j<guidanceEntry; j++){
729  title = Comp->GetGuidanceLine(j);
730  title2 = "";
731  if (title != ""){
732  for(int i=0; i< (int)title.length(); i++){
733  c[0]=title(i);
734  c[1]= '\0';
735  if ( c[0] == '\n' || c[0] == '\r') {
736  c[0]= ' ';
737  }
738  title2.append(c);
739  }
740  }
741  G4cout << title2 << G4endl;
742  }
743  G4cout << Comp->GetRange() << G4endl;
744  G4cout << parameterEntry << G4endl;
745  for( int par=0; par<parameterEntry; par++) {
746  prp = (G4UIparameter *)Comp->GetParameter(par);
747  G4cout << prp->GetParameterName() << G4endl;
748  G4cout << prp->GetParameterGuidance() << G4endl;
749  G4cout << prp->GetParameterType() << G4endl;
750  G4cout << prp->IsOmittable() << G4endl;
751  G4cout << prp->GetDefaultValue() << G4endl;
752  G4cout << prp->GetParameterRange() << G4endl;
753  G4cout << prp->GetParameterCandidates() << G4endl;
754  }
755  G4cout << "@@JParamEnd" << G4endl;
756 }
757 
761  int treeEntry, commandEntry;
762  G4UIcommand * Comp;
763  treeEntry = tree->GetTreeEntry();
764  commandEntry = tree->GetCommandEntry();
765 
766  for(int com=0; com<commandEntry; com++) {
767  Comp = tree->GetCommand(com+1);
768  if( Comp->IsAvailable()==false ) {
769  G4cout << Comp->GetCommandPath()<<G4endl;
770  }
771  }
772  if( treeEntry == 0 ) return; // end recursion
773 
774  for( int i=0; i<treeEntry; i++) {
775  SendDisableList(tree->GetTree(i+1), level+1);
776  // be sure the function name is the same
777  }
778 }
779 
780 
781 
782 //####### update check routines ####################################
783 
787 {
788  static G4ThreadLocal G4ApplicationState *previousState_G4MT_TLS_ = 0 ; if (!previousState_G4MT_TLS_) {previousState_G4MT_TLS_ = new G4ApplicationState ; *previousState_G4MT_TLS_= G4State_PreInit ; } G4ApplicationState &previousState = *previousState_G4MT_TLS_;
789  G4ApplicationState newState;
791  newState = statM->GetCurrentState();
792  if( newState != previousState )
793  {
795  previousState = newState;
796  }
797 }
798 
802 {
803  G4String stateString;
805  G4UIcommandTree * tree = UI->GetTree();
806  stateString = statM->GetStateString(statM->GetCurrentState());
807  if ( uiMode != terminal_mode ){
808  G4cout << "@@State \"" << stateString << "\"" << G4endl;
809  G4cout << "@@DisableListBegin"<<G4endl;
810  SendDisableList(tree, 0);
811  G4cout << "@@DisableListEnd" <<G4endl;
812  }
813 }
814 
818 {
819  G4UIcommandTree * tree = UI->GetTree();
820  SendCommandProperties(tree);
821 }
822 
826 {
827  SendAParamProperty(com);
828 }
829 
833  int added=0, deleted=0;
834  int pEntry= previousTreeCommands.size();
835  int nEntry= newTreeCommands.size();
836  int i,j;
837  for( i=0; i<pEntry; i++) { // check deleted command(s)
838  for( j=0; j<nEntry; j++) {
839  if( previousTreeCommands[i] == newTreeCommands[j]) break;
840  }
841  if( j==nEntry ) {
842  deleted = 1;
843  //G4cout <<"deleted: "<< previousTreeCommands(i) << G4endl;
844  }
845  }
846  for( i=0; i<nEntry; i++) { // check added command(s)
847  for( j=0; j<pEntry; j++) {
848  if( newTreeCommands[i] == previousTreeCommands[j]) break;
849  }
850  if( j==pEntry ) {
851  added = 1;
852  // G4cout <<"added: "<< newTreeCommands(i) << G4endl;
853  }
854  }
855  if( added && deleted==0 ) {G4cout<<"c added"<<G4endl;return added;}
856  if( added==0 && deleted ) {G4cout<<"c deleted"<<G4endl;return deleted;}
857  if( added && deleted ) {G4cout<<"c add/deleted"<<G4endl;return addedAndDeleted;}
858  return notChanged;
859 }
860 
864  G4String commandPath;
865  G4String title;
866  G4String pathName; //tree name
867  G4UIcommandTree * t;
868  int treeEntry = tree->GetTreeEntry();
869  int commandEntry = tree->GetCommandEntry();
870 
871  if( level==0 ) { newTreeCommands.clear();}
872  for(int com=0; com<commandEntry; com++){
873  commandPath = tree->GetCommand(com+1)->GetCommandPath();
874  title = tree->GetCommand(com+1)->GetTitle();
875  newTreeCommands.push_back( commandPath + " " + title );
876  }
877 
878  if(treeEntry == 0) return; //end recursion
879 
880  for(int i=0; i< treeEntry; i++){
881  t = tree->GetTree(i+1);
882  pathName = t->GetPathName();
883  title = t->GetTitle();
884  newTreeCommands.push_back( pathName + " " + title );
885  GetNewTreeStructure(t, level+1);
886  }
887 }
888 
892  // call NotifyParameterUpdate() if the value of each
893  // command/parameter is updated.
894  // assuming the command structure is not changed.
895  int pEntry= previousTreeParams.size();
896  int nEntry= newTreeParams.size();
897  int i;
898  G4UIcommand* Comp;
899  if (pEntry != nEntry) return;
900  for( i=0; i<nEntry; i++) {
901  if( previousTreeParams[i] != newTreeParams[i]){
902  Comp = newTreePCP[i];
903  G4cout << Comp->GetCommandPath()
904  << " command is updated." <<G4endl;
905  NotifyParameterUpdate(Comp);
906  }
907  }
908 }
909 
911 void G4UIGainServer::GetNewTreeValues( G4UIcommandTree * tree, int level){ // recursive
913  G4String commandPath;
914  G4String pathName; //tree name
915  G4UIcommandTree * t;
916  int parameterEntry;
917  int treeEntry = tree->GetTreeEntry();
918  int commandEntry = tree->GetCommandEntry();
919  G4UIcommand * Comp;
920  G4UIparameter * prp;
921  G4String param, str(" ");
922 
923  if( level==0 ) { newTreeParams.clear(); }
924  for(int com=0; com<commandEntry; com++) {
925  Comp = tree->GetCommand(com+1);
926  commandPath = Comp->GetCommandPath();
927  parameterEntry = Comp->GetParameterEntries();
928  param = commandPath +" ";
929  for( int par=0; par< parameterEntry; par++) {
930  prp = (G4UIparameter *)Comp->GetParameter(par);
931  param += prp->GetParameterName() +" ";
932  str(0) = prp->GetParameterType();
933  param += str + " ";
934  param += prp->GetDefaultValue() +" ";
935  param += prp->GetParameterRange() +" ";
936  param += prp->GetParameterCandidates();
937  }
938  newTreeParams.push_back( param + "\n");
939  newTreePCP.push_back( Comp );
940  }
941  if( treeEntry == 0 ) return; // end recursion
942  for( int i=0; i< treeEntry; i++) {
943  t = tree->GetTree(i+1);
944  GetNewTreeValues(t, level+1);
945  }
946 }
947 
948 
949 #endif
950 
951 
952 
953 
954 
955 
956 
957 
958 
959 
960 
961 
const XML_Char int len
Definition: expat.h:262
void SendDisableList(G4UIcommandTree *, int recursiveLevel)
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:208
G4String & remove(str_size)
const G4String GetTitle() const
Definition: G4UIcommand.hh:170
G4bool isNull() const
#define G4cin
Definition: G4ios.hh:60
virtual void PauseSessionStart(const G4String &msg)
void CodeGenJavaParams(G4UIcommandTree *, int recursiveLevel)
void NotifyParameterUpdate(G4UIcommand *)
void NotifyStateChange(void)
virtual void ExecuteCommand(const G4String &aCommand)
G4UIcommandTree * FindDirPath(G4String)
void GetNewTreeStructure(G4UIcommandTree *, int recursiveLevel)
void SendAParamProperty(G4UIcommand *)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:466
void WaitingConnection()
#define G4endl
Definition: G4ios.hh:61
std::istream & readLine(std::istream &, G4bool skipWhite=true)
std::vector< G4UIcommand * > newTreePCP
const G4String GetPathName() const
const G4String & GetGuidanceLine(G4int i) const
Definition: G4UIcommand.hh:137
#define DEFAULT_PORT
char GetParameterType() const
G4UIsession * SessionStart()
G4String GetDefaultValue() const
char buf[1024]
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:145
G4String GetParameterCandidates() const
str_size index(const char *, G4int pos=0) const
virtual G4int ReceiveG4cout(const G4String &coutString)
G4int GetGuidanceEntries() const
Definition: G4UIcommand.hh:135
void CodeGenJavaTree(G4UIcommandTree *, int recursiveLevel)
#define G4ThreadLocal
Definition: tls.hh:69
G4String GetParameterRange() const
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
struct sockaddr_in saddr
void ListCurrentWithNum() const
G4String GetCommand()
G4String GetPreviousCommand(G4int i) const
Definition: G4UImanager.hh:233
G4String SolveAlias(const char *aCmd)
Definition: G4UImanager.cc:411
virtual void ExitHelp() const
G4UIcommand * GetCommand(G4int i)
void UpdateParamVal(void)
bool G4bool
Definition: G4Types.hh:79
G4String GetCurrentValues(const char *aCommand)
Definition: G4UImanager.cc:190
std::vector< G4UIcommand * > previousTreePCP
void GetNewTreeValues(G4UIcommandTree *, int recursiveLevel)
const G4String GetParameterGuidance() const
G4String promptCharacter
Definition: G4UIGAG.hh:45
G4String GetStateString(G4ApplicationState aState) const
#define FALSE
Definition: globals.hh:52
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
G4String strip(G4int strip_Type=trailing, char c=' ')
#define TRUE
Definition: globals.hh:55
void UpdateState(void)
const G4ThreeVector const G4double const
void ListDirectory(G4String)
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:139
G4GLOB_DLL std::ostream G4cerr
G4String ModifyPrefix(G4String)
void NotifyCommandUpdate(void)
struct sockaddr_in caddr
void SetCoutDestination(G4UIsession *const value)
Definition: G4UImanager.cc:653
std::string::size_type str_size
virtual G4int ReceiveG4cerr(const G4String &cerrString)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
std::vector< G4String > newTreeCommands
int CommandUpdated(void)
virtual void List()
Definition: G4UIcommand.cc:351
int G4int
Definition: G4Types.hh:78
void SendParameterProperties(G4UIcommandTree *)
G4int last(char) const
G4ApplicationState GetCurrentState() const
void ShowCurrent(G4String)
in close()
void ListCurrent() const
G4int GetCommandEntry() const
virtual G4bool GetHelpChoice(G4int &aInt)
G4bool IsOmittable() const
G4int GetParameterEntries() const
Definition: G4UIcommand.hh:143
G4GLOB_DLL std::ostream G4cout
G4UImanager * UI
G4int GetTreeEntry() const
G4ApplicationState
std::vector< G4String > previousTreeParams
void ChangeDirectory(G4String)
G4String GetFullPath(G4String)
std::vector< G4String > previousTreeCommands
#define SOCK_NAME
G4String & prepend(const char *)
G4int GetNumberOfHistory() const
Definition: G4UImanager.hh:231
const G4String GetTitle() const
G4bool IsAvailable()
Definition: G4UIcommand.cc:292
G4String & append(const G4String &)
void SendCommandProperties(G4UIcommandTree *)
G4UIcommand * FindPath(const char *commandPath) const
void TerminalHelp(G4String)
G4String GetParameterName() const
const G4String & GetRange() const
Definition: G4UIcommand.hh:133
void SetSession(G4UIsession *const value)
Definition: G4UImanager.hh:215
static G4StateManager * GetStateManager()
G4UIcommandTree * GetTree(G4int i)
std::vector< G4String > newTreeParams