Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
larcore
larcore
CoreUtils
EnsureOnlyOneSchedule.h
Go to the documentation of this file.
1
#ifndef larcore_CoreUtils_EnsureOnlyOneSchedule_h
2
#define larcore_CoreUtils_EnsureOnlyOneSchedule_h
3
4
#include "
art/Utilities/Globals.h
"
5
#include "
canvas/Utilities/Exception.h
"
6
#include "cetlib_except/demangle.h"
7
8
/**
9
* @file EnsureOnlyOneSchedule.h
10
* @brief Type whose constructor throws if more than one art schedule is configured
11
*
12
* This class is intended to be used in the context of an art job. It
13
* is helpful for services that have the notion of a "current event,"
14
* but are thread-safe within that event. The constructor of this
15
* class will throw an exception if more than one art schedule is
16
* configured. It should be used via private inheritance:
17
*
18
* class MyService : lar::EnsureOnlyOneSchedule<MyService> {
19
* ..
20
* };
21
*
22
*/
23
24
namespace
lar
{
25
template
<
typename
T>
26
class
EnsureOnlyOneSchedule
{
27
public
:
28
EnsureOnlyOneSchedule
()
29
{
30
if
(
auto
const
nschedules =
art::Globals::instance
()->nschedules(); nschedules > 1) {
31
throw
art::Exception
{
art::errors::Configuration
}
32
<<
"This job uses "
<< nschedules <<
" schedules, but the type '"
<< cet::demangle_symbol(
typeid
(
T
).
name
()) <<
" supports\n"
33
<<
"processing only one event at a time. Please reconfigure your job to use only one schedule.\n"
;
34
}
35
}
36
};
37
}
38
39
#endif
/* larcore_CoreUtils_EnsureOnlyOneSchedule_h */
40
41
// Local Variables:
42
// mode: c++
43
// End:
name
static QCString name
Definition:
declinfo.cpp:673
lar::EnsureOnlyOneSchedule::EnsureOnlyOneSchedule
EnsureOnlyOneSchedule()
Definition:
EnsureOnlyOneSchedule.h:28
ValidateOpDetSimulation.T
T
Definition:
ValidateOpDetSimulation.py:52
Exception.h
art::errors::Configuration
Definition:
Exception.h:32
Globals.h
art::Exception
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition:
Exception.h:66
lar
LArSoft-specific namespace.
Definition:
EnsureOnlyOneSchedule.h:24
art::Globals::instance
static Globals * instance()
Definition:
Globals.cc:17
lar::EnsureOnlyOneSchedule
Definition:
EnsureOnlyOneSchedule.h:26
Generated by
1.8.11