www.mooseframework.org
ControllableParameter.C
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 #include "ControllableParameter.h"
11 #include "MooseUtils.h"
12 
13 void
15 {
16  _items.push_back(item);
17 }
18 
19 std::string
21 {
22  std::ostringstream oss;
23  for (auto item_ptr : _items)
24  oss << item_ptr->dump();
25  return oss.str();
26 }
27 
28 void
30 {
31  for (const ControllableItem * const item : _items)
32  {
33  const std::set<ExecFlagType> & flags = item->getExecuteOnFlags();
34  if (!flags.empty() && flags.find(current) == flags.end())
35  mooseError("The controllable parameter (",
36  item->name(),
37  ") is not allowed to execute on '",
38  current,
39  "', it is only allowed to execute on '",
40  MooseUtils::join(flags, " "),
41  "'.");
42  }
43 }
44 
45 std::ostream &
46 operator<<(std::ostream & stream, const ControllableParameter & obj)
47 {
48  return stream << obj.dump();
49 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284
The ControllableParameter class is simply a set of ControllableItem objects.
void checkExecuteOnType(const ExecFlagType &current) const
Check the execute flags.
void add(ControllableItem *item)
Adds the supplied item with the other items within this object.
std::vector< ControllableItem * > _items
Storage for the ControllableItems, these are stored as pointers to avoid copies.
std::ostream & operator<<(std::ostream &stream, const ControllableParameter &obj)
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:18
An intermediate object for building a "controllable item", where an "item" can refer to multiple inpu...
std::string dump() const
Return a string that lists the parameters stored by this object.
std::string join(const T &strings, const std::string &delimiter)
Python like join function for strings.
Definition: MooseUtils.h:130