#include <VisFramework/VisFrameworkBase/interface/VisMainProgram.h>
Definition at line 23 of file VisMainProgram.h.
VisMainProgram::VisMainProgram | ( | IgState * | state | ) |
Create and initialise a manager proxy to run the EventProcessor thread.
The thread is not started yet but things are left initialised such that it will start just before the Qt event loop begins processing and that it is safe to begin loading actual studio contents like visualisers and data proxies.
Definition at line 42 of file VisMainProgram.cc.
References ASSERT, lat::CreateCallback(), DBSPlugin::get(), init(), LFfwvis, LOG, m_state, IgState::put(), start(), and GsfMatrixTools::trace().
00043 : m_state (state), 00044 m_mainWindow (IgQtAppWindowService::get (state)->mainWindow ()) 00045 { 00046 LOG (0, trace, LFfwvis, "VisMainProgram::VisMainProgram\n"); 00047 00048 // Register ourselves into the state. 00049 ASSERT (m_state); 00050 m_state->put (s_key, this); 00051 00052 // Make sure the event queue is initialised. This needs to be 00053 // early enough so that data proxies can be created. 00054 if (! VisQueue::get (m_state)) 00055 new VisQueue (m_state); 00056 00057 init (); 00058 00059 // Auto-register to execute when studio starts running. 00060 ASSERT (IgQtAppLoopService::get (m_state)); 00061 IgQtAppLoopService::get (m_state)->prepare 00062 (lat::CreateCallback (this, &VisMainProgram::start)); 00063 }
VisMainProgram::~VisMainProgram | ( | void | ) |
This is assumed to be done late in application exit, and not before IgAtAppLoopService has ran its post-loop actions.
In other words, it is not valid to destroy this object when the CARFMain or the Qt event loop are still active.
Definition at line 154 of file VisMainProgram.cc.
References ASSERT, IgState::detach(), and m_state.
void VisMainProgram::cmsExceptionCallback | ( | cms::Exception * | e | ) |
Definition at line 295 of file VisMainProgram.cc.
References arg, IgArgsElement::argv(), hlt_scaler_cfg::critical, DBSPlugin::get(), m_mainWindow, m_state, and cms::Exception::what().
Referenced by init().
00296 { 00297 IgArgsElement *args = IgArgsElement::get (m_state); 00298 00299 IgQtLock (); 00300 QApplication::restoreOverrideCursor (); 00301 00302 // Make sure the event processor is finalized. 00303 if (VisEventProcessorService *procService = VisEventProcessorService::get (m_state)) 00304 { 00305 delete procService; 00306 } 00307 00308 QMessageBox::critical (m_mainWindow, "IGUANA", QString ("<p>CMS Exception caught in %1:</p>" 00309 "<p>%2</p>").arg (args->argv () [0]).arg (e->what ())); 00310 qApp->quit (); 00311 }
void VisMainProgram::configFailureCallback | ( | cms::Exception * | e | ) |
Definition at line 373 of file VisMainProgram.cc.
References IgArgsElement::arg(), arg, IgArgsElement::args(), IgArgsElement::argv(), GenMuonPlsPt100GeV_cfg::cout, hlt_scaler_cfg::critical, lat::endl(), aod_PYTHIA_cfg::fileName, IgArgsElement::find(), DBSPlugin::get(), LFfwvis, LOG, m_mainWindow, m_state, quit(), GsfMatrixTools::trace(), and cms::Exception::what().
Referenced by init().
00374 { 00375 LOG (0, trace, LFfwvis, "VisMainProgram::configFailureCallback() Failed to get a parameter set file.\n"); 00376 00377 IgArgsElement *args = IgArgsElement::get (m_state); 00378 std::vector <std::string> parameterSetOpts; 00379 parameterSetOpts.push_back ("--parameter-set"); 00380 parameterSetOpts.push_back ("-p"); 00381 std::string parameterSetFilename; 00382 args->find (parameterSetOpts, parameterSetFilename, false); 00383 00384 if (parameterSetFilename.empty () && (args->args () > 1)) 00385 { 00386 std::string fileName (args->arg (1)); 00387 parameterSetFilename = fileName; 00388 } 00389 00390 IgQtLock (); 00391 QApplication::restoreOverrideCursor (); 00392 00393 switch (QMessageBox::critical (m_mainWindow, "IGUANA", QString ("<p><b>Attention:</b> Please, check that \"%1\" does exist and " 00394 "its Python syntax is valid.</p>" 00395 "<p>Use <i>python -i yourFileName_cfg.py</i> to check the syntax " 00396 "(Ctrl+D to exit Python shell).</p>" 00397 "Use iguana as follows:<br> <i>> iguana yourFileName_cfg.py</i>" 00398 "<p>%2 will load a default configuration with an EmptySource.</p>" 00399 "<p><b>CMS Exception:</b></p>" 00400 "<p>%3</p>") 00401 .arg (parameterSetFilename).arg (args->argv () [0]).arg (e->what ()), QMessageBox::Ok, QMessageBox::Cancel)) 00402 { 00403 case QMessageBox::Ok: 00404 break; 00405 case QMessageBox::Cancel: 00406 std::cout << "Quit" << std::endl; 00407 00408 this->quit (); 00409 break; 00410 } 00411 }
void VisMainProgram::exceptionCallback | ( | std::exception * | e | ) |
Definition at line 275 of file VisMainProgram.cc.
References arg, IgArgsElement::argv(), hlt_scaler_cfg::critical, DBSPlugin::get(), m_mainWindow, and m_state.
Referenced by init().
00276 { 00277 IgArgsElement *args = IgArgsElement::get (m_state); 00278 00279 IgQtLock (); 00280 QApplication::restoreOverrideCursor (); 00281 00282 // Make sure the event processor is finalized. 00283 if (VisEventProcessorService *procService = VisEventProcessorService::get (m_state)) 00284 { 00285 delete procService; 00286 } 00287 00288 QMessageBox::critical (m_mainWindow, "IGUANA", QString ("<p>Standard library exception caught in %1:</p>" 00289 "<p>%2</p>").arg (args->argv () [0]).arg (e->what ())); 00290 qApp->quit (); 00291 }
void VisMainProgram::frameworkExceptionCallback | ( | lat::Error * | e | ) |
Definition at line 256 of file VisMainProgram.cc.
References arg, IgArgsElement::argv(), hlt_scaler_cfg::critical, lat::Error::explainSelf(), DBSPlugin::get(), m_mainWindow, and m_state.
Referenced by init().
00257 { 00258 IgArgsElement *args = IgArgsElement::get (m_state); 00259 00260 IgQtLock (); 00261 QApplication::restoreOverrideCursor (); 00262 00263 // Make sure the event processor is finalized. 00264 if (VisEventProcessorService *procService = VisEventProcessorService::get (m_state)) 00265 { 00266 delete procService; 00267 } 00268 00269 QMessageBox::critical (m_mainWindow, "IGUANA", QString ("<p>Exception caught in %1:</p>" 00270 "<p>%2</p>").arg (args->argv () [0]).arg (e->explainSelf ())); 00271 qApp->quit (); 00272 }
VisMainProgram::IG_DECLARE_STATE_ELEMENT | ( | VisMainProgram | ) | [private] |
Definition at line 66 of file VisMainProgram.cc.
References ASSERT, cmsExceptionCallback(), configFailureCallback(), lat::CreateCallback(), exceptionCallback(), frameworkExceptionCallback(), DBSPlugin::get(), IgEnvsElement::getEnv(), VisEventProcessorService::initEventProcessor(), LFfwvis, LOG, m_state, VisEventProcessorService::onCmsException(), VisEventProcessorService::onConfigFailure(), VisEventProcessorService::onException(), VisEventProcessorService::onFrameworkException(), VisEventProcessorService::onProcessorStarted(), VisEventProcessorService::onProcessorStopped(), VisEventProcessorService::onStartingProcessor(), VisEventProcessorService::onStatusMessage(), VisEventProcessorService::onStoppingProcessor(), VisEventProcessorService::onUnhandledException(), processorStartedCallback(), processorStoppedCallback(), VisAppearanceService::setConfiguration(), startingProcessorCallback(), statusMessageCallback(), stoppingProcessorCallback(), GsfMatrixTools::trace(), and unhandledExceptionCallback().
Referenced by VisMainProgram().
00067 { 00068 LOG (0, trace, LFfwvis, "VisMainProgram::init\n"); 00069 00070 VisAppearanceService *appearService = VisAppearanceService::get (m_state); 00071 if (! appearService) 00072 { 00073 appearService = new VisAppearanceService (m_state); 00074 ASSERT (appearService); 00075 00076 IgEnvsElement *envs = IgEnvsElement::get (m_state); 00077 std::string configString; 00078 if (envs->getEnv ("IGUANA_CONFIG", configString)) 00079 { 00080 appearService->setConfiguration (configString); 00081 } 00082 } 00083 00084 VisEventProcessorService *procService 00085 = VisEventProcessorService::get (m_state); 00086 00087 // Make sure the event processor is initialised. 00088 if (! procService) 00089 { 00090 procService = new VisEventProcessorService (m_state); 00091 00092 procService->onProcessorStarted ( 00093 lat::CreateCallback (this, 00094 &VisMainProgram::processorStartedCallback)); 00095 00096 procService->onProcessorStopped ( 00097 lat::CreateCallback (this, 00098 &VisMainProgram::processorStoppedCallback)); 00099 00100 procService->onStartingProcessor ( 00101 lat::CreateCallback (this, 00102 &VisMainProgram::startingProcessorCallback)); 00103 00104 procService->onStoppingProcessor ( 00105 lat::CreateCallback (this, 00106 &VisMainProgram::stoppingProcessorCallback)); 00107 00108 procService->onException ( 00109 lat::CreateCallback (this, 00110 &VisMainProgram::exceptionCallback)); 00111 00112 procService->onCmsException ( 00113 lat::CreateCallback (this, 00114 &VisMainProgram::cmsExceptionCallback)); 00115 00116 procService->onFrameworkException ( 00117 lat::CreateCallback (this, 00118 &VisMainProgram::frameworkExceptionCallback)); 00119 00120 procService->onUnhandledException ( 00121 lat::CreateCallback (this, 00122 &VisMainProgram::unhandledExceptionCallback)); 00123 00124 procService->onConfigFailure ( 00125 lat::CreateCallback (this, 00126 &VisMainProgram::configFailureCallback)); 00127 00128 procService->onStatusMessage ( 00129 lat::CreateCallback (this, 00130 &VisMainProgram::statusMessageCallback)); 00131 00132 procService->initEventProcessor (); 00133 } 00134 00135 // // Auto-register to execute when studio starts running. 00136 // ASSERT (IgQtAppLoopService::get (m_state)); 00137 // IgQtAppLoopService::get (m_state)->prepare 00138 // (lat::CreateCallback (this, &VisMainProgram::start)); 00139 00140 VisExceptionService *exService = VisExceptionService::get (m_state); 00141 if (! exService) 00142 { 00143 exService = new VisExceptionService (m_state); 00144 } 00145 00146 LOG (0, trace, LFfwvis, "VisMainProgram::init: Done.\n"); 00147 }
Definition at line 362 of file VisMainProgram.cc.
References DBSPlugin::get(), LFfwvis, LOG, m_state, and GsfMatrixTools::trace().
Referenced by init().
00363 { 00364 LOG (0, trace, LFfwvis, "VisMainProgram::processorStartedCallback() Processor initialized.\n"); 00365 00366 IgQtLock (); 00367 QApplication::restoreOverrideCursor (); 00368 if (IgQtAppStatusBarService *sbar = IgQtAppStatusBarService::get (m_state)) 00369 sbar->setMessage (QString ("Event Processor is initialized.")); 00370 }
Definition at line 353 of file VisMainProgram.cc.
References DBSPlugin::get(), and m_state.
Referenced by init().
00354 { 00355 IgQtLock (); 00356 QApplication::setOverrideCursor (Qt::waitCursor); 00357 if (IgQtAppStatusBarService *sbar = IgQtAppStatusBarService::get (m_state)) 00358 sbar->setMessage (QString ("Event Processor stopped...")); 00359 }
Join the main (GUI) and run() threads.
Called from the main thread.
Definition at line 216 of file VisMainProgram.cc.
References DBSPlugin::get(), LFfwvis, LOG, m_state, proc, and GsfMatrixTools::trace().
Referenced by configFailureCallback(), and start().
00217 { 00218 LOG (0, trace, LFfwvis, "VisMainProgram::quit()\n"); 00219 00220 IgQtLock (); 00221 00222 // The GUI has exited. Tell the event processor thread to exit at 00223 // the earliest opportunity. This is safe even if CARFMain has 00224 // already exited, VisQueueProcessor and VisQueue are still 00225 // around; we just schedule a callback that will never execute. 00226 // The event thread may not have started yet, or may have failed 00227 // to start completely. In that case we simply assume the worst 00228 // and never join the threads. The application will nevertheless 00229 // die when the main thread exits (FIXME: Does it? Thread safety 00230 // of state access!). 00231 if (VisQueueProcessor *proc = VisQueueProcessor::get (m_state)) 00232 { 00233 // Queue a request to abort event processing 00234 proc->scheduleAbort (); 00235 00236 // Join with the CARFMain thread. This is the only place we 00237 // do it, so this is guaranteed to succeed no matter which 00238 // order the threads quit. 00239 // m_thread->finalize (); 00240 } 00241 00242 // Make sure the event processor is finalized. 00243 if (VisEventProcessorService *procService = VisEventProcessorService::get (m_state)) 00244 { 00245 procService->scheduleAbort (); 00246 delete procService; 00247 00248 LOG (1, trace, LFfwvis, "VisMainProgram::quit() eventProcessor ()->endJob () done\n"); 00249 } 00250 00251 LOG (0, trace, LFfwvis, "VisMainProgram::quit() done\n"); 00252 qApp->quit (); 00253 }
Thread main routine for running CARFMain.
Once COBRA exits, instructs the GUI to exit too (if that hasn't happened yet).
Definition at line 179 of file VisMainProgram.cc.
References LFfwvis, LOG, and GsfMatrixTools::trace().
00180 { 00181 LOG (0, trace, LFfwvis, "VisMainProgram::run()\n"); 00182 00183 // Force Objy initialisation. This must be in the CARFMain thread 00184 // (= here, not in the main thread). 00185 // PackageInitializer::initializeALL ("BasicCompServices"); 00186 00187 // Get command line args. (FIXME: Thread safety!) 00188 00189 // Tell the GUI to exit. We do not need to synchronise here. As 00190 // of Qt 2.2.4 calling QApplication::quit() is harmless even if 00191 // done when the app has already exited. Qt processes quitting 00192 // mostly unlocked so locking does us no extra good; we do just in 00193 // case things change. The wake-up from unlock is also harmless 00194 // if the GUI has already quit. 00195 // 00196 // If the GUI is still running, this will cause it to quit at the 00197 // next opportunity. Eventually IgQtAppLoopService will invoke 00198 // our quit() method below as a post-loop action. quit() joins 00199 // with this thread as we now fall out. 00200 // 00201 // If the GUI has already quit, the main thread is most likely 00202 // already waiting in the join. It will proceed to exit once we 00203 // return here. The join is also the furthest the main thread can 00204 // get, so we know it is safe to access qApp here. 00205 // 00206 // FIXME: This should be the point where user is given the 00207 // opportunity to restart edm::EventProcessor or notify them about the 00208 // shut-down (and reason). 00209 00210 LOG (0, trace, LFfwvis, "VisMainProgram::run() done\n"); 00211 }
Start the thread that runs CARFMain.
This is invoked in the main thread just before Qt event loop starts in the studio.
Definition at line 163 of file VisMainProgram.cc.
References lat::CreateCallback(), DBSPlugin::get(), LFfwvis, LOG, m_state, quit(), and GsfMatrixTools::trace().
Referenced by VisMainProgram().
00164 { 00165 LOG (0, trace, LFfwvis, "VisMainProgram::start()\n"); 00166 00167 IgQtLock (); 00168 00169 // Auto-register a post-action to force a quit. 00170 IgQtAppLoopService::get (m_state)->post 00171 (lat::CreateCallback (this, &VisMainProgram::quit)); 00172 00173 LOG (0, trace, LFfwvis, "VisMainProgram::start() done\n"); 00174 }
Definition at line 333 of file VisMainProgram.cc.
References DBSPlugin::get(), LFfwvis, LOG, m_state, and GsfMatrixTools::trace().
Referenced by init().
00334 { 00335 LOG (0, trace, LFfwvis, "VisMainProgram::startingProcessorCallback() Starting Processor initialization...\n"); 00336 00337 IgQtLock (); 00338 QApplication::setOverrideCursor (Qt::waitCursor); 00339 if (IgQtAppStatusBarService *sbar = IgQtAppStatusBarService::get (m_state)) 00340 sbar->setMessage (QString ("Start Event Processor initialization...")); 00341 }
void VisMainProgram::statusMessageCallback | ( | const std::string & | msg | ) |
Definition at line 414 of file VisMainProgram.cc.
References DBSPlugin::get(), LFfwvis, LOG, m_state, and GsfMatrixTools::trace().
Referenced by init().
00415 { 00416 LOG (0, trace, LFfwvis, "VisMainProgram::statusMessageCallback() " << message << "\n"); 00417 00418 IgQtLock (); 00419 00420 if (IgQtAppStatusBarService *sbar = IgQtAppStatusBarService::get (m_state)) 00421 sbar->setMessage (message); 00422 }
Definition at line 344 of file VisMainProgram.cc.
References DBSPlugin::get(), and m_state.
Referenced by init().
00345 { 00346 IgQtLock (); 00347 QApplication::setOverrideCursor (Qt::waitCursor); 00348 if (IgQtAppStatusBarService *sbar = IgQtAppStatusBarService::get (m_state)) 00349 sbar->setMessage (QString ("Stopping running Event Processor...")); 00350 }
Definition at line 314 of file VisMainProgram.cc.
References arg, IgArgsElement::argv(), hlt_scaler_cfg::critical, DBSPlugin::get(), m_mainWindow, and m_state.
Referenced by init().
00315 { 00316 IgArgsElement *args = IgArgsElement::get (m_state); 00317 00318 IgQtLock (); 00319 QApplication::restoreOverrideCursor (); 00320 00321 // Make sure the event processor is finalized. 00322 if (VisEventProcessorService *procService = VisEventProcessorService::get (m_state)) 00323 { 00324 delete procService; 00325 } 00326 00327 QMessageBox::critical (m_mainWindow, "IGUANA", QString ("<p>Unknown exception caught in %1</p>") 00328 .arg (args->argv () [0])); 00329 qApp->quit (); 00330 }
QWidget* VisMainProgram::m_mainWindow [private] |
Definition at line 51 of file VisMainProgram.h.
Referenced by cmsExceptionCallback(), configFailureCallback(), exceptionCallback(), frameworkExceptionCallback(), and unhandledExceptionCallback().
IgState* VisMainProgram::m_state [private] |
Definition at line 50 of file VisMainProgram.h.
Referenced by cmsExceptionCallback(), configFailureCallback(), exceptionCallback(), frameworkExceptionCallback(), init(), processorStartedCallback(), processorStoppedCallback(), quit(), start(), startingProcessorCallback(), statusMessageCallback(), stoppingProcessorCallback(), unhandledExceptionCallback(), VisMainProgram(), and ~VisMainProgram().