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

A class for accessing controllable InputParameters. More...

#include <ControllableParameter.h>

Public Member Functions

 ControllableParameter ()
 Constructor. More...
 
std::size_t size () const
 The number of parameters contained in the class. More...
 
void set (const T &value)
 Set the value(s) of the controlled parameters stored in this class. More...
 
const std::vector< T * > & get () const
 Retrieve a copy of the parameter values controlled by this class. More...
 
std::string dump ()
 Return a string that lists the parameters stored by this object. More...
 
void insert (const MooseObjectParameterName &name, std::shared_ptr< InputParameters > param_object)
 Adds a parameter to the container. More...
 

Private Attributes

std::vector< T * > _parameter_values
 Vector of pointers to the parameters stored in this object for control. More...
 
std::multimap< T *, MooseObjectParameterName_parameter_names
 Map of the possible names associated with the parameters stored for control. More...
 

Detailed Description

template<typename T>
class ControllableParameter< T >

A class for accessing controllable InputParameters.

This class is used within Control objects for returning sets of InputParaemeters.

Definition at line 30 of file ControllableParameter.h.

Constructor & Destructor Documentation

template<typename T >
ControllableParameter< T >::ControllableParameter ( )

Constructor.

The construct does nothing, items must be added via the insert method.

See also
ControlInterface

Definition at line 83 of file ControllableParameter.h.

84 {
85 }

Member Function Documentation

template<typename T >
std::string ControllableParameter< T >::dump ( )

Return a string that lists the parameters stored by this object.

This is used by ControlInterface::getControlParamByName for error reporting.

Definition at line 125 of file ControllableParameter.h.

Referenced by Control::getControllableParameterHelper(), and ControllableParameter< Real >::size().

126 {
127  // Count of objects, for printing a number with the parameter
128  unsigned int index = 0;
129 
130  // The output stream
131  std::ostringstream oss;
132 
133  // Loop through each pointer
134  typename std::vector<T *>::iterator iter;
135  for (iter = _parameter_values.begin(); iter != _parameter_values.end(); iter++)
136  {
137  // Get the list of names associated with the parameter
138  std::pair<typename std::multimap<T *, MooseObjectParameterName>::const_iterator,
139  typename std::multimap<T *, MooseObjectParameterName>::const_iterator>
140  range = _parameter_names.equal_range(*iter);
141  typename std::multimap<T *, MooseObjectParameterName>::const_iterator jt;
142 
143  // Print each parameter as a list of possible names
144  oss << "(" << index << ") ";
145  for (jt = range.first; jt != range.second; ++jt)
146  oss << jt->second << " ";
147  oss << "\n";
148  index++;
149  }
150 
151  return oss.str();
152 }
std::multimap< T *, MooseObjectParameterName > _parameter_names
Map of the possible names associated with the parameters stored for control.
std::vector< T * > _parameter_values
Vector of pointers to the parameters stored in this object for control.
template<typename T >
const std::vector< T * > & ControllableParameter< T >::get ( ) const

Retrieve a copy of the parameter values controlled by this class.

Definition at line 118 of file ControllableParameter.h.

Referenced by Control::getControllableParameterHelper(), and Control::getControllableValueByName().

119 {
120  return _parameter_values;
121 }
std::vector< T * > _parameter_values
Vector of pointers to the parameters stored in this object for control.
template<typename T >
void ControllableParameter< T >::insert ( const MooseObjectParameterName name,
std::shared_ptr< InputParameters param_object 
)

Adds a parameter to the container.

See also
ControlInterface

Definition at line 89 of file ControllableParameter.h.

Referenced by InputParameterWarehouse::getControllableParameter(), and ControllableParameter< Real >::size().

91 {
92  // Get a pointer to the Parameter
93  T * param_ptr = &param_object->template set<T>(name.parameter());
94 
95  // Search for the pointer in the existing multimap
96  typename std::multimap<T *, MooseObjectParameterName>::iterator iter =
97  _parameter_names.find(param_ptr);
98 
99  // If the pointer does not exist, add it
100  if (iter == _parameter_names.end())
101  _parameter_values.push_back(param_ptr);
102 
103  // Update the object names
104  _parameter_names.insert(std::pair<T *, MooseObjectParameterName>(param_ptr, name));
105 }
const std::string & parameter() const
Return the parameter name.
std::multimap< T *, MooseObjectParameterName > _parameter_names
Map of the possible names associated with the parameters stored for control.
std::vector< T * > _parameter_values
Vector of pointers to the parameters stored in this object for control.
template<typename T>
void ControllableParameter< T >::set ( const T &  value)

Set the value(s) of the controlled parameters stored in this class.

Parameters
valueThe value to change the parameters to.

Definition at line 109 of file ControllableParameter.h.

Referenced by Control::setControllableValueByName().

110 {
111  typename std::vector<T *>::iterator iter;
112  for (unsigned int i = 0; i < _parameter_values.size(); i++)
113  *_parameter_values[i] = value;
114 }
std::vector< T * > _parameter_values
Vector of pointers to the parameters stored in this object for control.
template<typename T>
std::size_t ControllableParameter< T >::size ( ) const
inline

The number of parameters contained in the class.

Definition at line 46 of file ControllableParameter.h.

Referenced by InputParameterWarehouse::getControllableParameter().

46 { return _parameter_values.size(); }
std::vector< T * > _parameter_values
Vector of pointers to the parameters stored in this object for control.

Member Data Documentation

template<typename T>
std::multimap<T *, MooseObjectParameterName> ControllableParameter< T >::_parameter_names
private

Map of the possible names associated with the parameters stored for control.

Definition at line 79 of file ControllableParameter.h.

Referenced by ControllableParameter< T >::dump(), and ControllableParameter< T >::insert().

template<typename T>
std::vector<T *> ControllableParameter< T >::_parameter_values
private

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