49 ss <<
"[ERROR] " << message << std::endl;
50 throw std::runtime_error(ss.str());
58 auto n_cmd = ctree-> GetCommandEntry();
59 for (
auto icmd = 1; icmd <= n_cmd; icmd++ ) {
60 auto cmd_path = ctree-> GetCommand(icmd)-> GetCommandPath();
64 auto n_tree = ctree-> GetTreeEntry();
65 for (
auto itr = 1; itr <= n_tree ; itr++ ) {
101 enum { kBufferSize = 4096 };
106 std::cout <<
"@@ Waiting..." << std::endl;
110 zmq::message_t request;
113 auto end_pos = request.size();
114 if ( end_pos >= kBufferSize ) end_pos = kBufferSize - 1;
115 std::memcpy(
buffer, request.data(), end_pos);
117 std::string cmd_str =
buffer;
120 std::cout <<
"@@ Recv=" << cmd_str <<
"<<" << std::endl;
126 if ( cmd_str ==
"@@ping" ) {
129 }
else if ( cmd_str ==
"@@debug") {
133 }
else if ( cmd_str ==
"@@nodebug") {
137 }
else if ( cmd_str ==
"@@get_command_tree" ) {
144 }
else if ( cmd_str ==
"@@get_fullcommand_tree" ) {
150 }
else if ( cmd_str ==
"help" ) {
157 << new_command <<
"<<" << std::endl;
163 size_t cout_size = reply.size();
164 zmq::message_t message(cout_size);
165 std::strncpy((
char*)message.data(), reply.c_str(), cout_size);
166 qok =
socket.send(message);
182 std::cout << coutString << std::flush;
194 std::cerr << cerrString << std::flush;
205 const std::string nullstr =
"";
209 if ( cstr.length() == 0 ) {
213 }
else if ( cstr[0] ==
'#' ) {
217 }
else if ( cstr ==
"ls" || cstr.substr(0,3) ==
"ls " ) {
221 }
else if ( cstr ==
"lc" || cstr.substr(0,3) ==
"lc " ) {
222 shell_-> ListCommand(cstr.erase(0,2));
225 }
else if (cstr ==
"pwd" ) {
226 G4cout <<
"Current Command Directory : "
230 }
else if ( cstr ==
"cwd" ) {
231 shell_-> ShowCurrentDirectory();
234 }
else if (cstr ==
"cd" || cstr.substr(0,3) ==
"cd " ) {
239 }
else if ( cstr ==
"help" || cstr.substr(0,5) ==
"help " ) {
243 }
else if ( cstr(0) ==
'?' ) {
247 }
else if ( cstr ==
"history" ) {
249 for (
auto i = 0; i < nh; i++) {
254 }
else if ( cstr ==
"exit" ) {
266 auto pcode = rc % 100;
267 auto status = rc - pcode;
277 <<
"> not found" <<
G4endl;
280 G4cerr <<
"illegal application state -- command refused" <<
G4endl;
286 G4cerr <<
"Parameter is out of candidate list (index "
287 << pcode <<
")" <<
G4endl;
289 << cmd-> GetParameter(pcode)-> GetParameterCandidates()
293 G4cerr <<
"Parameter is wrong type and/or is not omittable (index "
294 << pcode <<
")" <<
G4endl;
299 G4cerr <<
"command refused (" << status <<
")" <<
G4endl;
@ fParameterOutOfCandidates
@ fIllegalApplicationState
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
G4String GetPreviousCommand(G4int i) const
static G4UImanager * GetUIpointer()
G4UIcommand * FindCommand(const char *commandName) const
G4String ModifyToFullPathCommand(const char *aCommandLine) const
void ShowCurrent(const G4String &) const
void TerminalHelp(const G4String &)
void ListDirectory(const G4String &) const
G4String GetCurrentWorkingDirectory() const
void ChangeDirectoryCommand(const G4String &)
G4UIcommandTree * FindDirectory(const char *dirName) const
virtual G4int ReceiveG4cout(const G4String &coutString)
virtual void ExitHelp() const
G4String GetCommand(const G4String &input)
virtual G4UIsession * SessionStart()
virtual G4int ReceiveG4cerr(const G4String &cerrString)
virtual void ExecuteCommand(const G4String &command)
virtual G4bool GetHelpChoice(G4int &)
virtual void PauseSessionStart(const G4String &message)
G4String lstrip_copy(G4String str, char c=' ')
Return copy of string with leading characters removed.
std::stringstream cout_stream
void GetCommandTree(G4UIcommandTree *ctree)
void ThrowException(const std::string &message)