www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
OutputMapWrapper< T > Class Template Reference

In newer versions of Clang calling operator[] on a map with a component that has a default constructor is an error, thus utilizing a map directly to store a ExecFlagEnum is not possible. More...

#include <AdvancedOutputUtils.h>

Public Member Functions

 OutputMapWrapper ()
 Constructor. More...
 
T & operator[] (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, T >::iterator begin ()
 Provide iterator and find access to the underlying map data. More...
 
std::map< std::string, T >::iterator end ()
 
std::map< std::string, T >::iterator find (const std::string &name)
 
std::map< std::string, T >::const_iterator begin () const
 
std::map< std::string, T >::const_iterator end () const
 
const std::map< std::string, T >::const_iterator find (const std::string &name) const
 

Protected Attributes

std::map< std::string, T > _map
 Data storage. More...
 

Detailed Description

template<typename T>
class OutputMapWrapper< T >

In newer versions of Clang calling operator[] on a map with a component that has a default constructor is an error, thus utilizing a map directly to store a ExecFlagEnum is not possible.

This template class is a map wrapper that provides the basic map-like functionality for accessing map types with operator[] by using find internally. It also produces an error if the map key does not exists, this it provides a layer of protection not available to maps operator[] in general.

This class is used here to create two different warehouse containers below.

See also
OutputOnWarehouse OutputDataWarehouse

Definition at line 58 of file AdvancedOutputUtils.h.

Constructor & Destructor Documentation

◆ OutputMapWrapper()

template<typename T>
OutputMapWrapper< T >::OutputMapWrapper ( )
inline

Constructor.

Definition at line 64 of file AdvancedOutputUtils.h.

64 {};

Member Function Documentation

◆ begin() [1/2]

template<typename T>
std::map<std::string, T>::iterator OutputMapWrapper< T >::begin ( )
inline

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, T > _map
Data storage.

◆ begin() [2/2]

template<typename T>
std::map<std::string, T>::const_iterator OutputMapWrapper< T >::begin ( ) const
inline

Definition at line 88 of file AdvancedOutputUtils.h.

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

◆ contains()

template<typename T>
bool OutputMapWrapper< T >::contains ( const std::string &  name)
inline

A method for testing of a key exists.

Definition at line 99 of file AdvancedOutputUtils.h.

Referenced by AdvancedOutput::hasOutput(), AdvancedOutput::hasOutputHelper(), AdvancedOutput::initPostprocessorOrVectorPostprocessorLists(), and AdvancedOutput::wantOutput().

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

◆ end() [1/2]

template<typename T>
std::map<std::string, T>::iterator OutputMapWrapper< T >::end ( )
inline

Definition at line 83 of file AdvancedOutputUtils.h.

Referenced by OutputMapWrapper< ExecFlagEnum >::contains(), and AdvancedOutput::wantOutput().

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

◆ end() [2/2]

template<typename T>
std::map<std::string, T>::const_iterator OutputMapWrapper< T >::end ( ) const
inline

Definition at line 89 of file AdvancedOutputUtils.h.

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

◆ find() [1/2]

template<typename T>
std::map<std::string, T>::iterator OutputMapWrapper< T >::find ( const std::string &  name)
inline

Definition at line 84 of file AdvancedOutputUtils.h.

Referenced by OutputMapWrapper< ExecFlagEnum >::contains(), and AdvancedOutput::wantOutput().

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

◆ find() [2/2]

template<typename T>
const std::map<std::string, T>::const_iterator OutputMapWrapper< T >::find ( const std::string &  name) const
inline

Definition at line 90 of file AdvancedOutputUtils.h.

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

◆ operator[]()

template<typename T>
T& OutputMapWrapper< T >::operator[] ( const std::string &  name)
inline

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, 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:208

Member Data Documentation

◆ _map

template<typename T>
std::map<std::string, T> OutputMapWrapper< T >::_map
protected

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