www.mooseframework.org
AdvancedOutputUtils.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 // MOOSE includes
13 #include "MooseError.h"
14 #include "ExecFlagEnum.h"
15 
16 // Forward declarations
17 class InputParameters;
18 
27 struct OutputData
28 {
30  std::set<std::string> available;
31 
33  std::set<std::string> show;
34 
36  std::set<std::string> hide;
37 
39  std::set<std::string> output;
40 };
41 
56 template <typename T>
58 {
59 public:
64 
68  T & operator[](const std::string & name)
69  {
70  // Locate the map entry, error if it is not found
71  typename std::map<std::string, T>::iterator iter = _map.find(name);
72  if (iter == _map.end())
73  mooseError("Unknown map key ", name);
74  return iter->second;
75  }
76 
78 
81  typename std::map<std::string, T>::iterator begin() { return _map.begin(); }
82  typename std::map<std::string, T>::iterator end() { return _map.end(); }
83  typename std::map<std::string, T>::iterator find(const std::string & name)
84  {
85  return _map.find(name);
86  }
87  typename std::map<std::string, T>::const_iterator begin() const { return _map.begin(); }
88  typename std::map<std::string, T>::const_iterator end() const { return _map.end(); }
89  const typename std::map<std::string, T>::const_iterator find(const std::string & name) const
90  {
91  return _map.find(name);
92  }
94 
98  bool contains(const std::string & name) { return find(name) != end(); }
99 
100 protected:
102  typename std::map<std::string, T> _map;
103 };
104 
124 class OutputOnWarehouse : public OutputMapWrapper<ExecFlagEnum>
125 {
126 public:
132  OutputOnWarehouse(const ExecFlagEnum & execute_on, const InputParameters & parameters);
133 };
134 
143 class OutputDataWarehouse : public OutputMapWrapper<OutputData>
144 {
145 public:
150 
157  bool hasShowList() { return _has_show_list; }
158 
165  void setHasShowList(bool value) { _has_show_list = value; }
166 
167 private:
168  // True when the input file contains a show/hide list
170 };
171 
std::set< std::string > output
A list of the outputs to write.
std::map< std::string, T >::const_iterator begin() const
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:24
std::map< std::string, T > _map
Data storage.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
A helper warehouse for storing OutputData objects for the various output types.
std::map< std::string, T >::const_iterator end() const
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...
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.
bool contains(const std::string &name)
A method for testing of a key exists.
OutputOnWarehouse(const ExecFlagEnum &execute_on, const InputParameters &parameters)
Constructor.
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...
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.
const std::map< std::string, T >::const_iterator find(const std::string &name) const
std::set< std::string > show
User-supplied list of outputs to display.
OutputDataWarehouse()
Populate the OutputData structures for all output types that are &#39;variable&#39; based.
OutputMapWrapper()
Constructor.
std::map< std::string, T >::iterator find(const std::string &name)
void setHasShowList(bool value)
Set the show list bool.