Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

JobCDisplayModule.cxx

Go to the documentation of this file.
00001 
00002 // $Id: JobCDisplayModule.cxx,v 1.6 2002/12/13 17:40:20 rhatcher Exp $
00003 //
00004 // Interface job control to an event display package
00005 //
00006 // messier@huhepl.harvard.edu
00008 #include "JobControl/JobCDisplayModule.h"
00009 #include <string>
00010 #include <cstring> // strlen
00011 #include "MessageService/MsgService.h"
00012 #include "JobControl/JobCResult.h"
00013 #include "JobControl/JobCEnv.h"
00014 #include "JobControl/JobCommand.h"
00015 #include "JobControl/JobCModuleRegistry.h"
00016 #include "JobControl/JobCModuleProxy.h"
00017 
00018 CVSID("$Id: JobCDisplayModule.cxx,v 1.6 2002/12/13 17:40:20 rhatcher Exp $");
00019 JOBMODULE(JobCDisplayModule,"Display","Event display interface");
00020 
00021 //......................................................................
00022 
00023 JobCDisplayModule::JobCDisplayModule() : fDisplayModule(0) { }
00024 
00025 //......................................................................
00026 
00027 JobCDisplayModule::~JobCDisplayModule() 
00028 { 
00029   if (fDisplayModule) this->Stop(0);
00030 }
00031 
00032 //......................................................................
00033 
00034 JobCResult JobCDisplayModule::Ana(const MomNavigator *mom) 
00035 { 
00036   if (fDisplayModule) {
00037     return fDisplayModule->Ana(mom);
00038   }
00039   return JobCResult::kAOK;
00040 }
00041 
00042 //......................................................................
00043 
00044 JobCResult JobCDisplayModule::Reco(MomNavigator *mom) 
00045 { 
00046   if (fDisplayModule) {
00047     return fDisplayModule->Reco(mom);
00048   }
00049   return JobCResult::kAOK;
00050 }
00051 
00052 //......................................................................
00053 
00054 void JobCDisplayModule::BeginJob()
00055 {
00056 //======================================================================
00057 // Executed at the start of a new job
00058 //======================================================================
00059   // Pass the begin job along to the display implementation
00060   if (fDisplayModule) {
00061     fDisplayModule->BeginJob();
00062   }
00063 }
00064 
00065 //......................................................................
00066 
00067 void JobCDisplayModule::EndJob() 
00068 {
00069 //======================================================================
00070 // Executed at the end of a job
00071 //======================================================================
00072   if (fDisplayModule) {
00073     fDisplayModule->EndJob();
00074   }
00075 }
00076 
00077 //......................................................................
00078 
00079 //======================================================================
00080 // These are just wrappers to the methods implemented by the display
00081 // module.
00082 //======================================================================
00083 void JobCDisplayModule::BeginFile() 
00084 {
00085   if (fDisplayModule) {
00086     fDisplayModule->BeginFile();
00087   }
00088 }
00089 
00090 //......................................................................
00091 
00092 void JobCDisplayModule::EndFile() 
00093 {
00094   if (fDisplayModule) {
00095     fDisplayModule->EndFile();
00096   }
00097 }
00098 
00099 //......................................................................
00100 
00101 void JobCDisplayModule::BeginRun() 
00102 {
00103   if (fDisplayModule) {
00104     fDisplayModule->BeginRun();
00105   }
00106 }
00107 
00108 //......................................................................
00109 
00110 void JobCDisplayModule::EndRun() 
00111 {
00112   if (fDisplayModule) {
00113     fDisplayModule->EndRun();
00114   }
00115 }
00116 
00117 //......................................................................
00118 
00119 void JobCDisplayModule::HandleCommand(JobCommand *command)
00120 {
00121 //======================================================================
00122 // Handle a parsed text command
00123 //======================================================================
00124   const char* cmd = command->PopCmd();
00125   if (command) {
00126     string cmds(cmd);
00127     if (cmd == "Start") {
00128       const char* dispname = command->PopOpt();
00129       this->Start(dispname);
00130       return;
00131     }
00132     if (cmd == "Stop") {
00133       const char* dispname = command->PopOpt();
00134       this->Stop(dispname);
00135       return;
00136     }
00137   }
00138   
00139   // See if the displays attached know what to do with the command
00140   if (fDisplayModule) {
00141     command->PushCmd();
00142     fDisplayModule->HandleCommand(command);
00143   }
00144 }
00145 
00146 //......................................................................
00147 
00148 void JobCDisplayModule::Help() 
00149 {
00150   static const char* help = 
00151     "General Display commands:\n"
00152     " /Display/Start <display-name>\n"
00153     " /Display/Stop  <display-name>\n";
00154   
00155   MSG("JobC",Msg::kInfo) << help << endl;
00156   if (fDisplayModule) {
00157     fDisplayModule->Help();
00158   }
00159 }
00160 
00161 //......................................................................
00162 
00163 void JobCDisplayModule::Report() 
00164 {
00165   if (fDisplayModule) {
00166     fDisplayModule->Report();
00167   }
00168 }
00169 
00170 //......................................................................
00171 
00172 void JobCDisplayModule::Reset() 
00173 {
00174   if (fDisplayModule) {
00175     fDisplayModule->Reset();
00176   }
00177 }
00178 
00179 //......................................................................
00180 
00181 JobCResult JobCDisplayModule::Get(MomNavigator* mom) 
00182 {
00183   if (fDisplayModule) {
00184     return fDisplayModule->Get(mom);
00185   }
00186   return JobCResult::kAOK;
00187 }
00188 
00189 //......................................................................
00190 
00191 JobCResult JobCDisplayModule::Put(const MomNavigator* mom) 
00192 {
00193   if (fDisplayModule) {
00194     return fDisplayModule->Put(mom);
00195   }
00196   return JobCResult::kAOK;
00197 }
00198 
00199 //......................................................................
00200 
00201 void JobCDisplayModule::Stop(const char* /* dispname */)
00202 {
00203 //======================================================================
00204 // Purpose: Stop a named event display -- currently only one allowed
00205 // at a time so "dispname" is not used
00206 //======================================================================
00207   fDisplayModule->EndJob();
00208   delete fDisplayModule;
00209   fDisplayModule = 0;
00210 }
00211 
00212 //......................................................................
00213 
00214 void JobCDisplayModule::Start(const char* display) 
00215 {
00216 //======================================================================
00217 // Purpose: Start a named event display
00218 //======================================================================
00219 
00220   // Figure out the name of the display to start - if none use default
00221   string disname; // name of display to start
00222   if (display != 0 && strlen(display)>0) {
00223     disname = display; // Use given name
00224   }
00225   else {
00226     disname = "MIDAD"; // Set default name
00227   }
00228   
00229   // If we have a display module active, delete it. This module could
00230   // in principle connect to multiple display modules, but for now
00231   // hard coded to be one and only one at a time.
00232   if (fDisplayModule) this->Stop(0);
00233 
00234   // Look up the proxy for the module
00235   JobCModuleProxy* prx = 
00236     JobCModuleRegistry::Instance().LookUp(disname.c_str());
00237   if (prx) {
00238     // Found the proxy - use it to create the module
00239     fDisplayModule = prx->CreateModule();
00240   }
00241   else {
00242     // No proxy found for the display module
00243     MSG("JobC",Msg::kWarning) << 
00244       "No display module '" << disname << "' found." << endl;
00245   }
00246 }
00247 

Generated on Mon Feb 15 11:06:48 2010 for loon by  doxygen 1.3.9.1