All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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:

Classes

struct  Config
 

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 

Public Member Functions

 Exploder (Parameters const &config)
 Constructor. More...
 
virtual void analyze (art::Event const &) override
 Executes the iterations. More...
 

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
 

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

using lar::example::Exploder::Parameters = art::EDAnalyzer::Table<Config>

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.

99  : art::EDAnalyzer(config)
100  , fManageBadAlloc(config().ManageBadAlloc())
101  , fManageOutOfRange(config().ManageOutOfRange())
102  , fManageArtException(config().ManageArtException())
103  {}

Member Function Documentation

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

Executes the iterations.

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.
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 
188  throw art::Exception(art::errors::LogicError)
189  << "I hate the world and I am vengeful.\n";
190 
191 } // lar::example::Exploder::throwArtException()
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()
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()

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: