57 UI-> SetSession(
this);
58 UI-> SetCoutDestination(
this);
82 UI-> SetSession(NULL);
83 UI-> SetCoutDestination(NULL);
125 strcpy(
buf,
"nowIdle");
134 if(aCommand.length()<2)
return;
137 if(aCommand.length()<2)
return;
139 G4int paramIndex = returnVal % 100;
142 G4int commandStatus = returnVal - paramIndex;
147 switch(commandStatus) {
164 G4cerr <<
"@@ErrResult \"illegal application state -- command refused.\"" <<
G4endl;
167 G4cout <<
"@@ErrResult \"Parameter Out of Range.\"" <<
G4endl;
170 G4cout <<
"@@ErrResult \"Parameter is wrong type and/or is not omittable.\""<<
G4endl;
173 G4cerr <<
"@@ErrResult \"Parameter is out of candidate.\"" <<
G4endl;
177 G4cerr <<
"command refused (" << commandStatus <<
")" <<
G4endl;
213 if (!
G4cin.good()) {
G4cin.clear(); newCommand = nullString;
iExit=
false;
break;}
216 if( newCommand.length() < 1) {
break; }
218 while( newCommand(newCommand.length()-1) ==
'_' )
221 newCommand.
remove(newCommand.length()-1);
223 if (!
G4cin.good()) {
G4cin.clear(); newCommand = nullString;
iExit=
false;
break;}
224 newCommand.
append(newLine);
228 if( nC.length() < 1) {
break; }
231 if( nC ==
"@@GainmodeJAVA" ) {
237 else if( nC ==
"@@GainmodeTcl" ) {
243 else if( nC(0) ==
'#' )
246 else if( nC ==
"ls" || nC(0,3) ==
"ls " )
248 else if( nC ==
"pwd" )
250 else if( nC(0,2) ==
"cd" || nC(0,3) ==
"cd " )
252 else if( nC ==
"help" || nC(0,5) ==
"help ")
254 else if( nC(0) ==
'?' )
256 else if( nC(0,4) ==
"hist" || nC ==
"history")
259 for(
int i=0;i<nh;i++)
262 else if( nC(0) ==
'!' )
267 std::istringstream is((
char*)tt);
277 {
G4cerr <<
"history " << vl <<
" is not found." <<
G4endl; }
279 else if( nC(0,4) ==
"exit" )
285 G4cerr <<
"Please abrot it using \"/run/abort\" command first" <<
G4endl;
286 G4cerr <<
" and use \"continue\" command until the application" <<
G4endl;
289 G4cout <<
"@@ErrResult \"You are now processing RUN.\"" <<
G4endl;
297 newCommand = nullString;
301 else if( nC ==
"cont" || nC ==
"continue" )
304 newCommand = nullString;
318 write(
socketD[1],coutString,coutString.length());
331 write(
socketD[2],cerrString,cerrString.length());
346 G4cin.ignore(30,
'\n');
357 G4cin.getline(temp, 100);
364 socketD[0] = socket(AF_INET,SOCK_STREAM,0);
367 perror(
"server:socket");
374 saddr.sin_family = AF_INET;
375 saddr.sin_addr.s_addr = INADDR_ANY;
400 for(
int i=1;i<=2;i++){
401 #if defined __APPLE__ && (__GNUC__<4)
411 "Invalid Socket. Cannot establish connection");
422 if( newCommand(0) ==
'/' )
423 { tmpString = newCommand; }
424 else if( newCommand(0,3) ==
"../" )
427 unsigned i_direc = 0;
428 while( i_direc < newCommand.length() )
430 if( newCommand(i_direc,3) ==
"../" )
439 tmpString.
append( newCommand( i_direc, newCommand.length()-i_direc ) );
445 tmpString.
append( newCommand );
462 if( ! (curV.
isNull()||curV(0)==
'\0' ) ) {
464 G4cout <<
"Current value(s) of the parameter(s) : " << curV <<
G4endl;
471 G4cout <<
"@@ErrResult \"Current value is not available.\"" <<
G4endl;
479 if( newCommand.length() <= 3 )
483 G4String aNewPrefix = newCommand(3,newCommand.length()-3);
485 if( newPrefix(0) ==
'/' )
487 else if( newPrefix(0) !=
'.' )
506 if( newCommand.length() <= 3 )
510 G4String newPrefix = newCommand(3,newCommand.length()-3);
512 if( newPrefix(0) ==
'/' )
513 { targetDir = newPrefix; }
514 else if( newPrefix(0) !=
'.' )
517 targetDir += newPrefix;
522 if( targetDir( targetDir.length() - 1 ) !=
'/' )
523 { targetDir +=
"/"; }
525 if( commandTree == NULL )
526 {
G4cout <<
"Directory <" << targetDir <<
"> is not found." <<
G4endl; }
537 if(i!=std::string::npos){
538 G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
540 if(newValue(0)!=
'/'){
544 if(theCommand !=NULL){
549 G4cout<<
"Command<" << newValue <<
"is not found."<<
G4endl;
557 unsigned prefixIndex = 1;
558 while(prefixIndex<
prefix.length()-1){
559 int ii =
prefix.index(
"/",prefixIndex);
568 G4cout<<
G4endl <<
"Type the number (0:end, -n:n level back) :"<<std::flush;
572 G4cin.ignore(30,
'\n');
577 if(iFloor <0) iFloor =0;
580 else if(j==0){
break;}
584 if(j<=n_tree+floor[iFloor]->GetCommandEntry()){
589 floor[iFloor+1] = floor[iFloor]->
GetTree(j);
598 G4cin.getline(temp,100);
607 if(newCommand(0,2) ==
".."){
609 G4String tmpString = newPrefix(0,newPrefix.length()-1);
610 newPrefix = newPrefix(0,tmpString.
last(
'/')+1);
614 newPrefix += newCommand;
617 if(newCommand ==
".." || newCommand ==
"../"){
620 newCommand=newCommand(3,newCommand.length()-3);
630 while( idx < newCommand.length()-1 )
632 int i = newCommand.
index(
"/",idx);
634 if( comTree == NULL )
673 int treeEntry, commandEntry;
678 for(
int i=0; i<commandEntry; i++){
682 if(treeEntry == 0)
return;
684 for(
int j=0; j<treeEntry; j++){
692 int treeEntry,commandEntry,i;
698 for(i=0;i<commandEntry; i++){
701 if(treeEntry ==0)
return;
703 for(i=0;i<treeEntry; i++){
715 int guidanceEntry, parameterEntry;
724 for (
int j=0; j<guidanceEntry; j++){
728 for(
int i=0; i< (int)title.length(); i++){
731 if ( c[0] ==
'\n' || c[0] ==
'\r') {
741 for(
int par=0; par<parameterEntry; par++) {
757 int treeEntry, commandEntry;
762 for(
int com=0; com<commandEntry; com++) {
768 if( treeEntry == 0 )
return;
770 for(
int i=0; i<treeEntry; i++) {
788 if( newState != previousState )
791 previousState = newState;
804 G4cout <<
"@@State \"" << stateString <<
"\"" <<
G4endl;
833 for( i=0; i<pEntry; i++) {
834 for( j=0; j<nEntry; j++) {
842 for( i=0; i<nEntry; i++) {
843 for( j=0; j<pEntry; j++) {
868 for(
int com=0; com<commandEntry; com++){
874 if(treeEntry == 0)
return;
876 for(
int i=0; i< treeEntry; i++){
895 if (pEntry != nEntry)
return;
896 for( i=0; i<nEntry; i++) {
900 <<
" command is updated." <<
G4endl;
920 for(
int com=0; com<commandEntry; com++) {
924 param = commandPath +
" ";
925 for(
int par=0; par< parameterEntry; par++) {
937 if( treeEntry == 0 )
return;
938 for(
int i=0; i< treeEntry; i++) {
std::vector< G4UIcommand * > newTreePCP
void CodeGenJavaTree(G4UIcommandTree *, int recursiveLevel)
G4UIcommandTree * FindDirPath(G4String)
G4int GetNumberOfHistory() const
G4String GetParameterCandidates() const
const G4String & GetRange() const
G4String GetPreviousCommand(G4int i) const
G4String & remove(str_size)
void TerminalHelp(G4String)
G4UIcommand * FindPath(const char *commandPath) const
std::vector< G4String > previousTreeCommands
G4String strip(G4int strip_Type=trailing, char c=' ')
G4int GetCommandEntry() const
G4String GetParameterName() const
G4UIcommand * GetCommand(G4int i)
void CodeGenJavaParams(G4UIcommandTree *, int recursiveLevel)
G4int GetTreeEntry() const
std::string::size_type str_size
const G4String GetTitle() const
void SetSession(G4UIsession *const value)
std::istream & readLine(std::istream &, G4bool skipWhite=true)
virtual void PauseSessionStart(const G4String &msg)
const G4String & GetGuidanceLine(G4int i) const
static G4UImanager * GetUIpointer()
G4bool IsOmittable() const
void NotifyParameterUpdate(G4UIcommand *)
G4String & prepend(const char *)
virtual void ExecuteCommand(const G4String &aCommand)
void GetNewTreeStructure(G4UIcommandTree *, int recursiveLevel)
static G4StateManager * GetStateManager()
std::vector< G4UIcommand * > previousTreePCP
void SendAParamProperty(G4UIcommand *)
G4GLOB_DLL std::ostream G4cout
str_size index(const char *, G4int pos=0) const
G4UIcommandTree * GetTree(G4int i)
virtual G4int ReceiveG4cerr(const G4String &cerrString)
void SendCommandProperties(G4UIcommandTree *)
virtual G4int ReceiveG4cout(const G4String &coutString)
G4UIparameter * GetParameter(G4int i) const
void ListCurrentWithNum() const
const G4String & GetCommandPath() const
G4ApplicationState GetCurrentState() const
virtual void ExitHelp() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void ShowCurrent(G4String)
std::vector< G4String > previousTreeParams
G4String GetCurrentValues(const char *aCommand)
const G4String GetPathName() const
std::vector< G4String > newTreeCommands
const G4String GetTitle() const
G4UIcommandTree * GetTree() const
G4String ModifyPrefix(G4String)
G4String & append(const G4String &)
G4String GetDefaultValue() const
void SetCoutDestination(G4UIsession *const value)
G4String SolveAlias(const char *aCmd)
char GetParameterType() const
void SendParameterProperties(G4UIcommandTree *)
void NotifyCommandUpdate(void)
G4String GetFullPath(G4String)
G4UIsession * SessionStart()
void NotifyStateChange(void)
const G4String GetParameterGuidance() const
void GetNewTreeValues(G4UIcommandTree *, int recursiveLevel)
std::vector< G4String > newTreeParams
G4String GetParameterRange() const
G4int GetGuidanceEntries() const
void UpdateParamVal(void)
void SendDisableList(G4UIcommandTree *, int recursiveLevel)
G4int GetParameterEntries() const
G4int ApplyCommand(const char *aCommand)
void ChangeDirectory(G4String)
G4GLOB_DLL std::ostream G4cerr
void ListDirectory(G4String)
G4String GetStateString(G4ApplicationState aState) const
virtual G4bool GetHelpChoice(G4int &aInt)