00001
00002
00003
00004
00005
00006
00008 #include <MessageService/MsgService.h>
00009
00010 #include "JobCModule.h"
00011 #include "JobCommand.h"
00012 #include "JobCResult.h"
00013 #include "JobCInputModule.h"
00014 #include "JobCPath.h"
00015
00016 CVSID("$Id: JobCModule.cxx,v 1.32 2006/04/07 18:29:53 boehm Exp $");
00017
00018
00019 static const char *gsMessage = "Module does not implement: ";
00020
00021
00022
00023 JobCModule::JobCModule() : fName(""), fConfig(false), fPath(0) { }
00024
00025
00026
00027 void JobCModule::Init(const char* name)
00028 {
00029 fName = name;
00030
00031
00032
00033 Registry r = this->DefaultConfig();
00034 this->GetConfig().UnLockValues();
00035 this->GetConfig() = r;
00036 this->GetConfig().SetName(r.GetName());
00037 this->Config(this->GetConfig());
00038
00039 this->GetConfig().LockKeys();
00040 }
00041
00042
00043
00044 JobCModule::~JobCModule() {}
00045
00046
00047
00048 const char *JobCModule::GetName() const { return fName.c_str(); }
00049
00050 const char* JobCModule::GetUniqueName() const
00051 {
00052 const char* name=0;
00053 if (!fConfig.Get("UniqueName",name)) return 0;
00054 return name;
00055 }
00056
00057
00058
00059 void JobCModule::BeginJob() {
00060 MSG("JobC",Msg::kDebug) <<
00061 "JobCModule::BeginJob for module " << this->GetName() << "\n";
00062 }
00063
00064
00065
00066 void JobCModule::EndJob() {
00067 MSG("JobC",Msg::kDebug) <<
00068 "JobCModule::End for module " << this->GetName() << "\n";
00069 }
00070
00071
00072
00073 void JobCModule::BeginFile() {
00074 MSG("JobC",Msg::kDebug) <<
00075 "JobCModule::BeginFile for module " << this->GetName() << "\n";
00076 }
00077
00078
00079
00080 void JobCModule::EndFile() {
00081 MSG("JobC",Msg::kDebug) <<
00082 "JobCModule::EndFile for module " << this->GetName() << "\n";
00083 }
00084
00085
00086
00087 void JobCModule::BeginRun()
00088 {
00089 MSG("JobC",Msg::kDebug) <<
00090 "JobCModule::BeginRun for module " << this->GetName() << "\n";
00091 }
00092
00093
00094
00095 void JobCModule::EndRun()
00096 {
00097 MSG("JobC",Msg::kDebug) <<
00098 "JobCModule::EndRun for module " << this->GetName() << "\n";
00099 }
00100
00101
00102
00103 JobCInputModule* JobCModule::GetJobCInputModule() const
00104 {
00105 if (!fPath) {
00106 MSG("JobC",Msg::kWarning)
00107 << fName << " has no associated JobCPath" << endl;
00108 return 0;
00109 }
00110 JobCInputModule* m = fPath->GetInputModule();
00111 if (!m) {
00112 MSG("JobC",Msg::kWarning)
00113 << "the associated path for " << fName
00114 << " has no input module" << endl;
00115 return 0;
00116 }
00117 return m;
00118 }
00119
00120
00121
00122 Int_t JobCModule::GetCurrentRun() const
00123 {
00124 JobCInputModule* m = GetJobCInputModule();
00125 if (!m) return -1;
00126 return m->GetCurrentRun();
00127 }
00128
00129 Int_t JobCModule::GetLastRun() const
00130 {
00131 JobCInputModule* m = GetJobCInputModule();
00132 if (!m) return -1;
00133 return m->GetLastRun();
00134 }
00135
00136
00137
00138 const char* JobCModule::GetCurrentFile(const char* streamname) const
00139 {
00140 JobCInputModule* m = GetJobCInputModule();
00141 if (!m) return "";
00142 return m->GetCurrentFile(streamname);
00143 }
00144
00145 const char* JobCModule::GetLastFile(const char* streamname) const
00146 {
00147 JobCInputModule* m = GetJobCInputModule();
00148 if (!m) return "";
00149 return m->GetLastFile(streamname);
00150 }
00151
00152
00153
00154 const Registry& JobCModule::DefaultConfig() const
00155 {
00156 MSG("JobC",Msg::kDebug) <<
00157 "JobCModule::DefaultConfig for module " << this->GetName() << "\n";
00158
00159 static const Registry r;
00160 return r;
00161 }
00162
00163
00164
00165 void JobCModule::Config(const Registry& r)
00166 {
00167 MSG("JobC",Msg::kDebug) <<
00168 "JobCModule::Config for module " << this->GetName() << "\n";
00169
00170
00171 bool islocked = this->GetConfig().ValuesLocked();
00172 if (islocked) this->GetConfig().UnLockValues();
00173 this->GetConfig() = r;
00174 if (islocked) this->GetConfig().LockValues();
00175 }
00176
00177
00178
00179
00180 JobCResult JobCModule::Get(MomNavigator * )
00181 {
00182
00183
00184
00185 MSG("JobC", Msg::kError) << gsMessage << "'Get'\n";
00186 return JobCResult::kError;
00187 }
00188
00189
00190
00191 JobCResult JobCModule::Put(const MomNavigator * )
00192 {
00193
00194
00195
00196 MSG("JobC", Msg::kError) << gsMessage << "'Put'\n";
00197 return JobCResult::kError;
00198 }
00199
00200
00201
00202 JobCResult JobCModule::Ana(const MomNavigator * )
00203 {
00204
00205
00206
00207 MSG("JobC", Msg::kError) << gsMessage << "'Ana'\n";
00208 return JobCResult::kError;
00209 }
00210
00211
00212
00213 JobCResult JobCModule::Reco(MomNavigator * )
00214 {
00215
00216
00217
00218 MSG("JobC", Msg::kError) << gsMessage << "'Reco'\n";
00219 return JobCResult::kError;
00220 }
00221
00222
00223
00224 void JobCModule::Cmd(const char* cmd)
00225 {
00226
00227
00228
00229 JobCommand c(cmd);
00230 this->HandleCommand(&c);
00231 }
00232
00233
00234
00235 void JobCModule::HandleCommand(JobCommand *command)
00236 {
00237
00238
00239
00240 if (command) {
00241 MSG("JobC", Msg::kWarning)
00242 << gsMessage << "'HandleCommand': " << command->PopCmd() << endl;
00243 }
00244 else {
00245 MSG("JobC", Msg::kWarning) << gsMessage << "'HandleCommand':\n";
00246 }
00247 }
00248
00249
00250
00251 void JobCModule::Help()
00252 {
00253
00254
00255
00256 MSG("JobC", Msg::kWarning) <<
00257 "No help available for module '" << this->GetName() << "'\n";
00258 }
00259
00260
00261
00262 void JobCModule::Report()
00263 {
00264
00265
00266
00267 MsgStream& m = MSGSTREAM("JobCReport",Msg::kInfo);
00268 m << this->GetName() << " configured with: " << std::endl;
00269 this->GetConfig().PrettyPrint(std::cout);
00270 }
00271
00272
00273
00274 void JobCModule::Reset()
00275 {
00276
00277 this->Config(this->DefaultConfig());
00278 }
00279
00280
00281
00282 void JobCModule::Set(const char* s)
00283 {
00284
00285
00286
00287
00288
00289
00290 Registry r;
00291 JobCommand::StringToRegistry(r,s);
00292
00293
00294 this->GetConfig().UnLockValues();
00295 this->GetConfig().Merge(r);
00296 this->GetConfig().LockValues();
00297
00298
00299 this->Config(this->GetConfig());
00300
00301
00302
00303 }
00304
00305
00306
00307 void JobCModule::Set(JobCDialog* d)
00308 {
00309
00310
00311
00312 bool deleted = false;
00313 if (d == 0) {
00314 d = new JobCDialog();
00315 deleted = true;
00316 }
00317
00318
00319 d->SetDefault(this->DefaultConfig());
00320 d->SetCurrent(this->GetConfig());
00321
00322
00323 Registry r = d->Querry();
00324
00325
00326 this->GetConfig().UnLockValues();
00327 this->GetConfig().Merge(r);
00328 this->GetConfig().LockValues();
00329
00330 this->Config(this->GetConfig());
00331
00332
00333 if (deleted) { delete d; d=0; }
00334 }
00335
00336
00337 bool JobCModule::SetUniqueName(const char* name)
00338 {
00339 if (fConfig.KeyExists("UniqueName")) return false;
00340 bool locked = fConfig.KeysLocked();
00341 fConfig.UnLockKeys();
00342 fConfig.Set("UniqueName",name);
00343 if (locked) fConfig.LockKeys();
00344 return true;
00345 }
00346
00347
00348
00349 Registry& JobCModule::GetConfig()
00350 {
00351
00352
00353
00354
00355
00356
00357
00358 return fConfig;
00359 }
00360