Classes | Public Types | Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
lar::example::Exploder Class Reference

A buggy module. More...

Inheritance diagram for lar::example::Exploder:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Classes

struct  Config
 

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 
- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 Exploder (Parameters const &config)
 Constructor. More...
 
virtual void analyze (art::Event const &) override
 Executes the iterations. More...
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Static Private Member Functions

static unsigned int throwOutOfRange ()
 Throws a std::length_error exception. More...
 
static void throwBadAlloc ()
 Throws a std::out_of_range exception. More...
 
static void throwArtException ()
 Throws a std::out_of_range exception. More...
 

Private Attributes

bool fManageBadAlloc
 
bool fManageOutOfRange
 
bool fManageArtException
 

Additional Inherited Members

- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

A buggy module.

This module executes a number of iterations. It does something in some of those iterations, depending on the module configuration.

Configuration

Definition at line 42 of file Exploder_module.cc.

Member Typedef Documentation

Definition at line 67 of file Exploder_module.cc.

Constructor & Destructor Documentation

lar::example::Exploder::Exploder ( Parameters const &  config)

Constructor.

Definition at line 98 of file Exploder_module.cc.

100  , fManageBadAlloc(config().ManageBadAlloc())
101  , fManageOutOfRange(config().ManageOutOfRange())
102  , fManageArtException(config().ManageArtException())
103  {}
static Config * config
Definition: config.cpp:1054

Member Function Documentation

void lar::example::Exploder::analyze ( art::Event const &  )
overridevirtual

Executes the iterations.

Implements art::EDAnalyzer.

Definition at line 107 of file Exploder_module.cc.

107  {
108 
109  //
110  // std::length_error
111  //
112  if (fManageBadAlloc) {
113  try {
114  throwBadAlloc();
115  }
116  catch (std::bad_alloc const&) {}
117  }
118  else {
119  throwBadAlloc();
120  }
121 
122  //
123  // std::out_of_range
124  //
125  if (fManageOutOfRange) {
126  try {
127  throwOutOfRange();
128  }
129  catch (std::out_of_range const&) {}
130  }
131  else {
132  throwOutOfRange();
133  }
134 
135  //
136  // art::Exception
137  //
138  if (fManageArtException) {
139  try {
141  }
142  catch (art::Exception const&) {}
143  }
144  else {
146  }
147 
148 } // lar::example::Exploder::analyze()
static unsigned int throwOutOfRange()
Throws a std::length_error exception.
static void throwBadAlloc()
Throws a std::out_of_range exception.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
static void throwArtException()
Throws a std::out_of_range exception.
void lar::example::Exploder::throwArtException ( )
staticprivate

Throws a std::out_of_range exception.

Definition at line 186 of file Exploder_module.cc.

186  {
187 
189  << "I hate the world and I am vengeful.\n";
190 
191 } // lar::example::Exploder::throwArtException()
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void lar::example::Exploder::throwBadAlloc ( )
staticprivate

Throws a std::out_of_range exception.

Definition at line 171 of file Exploder_module.cc.

171  {
172 
173  using OneMebibyte = std::array<unsigned char, 1048576U>;
174 
175  std::vector<OneMebibyte> manyMebibytes;
176 
177  // this is allowed, but we don't have enough memory
178  mf::LogVerbatim("Exploder") << "Now allocating: " << manyMebibytes.max_size()
179  << " x " << sizeof(OneMebibyte) << " bytes";
180  manyMebibytes.resize(manyMebibytes.max_size());
181 
182 } // lar::example::Exploder::throwBadAlloc()
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
unsigned int lar::example::Exploder::throwOutOfRange ( )
staticprivate

Throws a std::length_error exception.

Definition at line 152 of file Exploder_module.cc.

152  {
153 
154  std::vector<int> intData(5, 0);
155 
156  int intTotal = 0;
157  for (unsigned int i = 0; i < 10; ++i) {
158  mf::LogVerbatim("Exploder") << "Starting TOOR iteration #" << i;
159 
160  // possible std::out_of_range throw
161  intTotal += intData.at(i);
162 
163  } // for
164  mf::LogVerbatim("Exploder") << "TOOR iterations completed.";
165 
166  return intTotal;
167 } // lar::example::Exploder::throwOutOfRange()
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim

Member Data Documentation

bool lar::example::Exploder::fManageArtException
private

Definition at line 80 of file Exploder_module.cc.

bool lar::example::Exploder::fManageBadAlloc
private

Definition at line 78 of file Exploder_module.cc.

bool lar::example::Exploder::fManageOutOfRange
private

Definition at line 79 of file Exploder_module.cc.


The documentation for this class was generated from the following file: