www.mooseframework.org
AdvancedOutputUtils.h
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #ifndef ADVANCEDOUTPUTUTILS_H
16 #define ADVANCEDOUTPUTUTILS_H
17 
18 // MOOSE includes
19 #include "MooseError.h"
20 #include "MultiMooseEnum.h"
21 
22 // Forward declarations
23 class InputParameters;
24 
33 struct OutputData
34 {
36  std::set<std::string> available;
37 
39  std::set<std::string> show;
40 
42  std::set<std::string> hide;
43 
45  std::set<std::string> output;
46 };
47 
62 template <typename T>
64 {
65 public:
70 
74  T & operator[](const std::string & name)
75  {
76  // Locate the map entry, error if it is not found
77  typename std::map<std::string, T>::iterator iter = _map.find(name);
78  if (iter == _map.end())
79  mooseError("Unknown map key ", name);
80  return iter->second;
81  }
82 
84 
87  typename std::map<std::string, T>::iterator begin() { return _map.begin(); }
88  typename std::map<std::string, T>::iterator end() { return _map.end(); }
89  typename std::map<std::string, T>::iterator find(const std::string & name)
90  {
91  return _map.find(name);
92  }
93  typename std::map<std::string, T>::const_iterator begin() const { return _map.begin(); }
94  typename std::map<std::string, T>::const_iterator end() const { return _map.end(); }
95  const typename std::map<std::string, T>::const_iterator find(const std::string & name) const
96  {
97  return _map.find(name);
98  }
100 
104  bool contains(const std::string & name) { return find(name) != end(); }
105 
106 protected:
108  typename std::map<std::string, T> _map;
109 };
110 
130 class OutputOnWarehouse : public OutputMapWrapper<MultiMooseEnum>
131 {
132 public:
138  OutputOnWarehouse(const MultiMooseEnum & execute_on, const InputParameters & parameters);
139 };
140 
149 class OutputDataWarehouse : public OutputMapWrapper<OutputData>
150 {
151 public:
156 
163  bool hasShowList() { return _has_show_list; }
164 
171  void setHasShowList(bool value) { _has_show_list = value; }
172 
173 private:
174  // True when the input file contains a show/hide list
176 };
177 
178 #endif // ADVANCEDOUTPUTUTILS_H
std::set< std::string > output
A list of the outputs to write.
std::map< std::string, T > _map
Data storage.
A helper warehouse for storing OutputData objects for the various output types.
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
A structure for storing the various lists that contain the names of the items to be exported...
std::map< std::string, T >::const_iterator end() const
T & operator[](const std::string &name)
A map accessor that errors if the key is not found.
In newer versions of Clang calling operator[] on a map with a component that has a default constructo...
bool hasShowList()
False when the show lists for all variables is empty.
std::map< std::string, T >::const_iterator begin() const
bool contains(const std::string &name)
A method for testing of a key exists.
std::set< std::string > available
A list of all possible outputs.
A helper warehouse class for storing the "execute_on" settings for the various output types...
const std::map< std::string, T >::const_iterator find(const std::string &name) const
std::set< std::string > hide
User-supplied list of outputs to hide.
std::map< std::string, T >::iterator end()
std::map< std::string, T >::iterator begin()
Provide iterator and find access to the underlying map data.
std::set< std::string > show
User-supplied list of outputs to display.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
OutputMapWrapper()
Constructor.
std::map< std::string, T >::iterator find(const std::string &name)
void setHasShowList(bool value)
Set the show list bool.