#include <JobCPathHandler.h>
Public Member Functions | |
| JobCPathHandler (JobCPath *p) | |
| ~JobCPathHandler () | |
| void | HandleCommand (JobCommand *cmd) |
Private Member Functions | |
| JobCPathHandler () | |
| void | PathRunCommand (JobCPath *p, JobCommand *cmd) |
| void | PathFilterCommand (JobCPath *p, JobCommand *cmd) |
| void | PathReportCommand (JobCPath *p, JobCommand *cmd) |
| void | PathResetCommand (JobCPath *p, JobCommand *cmd) |
Private Attributes | |
| JobCPath * | fPath |
Definition at line 14 of file JobCPathHandler.h.
| JobCPathHandler::JobCPathHandler | ( | JobCPath * | p | ) |
| JobCPathHandler::~JobCPathHandler | ( | ) |
| JobCPathHandler::JobCPathHandler | ( | ) | [private] |
| void JobCPathHandler::HandleCommand | ( | JobCommand * | cmd | ) |
Definition at line 40 of file JobCPathHandler.cxx.
References fPath, Msg::kWarning, MSG, PathFilterCommand(), PathReportCommand(), PathResetCommand(), PathRunCommand(), and JobCommand::PopCmd().
Referenced by JobController::HandleCommand().
00041 { 00042 //====================================================================== 00043 // Purpose: Switch yard for commands that act on paths as a whole 00044 // 00045 // Inputs: path - the job path to act on 00046 // cmd - the job command to use to decide how to act on the 00047 // path 00048 //====================================================================== 00049 const char *c = cmd->PopCmd(); 00050 if (c) { 00051 if (strcmp(c,"Run")==0) {this->PathRunCommand (fPath, cmd); return;} 00052 if (strcmp(c,"Filter")==0) {this->PathFilterCommand(fPath, cmd); return;} 00053 if (strcmp(c,"Report")==0) {this->PathReportCommand(fPath, cmd); return;} 00054 if (strcmp(c,"Reset")==0) {this->PathResetCommand (fPath, cmd); return;} 00055 MSG("JobC", Msg::kWarning) << 00056 "Unknown command '" << c << "'." << 00057 " Try one of the following:\n" << 00058 " Run,Filter,Report,Reset\n"; 00059 } 00060 }
| void JobCPathHandler::PathFilterCommand | ( | JobCPath * | p, | |
| JobCommand * | cmd | |||
| ) | [private] |
Definition at line 113 of file JobCPathHandler.cxx.
References JobCNode::FilterOff(), JobCNode::FilterOn(), JobCPath::FindNode(), JobCommand::HaveOpt(), Msg::kWarning, MSG, JobCommand::PopOpt(), JobCPath::ReverseAllFilters(), JobCNode::ReverseFilter(), JobCPath::SetAllFilters(), and JobCommand::SplitLine().
Referenced by HandleCommand().
00114 { 00115 //====================================================================== 00116 // Purpose: Process filter command 00117 //====================================================================== 00118 while (cmd->HaveOpt()) { 00119 const char* node = cmd->PopOpt(); 00120 const char* onOff = cmd->PopOpt(); 00121 if (node == 0 || onOff == 0) { 00122 MSG("JobC",Msg::kWarning) << 00123 "Usage: Filter <module>::<method> [on,reverse,off] ...\n" << 00124 " Filter all [on,off]\n"; 00125 return; 00126 } 00127 00128 string onOffs(onOff); 00129 string nodes(node); 00130 if (nodes == "ALL" || nodes == "all") { 00131 if (onOffs == "on" || onOffs == "ON") { 00132 p->SetAllFilters(true); 00133 return; 00134 } 00135 else if (onOffs == "reverse" || onOffs == "REVERSE") { 00136 p->ReverseAllFilters(); 00137 return; 00138 } 00139 } 00140 00141 // Get the module method pair that describe the node 00142 string mod; 00143 string method; 00144 JobCommand::SplitLine(node,':',mod,method); 00145 JobCNode* nodep = p->FindNode(mod.c_str(), method.c_str()); 00146 if (nodep == 0) { 00147 MSG("JobC",Msg::kWarning) << 00148 "Can't find node " << mod << "::" << method << ". Skipped.\n"; 00149 } 00150 else { 00151 if (onOffs == "on" || onOffs == "ON") { 00152 nodep->FilterOn(); 00153 } 00154 else if (onOffs == "reverse" || onOffs == "REVERSE") { 00155 nodep->ReverseFilter(); 00156 } 00157 else { 00158 nodep->FilterOff(); 00159 } 00160 } 00161 } 00162 }
| void JobCPathHandler::PathReportCommand | ( | JobCPath * | p, | |
| JobCommand * | cmd | |||
| ) | [private] |
Definition at line 166 of file JobCPathHandler.cxx.
References Msg::kInfo, and MSG.
Referenced by HandleCommand().
00167 { 00168 //====================================================================== 00169 // Purpose: Print the status of a given path 00170 //====================================================================== 00171 MSG("JobC",Msg::kInfo) << (*p) << endl; 00172 }
| void JobCPathHandler::PathResetCommand | ( | JobCPath * | p, | |
| JobCommand * | cmd | |||
| ) | [private] |
Definition at line 176 of file JobCPathHandler.cxx.
References sorry().
Referenced by HandleCommand().
00178 { 00179 sorry("PathResetCommand"); 00180 }
| void JobCPathHandler::PathRunCommand | ( | JobCPath * | p, | |
| JobCommand * | cmd | |||
| ) | [private] |
Definition at line 64 of file JobCPathHandler.cxx.
References JobCPath::GetName(), JobCommand::HaveOpt(), Msg::kWarning, MSG, Munits::nm, JobCommand::PopOpt(), JobCPath::Run(), JobCPath::RunNfail(), JobCPath::RunNin(), and JobCPath::RunNpass().
Referenced by HandleCommand().
00065 { 00066 //====================================================================== 00067 // Purpose: handle a /<path>/Run [Nin,Npass,Nfail] [n] command 00068 // 00069 // Inputs: p - the path <path> 00070 // cmd - the job command 00071 //====================================================================== 00072 // Figure out how many options we've been given 00073 const char* c[2]; 00074 int nopt = 0; 00075 while (cmd->HaveOpt() && nopt<2) { 00076 c[nopt] = cmd->PopOpt(); 00077 ++nopt; 00078 } 00079 00080 // No options - run until there are no records left to process 00081 if (nopt == 0) { 00082 p->Run(); 00083 return; 00084 } 00085 00086 // One option -- assume this is some number of events to process 00087 if (nopt == 1) { 00088 int n = atoi(c[0]); 00089 p->RunNin(n); 00090 return; 00091 } 00092 00093 // Two options -- [Nin,Npass,Nfail] [# records] 00094 if (nopt == 2) { 00095 int n = atoi(c[1]); 00096 if (strcmp(c[0],"Nin")==0) { p->RunNin(n); return; } 00097 if (strcmp(c[0],"Npass")==0) { p->RunNpass(n); return; } 00098 if (strcmp(c[0],"Nfail")==0) { p->RunNfail(n); return; } 00099 } 00100 00101 // Errors fall through 00102 const char* nm = p->GetName(); 00103 MSG("JobC", Msg::kWarning) << 00104 "usage: \n" 00105 " " << nm << "/Run Nin [n] - run until n records have been input\n" << 00106 " " << nm << "/Run Npass [n] - run until n records pass\n" 00107 " " << nm << "/Run Nfail [n] - run until n records fail\n" 00108 " " << nm << "/Run [n] - same as /Run Nin [n]\n"; 00109 }
JobCPath* JobCPathHandler::fPath [private] |
1.4.7