www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
OutputOnWarehouse Class Reference

A helper warehouse class for storing the "execute_on" settings for the various output types. More...

#include <AdvancedOutputUtils.h>

Inheritance diagram for OutputOnWarehouse:
[legend]

Public Member Functions

 OutputOnWarehouse (const ExecFlagEnum &execute_on, const InputParameters &parameters)
 Constructor. More...
 
ExecFlagEnumoperator[] (const std::string &name)
 A map accessor that errors if the key is not found. More...
 
bool contains (const std::string &name)
 A method for testing of a key exists. More...
 
std::map< std::string, ExecFlagEnum >::iterator begin ()
 Provide iterator and find access to the underlying map data. More...
 
std::map< std::string, ExecFlagEnum >::const_iterator begin () const
 
std::map< std::string, ExecFlagEnum >::iterator end ()
 
std::map< std::string, ExecFlagEnum >::const_iterator end () const
 
std::map< std::string, ExecFlagEnum >::iterator find (const std::string &name)
 
const std::map< std::string, ExecFlagEnum >::const_iterator find (const std::string &name) const
 

Protected Attributes

std::map< std::string, ExecFlagEnum_map
 Data storage. More...
 

Detailed Description

A helper warehouse class for storing the "execute_on" settings for the various output types.

In order to allow for new output types to be defined and to minimize the number of member variables the "execute_on" parameter for each of the output types (e.g., execute_postprocessors_on) are stored in a map.

This allows for iterative access to these parameters, which makes creating generic code (e.g., AdvancedOutput::shouldOutput) possible. However, ExecFlagEnum has a private constructor, so calling operator[] on the map is a compile time error.

To get around this and to provide a more robust storage structure, one that will error if the wrong output name is given, this warehouse was created. For the purposes of the AdvancedOutput object this warehouse functions exactly like a std::map, but provides an operator[] that works with ExecFlagEnum and errors if called on an invalid key.

See also
OutputMapWrapper OutputDataWarehouse

Definition at line 125 of file AdvancedOutputUtils.h.

Constructor & Destructor Documentation

◆ OutputOnWarehouse()

OutputOnWarehouse::OutputOnWarehouse ( const ExecFlagEnum execute_on,
const InputParameters parameters 
)

Constructor.

Parameters
execute_onThe general "execute_on" settings for the object.
parametersThe parameters object holding data for the class to use.

Definition at line 16 of file AdvancedOutputUtils.C.

19 {
20  // Initialize each of the 'execute_on' settings for the various types of outputs
21  if (parameters.have_parameter<ExecFlagEnum>("execute_nodal_on"))
22  _map.insert(std::make_pair("nodal", execute_on));
23 
24  if (parameters.have_parameter<ExecFlagEnum>("execute_elemental_on"))
25  _map.insert(std::make_pair("elemental", execute_on));
26 
27  if (parameters.have_parameter<ExecFlagEnum>("execute_scalars_on"))
28  _map.insert(std::make_pair("scalars", execute_on));
29 
30  if (parameters.have_parameter<ExecFlagEnum>("execute_postprocessors_on"))
31  _map.insert(std::make_pair("postprocessors", execute_on));
32 
33  if (parameters.have_parameter<ExecFlagEnum>("execute_vector_postprocessors_on"))
34  _map.insert(std::make_pair("vector_postprocessors", execute_on));
35 
36  if (parameters.have_parameter<ExecFlagEnum>("execute_input_on"))
37  _map.insert(std::make_pair("input", MooseUtils::getDefaultExecFlagEnum()));
38 
39  if (parameters.have_parameter<ExecFlagEnum>("execute_system_information_on"))
40  {
42  flags = EXEC_INITIAL;
43  _map.insert(std::make_pair("system_information", flags));
44  }
45 }
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:25
std::map< std::string, ExecFlagEnum > _map
Data storage.
ExecFlagEnum getDefaultExecFlagEnum()
Return the default ExecFlagEnum for MOOSE.
Definition: MooseUtils.C:724
const ExecFlagType EXEC_INITIAL

Member Function Documentation

◆ begin() [1/2]

std::map<std::string, ExecFlagEnum >::iterator OutputMapWrapper< ExecFlagEnum >::begin ( )
inlineinherited

Provide iterator and find access to the underlying map data.

Definition at line 82 of file AdvancedOutputUtils.h.

82 { return _map.begin(); }
std::map< std::string, ExecFlagEnum > _map
Data storage.

◆ begin() [2/2]

std::map<std::string, ExecFlagEnum >::const_iterator OutputMapWrapper< ExecFlagEnum >::begin ( ) const
inlineinherited

Definition at line 88 of file AdvancedOutputUtils.h.

88 { return _map.begin(); }
std::map< std::string, ExecFlagEnum > _map
Data storage.

◆ contains()

bool OutputMapWrapper< ExecFlagEnum >::contains ( const std::string &  name)
inlineinherited

A method for testing of a key exists.

Definition at line 99 of file AdvancedOutputUtils.h.

99 { return find(name) != end(); }
std::map< std::string, ExecFlagEnum >::iterator end()
std::map< std::string, ExecFlagEnum >::iterator find(const std::string &name)

◆ end() [1/2]

std::map<std::string, ExecFlagEnum >::iterator OutputMapWrapper< ExecFlagEnum >::end ( )
inlineinherited

Definition at line 83 of file AdvancedOutputUtils.h.

83 { return _map.end(); }
std::map< std::string, ExecFlagEnum > _map
Data storage.

◆ end() [2/2]

std::map<std::string, ExecFlagEnum >::const_iterator OutputMapWrapper< ExecFlagEnum >::end ( ) const
inlineinherited

Definition at line 89 of file AdvancedOutputUtils.h.

89 { return _map.end(); }
std::map< std::string, ExecFlagEnum > _map
Data storage.

◆ find() [1/2]

std::map<std::string, ExecFlagEnum >::iterator OutputMapWrapper< ExecFlagEnum >::find ( const std::string &  name)
inlineinherited

Definition at line 84 of file AdvancedOutputUtils.h.

85  {
86  return _map.find(name);
87  }
std::map< std::string, ExecFlagEnum > _map
Data storage.

◆ find() [2/2]

const std::map<std::string, ExecFlagEnum >::const_iterator OutputMapWrapper< ExecFlagEnum >::find ( const std::string &  name) const
inlineinherited

Definition at line 90 of file AdvancedOutputUtils.h.

91  {
92  return _map.find(name);
93  }
std::map< std::string, ExecFlagEnum > _map
Data storage.

◆ operator[]()

ExecFlagEnum & OutputMapWrapper< ExecFlagEnum >::operator[] ( const std::string &  name)
inlineinherited

A map accessor that errors if the key is not found.

Definition at line 69 of file AdvancedOutputUtils.h.

70  {
71  // Locate the map entry, error if it is not found
72  typename std::map<std::string, T>::iterator iter = _map.find(name);
73  if (iter == _map.end())
74  mooseError("Unknown map key ", name);
75  return iter->second;
76  }
std::map< std::string, ExecFlagEnum > _map
Data storage.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208

Member Data Documentation

◆ _map

std::map<std::string, ExecFlagEnum > OutputMapWrapper< ExecFlagEnum >::_map
protectedinherited

Data storage.

Definition at line 103 of file AdvancedOutputUtils.h.

Referenced by OutputOnWarehouse().


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