57 UI-> SetSession(
this);
58 UI-> SetCoutDestination(
this);
82 UI-> SetSession(NULL);
83 UI-> SetCoutDestination(NULL);
125 strcpy(
buf,
"nowIdle");
135 if(aCommand.length()<2)
return;
138 if(aCommand.length()<2)
return;
140 G4int paramIndex = returnVal % 100;
143 G4int commandStatus = returnVal - paramIndex;
148 switch(commandStatus) {
165 G4cerr <<
"@@ErrResult \"illegal application state -- command refused.\"" <<
G4endl;
168 G4cout <<
"@@ErrResult \"Parameter Out of Range.\"" <<
G4endl;
171 G4cout <<
"@@ErrResult \"Parameter is wrong type and/or is not omittable.\""<<
G4endl;
174 G4cerr <<
"@@ErrResult \"Parameter is out of candidate.\"" <<
G4endl;
178 G4cerr <<
"command refused (" << commandStatus <<
")" <<
G4endl;
215 if (!
G4cin.good()) {
G4cin.clear(); newCommand = nullString;
iExit=
false;
break;}
218 if( newCommand.length() < 1) {
break; }
220 while( newCommand(newCommand.length()-1) ==
'_' )
223 newCommand.
remove(newCommand.length()-1);
225 if (!
G4cin.good()) {
G4cin.clear(); newCommand = nullString;
iExit=
false;
break;}
226 newCommand.
append(newLine);
230 if( nC.length() < 1) {
break; }
233 if( nC ==
"@@GainmodeJAVA" ) {
239 else if( nC ==
"@@GainmodeTcl" ) {
245 else if( nC(0) ==
'#' )
248 else if( nC ==
"ls" || nC(0,3) ==
"ls " )
250 else if( nC ==
"pwd" )
252 else if( nC(0,2) ==
"cd" || nC(0,3) ==
"cd " )
254 else if( nC ==
"help" || nC(0,5) ==
"help ")
256 else if( nC(0) ==
'?' )
258 else if( nC(0,4) ==
"hist" || nC ==
"history")
261 for(
int i=0;i<nh;i++)
264 else if( nC(0) ==
'!' )
269 std::istringstream is((
char*)tt);
279 {
G4cerr <<
"history " << vl <<
" is not found." <<
G4endl; }
281 else if( nC(0,4) ==
"exit" )
287 G4cerr <<
"Please abrot it using \"/run/abort\" command first" <<
G4endl;
288 G4cerr <<
" and use \"continue\" command until the application" <<
G4endl;
291 G4cout <<
"@@ErrResult \"You are now processing RUN.\"" <<
G4endl;
299 newCommand = nullString;
303 else if( nC ==
"cont" || nC ==
"continue" )
306 newCommand = nullString;
320 ssize_t rc = write(
socketD[1],coutString,coutString.length());
334 ssize_t rc = write(
socketD[2],cerrString,cerrString.length());
350 G4cin.ignore(30,
'\n');
361 G4cin.getline(temp, 100);
368 socketD[0] = socket(AF_INET,SOCK_STREAM,0);
371 perror(
"server:socket");
378 saddr.sin_family = AF_INET;
379 saddr.sin_addr.s_addr = INADDR_ANY;
404 for(
int i=1;i<=2;i++){
405 #if defined __APPLE__ && (__GNUC__<4)
415 "Invalid Socket. Cannot establish connection");
426 if( newCommand(0) ==
'/' )
427 { tmpString = newCommand; }
428 else if( newCommand(0,3) ==
"../" )
431 unsigned i_direc = 0;
432 while( i_direc < newCommand.length() )
434 if( newCommand(i_direc,3) ==
"../" )
443 tmpString.
append( newCommand( i_direc, newCommand.length()-i_direc ) );
449 tmpString.
append( newCommand );
466 if( ! (curV.
isNull()||curV(0)==
'\0' ) ) {
468 G4cout <<
"Current value(s) of the parameter(s) : " << curV <<
G4endl;
475 G4cout <<
"@@ErrResult \"Current value is not available.\"" <<
G4endl;
483 if( newCommand.length() <= 3 )
487 G4String aNewPrefix = newCommand(3,newCommand.length()-3);
489 if( newPrefix(0) ==
'/' )
491 else if( newPrefix(0) !=
'.' )
510 if( newCommand.length() <= 3 )
514 G4String newPrefix = newCommand(3,newCommand.length()-3);
516 if( newPrefix(0) ==
'/' )
517 { targetDir = newPrefix; }
518 else if( newPrefix(0) !=
'.' )
521 targetDir += newPrefix;
526 if( targetDir( targetDir.length() - 1 ) !=
'/' )
527 { targetDir +=
"/"; }
529 if( commandTree == NULL )
530 {
G4cout <<
"Directory <" << targetDir <<
"> is not found." <<
G4endl; }
541 if(i!=std::string::npos){
542 G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
544 if(newValue(0)!=
'/'){
548 if(theCommand !=NULL){
553 G4cout<<
"Command<" << newValue <<
"is not found."<<
G4endl;
561 unsigned prefixIndex = 1;
562 while(prefixIndex<
prefix.length()-1){
563 int ii =
prefix.index(
"/",prefixIndex);
572 G4cout<<
G4endl <<
"Type the number (0:end, -n:n level back) :"<<std::flush;
576 G4cin.ignore(30,
'\n');
581 if(iFloor <0) iFloor =0;
584 else if(j==0){
break;}
588 if(j<=n_tree+floor[iFloor]->GetCommandEntry()){
593 floor[iFloor+1] = floor[iFloor]->
GetTree(j);
602 G4cin.getline(temp,100);
611 if(newCommand(0,2) ==
".."){
613 G4String tmpString = newPrefix(0,newPrefix.length()-1);
614 newPrefix = newPrefix(0,tmpString.
last(
'/')+1);
618 newPrefix += newCommand;
621 if(newCommand ==
".." || newCommand ==
"../"){
624 newCommand=newCommand(3,newCommand.length()-3);
634 while( idx < newCommand.length()-1 )
636 int i = newCommand.
index(
"/",idx);
638 if( comTree == NULL )
677 int treeEntry, commandEntry;
682 for(
int i=0; i<commandEntry; i++){
686 if(treeEntry == 0)
return;
688 for(
int j=0; j<treeEntry; j++){
696 int treeEntry,commandEntry,i;
702 for(i=0;i<commandEntry; i++){
705 if(treeEntry ==0)
return;
707 for(i=0;i<treeEntry; i++){
719 int guidanceEntry, parameterEntry;
728 for (
int j=0; j<guidanceEntry; j++){
732 for(
int i=0; i< (
int)title.length(); i++){
735 if ( c[0] ==
'\n' || c[0] ==
'\r') {
745 for(
int par=0; par<parameterEntry; par++) {
761 int treeEntry, commandEntry;
766 for(
int com=0; com<commandEntry; com++) {
772 if( treeEntry == 0 )
return;
774 for(
int i=0; i<treeEntry; i++) {
792 if( newState != previousState )
795 previousState = newState;
808 G4cout <<
"@@State \"" << stateString <<
"\"" <<
G4endl;
837 for( i=0; i<pEntry; i++) {
838 for( j=0; j<nEntry; j++) {
846 for( i=0; i<nEntry; i++) {
847 for( j=0; j<pEntry; j++) {
872 for(
int com=0; com<commandEntry; com++){
878 if(treeEntry == 0)
return;
880 for(
int i=0; i< treeEntry; i++){
899 if (pEntry != nEntry)
return;
900 for( i=0; i<nEntry; i++) {
904 <<
" command is updated." <<
G4endl;
924 for(
int com=0; com<commandEntry; com++) {
928 param = commandPath +
" ";
929 for(
int par=0; par< parameterEntry; par++) {
941 if( treeEntry == 0 )
return;
942 for(
int i=0; i< treeEntry; i++) {
void SendDisableList(G4UIcommandTree *, int recursiveLevel)
G4UIcommandTree * GetTree() const
G4String & remove(str_size)
const G4String GetTitle() const
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)
std::istream & readLine(std::istream &, G4bool skipWhite=true)
std::vector< G4UIcommand * > newTreePCP
const G4String GetPathName() const
const G4String & GetGuidanceLine(G4int i) const
char GetParameterType() const
G4UIsession * SessionStart()
G4String GetDefaultValue() const
G4UIparameter * GetParameter(G4int i) const
G4String GetParameterCandidates() const
str_size index(const char *, G4int pos=0) const
virtual G4int ReceiveG4cout(const G4String &coutString)
G4int GetGuidanceEntries() const
void CodeGenJavaTree(G4UIcommandTree *, int recursiveLevel)
G4String GetParameterRange() const
static G4UImanager * GetUIpointer()
void ListCurrentWithNum() const
G4String GetPreviousCommand(G4int i) const
G4String SolveAlias(const char *aCmd)
virtual void ExitHelp() const
G4UIcommand * GetCommand(G4int i)
void UpdateParamVal(void)
G4String GetCurrentValues(const char *aCommand)
std::vector< G4UIcommand * > previousTreePCP
void GetNewTreeValues(G4UIcommandTree *, int recursiveLevel)
const G4String GetParameterGuidance() const
G4String GetStateString(G4ApplicationState aState) const
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
G4String strip(G4int strip_Type=trailing, char c=' ')
const G4ThreeVector const G4double const
void ListDirectory(G4String)
const G4String & GetCommandPath() const
G4GLOB_DLL std::ostream G4cerr
G4String ModifyPrefix(G4String)
void NotifyCommandUpdate(void)
void SetCoutDestination(G4UIsession *const value)
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)
std::vector< G4String > newTreeCommands
void SendParameterProperties(G4UIcommandTree *)
G4ApplicationState GetCurrentState() const
void ShowCurrent(G4String)
G4int GetCommandEntry() const
virtual G4bool GetHelpChoice(G4int &aInt)
G4bool IsOmittable() const
G4int GetParameterEntries() const
G4GLOB_DLL std::ostream G4cout
G4int GetTreeEntry() const
std::vector< G4String > previousTreeParams
void ChangeDirectory(G4String)
G4String GetFullPath(G4String)
std::vector< G4String > previousTreeCommands
G4String & prepend(const char *)
G4int GetNumberOfHistory() const
const G4String GetTitle() const
G4String & append(const G4String &)
void SendCommandProperties(G4UIcommandTree *)
G4UIcommand * FindPath(const char *commandPath) const
void TerminalHelp(G4String)
G4String GetParameterName() const
const G4String & GetRange() const
void SetSession(G4UIsession *const value)
static G4StateManager * GetStateManager()
G4UIcommandTree * GetTree(G4int i)
std::vector< G4String > newTreeParams