13 #include "libmesh/simple_range.h" 30 const std::string & moose_object_type,
31 bool should_auto_build)
34 for (
auto it = range.first; it != range.second; ++it)
35 if (it->second == task)
39 mooseError(
"A ", task,
" is already registered. Do you need to use appendTaskName instead?");
47 const std::string & moose_object_type,
51 mooseError(
"A ", task,
" is not a registered task name.");
63 mooseError(
"A ", task,
" is not a registered task name.");
71 std::vector<std::string> sets, prev_names, tasks;
74 for (
unsigned int i = 0; i < sets.size(); ++i)
78 for (
unsigned int j = 0; j < tasks.size(); ++j)
81 for (
unsigned int k = 0; k < prev_names.size(); ++k)
93 mooseError(
"A ", task,
" is not a registered task name.");
104 const std::vector<std::string> &
118 const std::vector<std::vector<std::string>> &
133 mooseDeprecated(
"Syntax::isActionRequired is deprecated, use shouldAutoBuild() instead");
141 mooseAssert(map_pair !=
_registered_tasks.end(), std::string(
"Unregistered task: ") + task);
143 return map_pair->second;
148 const std::string & syntax,
149 const std::string & task,
150 const std::string & file,
154 for (
auto it = range.first; it != range.second; ++it)
155 if (it->second._action == action && it->second._task == task)
165 const std::string & syntax,
166 const std::string & task,
167 const std::string & file,
177 const std::string message =
"\"[" + syntax +
"]\" is deprecated.";
195 mooseError(
"The action syntax ", syntax,
" is not deprecated");
204 std::vector<std::string>
213 [](
const std::pair<std::string, ActionInfo> pair) {
214 return std::make_pair(pair.second._action,
215 std::make_pair(pair.first, pair.second._task));
220 std::vector<std::string> syntax;
222 for (
const auto & syntax_pair :
as_range(it_pair))
224 if (task ==
"" || syntax_pair.second.second == task)
225 syntax.emplace_back(syntax_pair.second.first);
230 std::vector<std::string>
234 for (
auto syntax_it = begin(syntaxes); syntax_it != end(syntaxes);)
237 syntax_it = syntaxes.erase(syntax_it);
247 const std::map<std::string, std::set<std::string>> & alt_map)
const 250 std::set<std::string> syntax_to_traverse;
251 if (!alt_map.empty())
252 std::transform(alt_map.begin(),
254 std::inserter(syntax_to_traverse, syntax_to_traverse.end()),
255 [](
auto pair) {
return pair.first; });
259 std::inserter(syntax_to_traverse, syntax_to_traverse.end()),
260 [](
auto pair) {
return pair.first; });
268 bool local_is_parent;
269 if (is_parent ==
nullptr)
270 is_parent = &local_is_parent;
272 std::vector<std::string> real_elements, reg_elements;
273 std::string return_value;
278 for (
auto it = syntax_to_traverse.rbegin(); it != syntax_to_traverse.rend(); ++it)
280 std::string reg_id = *it;
281 if (reg_id == real_id)
286 reg_elements.clear();
288 if (real_elements.size() <= reg_elements.size())
290 bool keep_going =
true;
291 for (
unsigned int j = 0; keep_going && j < real_elements.size(); ++j)
293 if (real_elements[j] != reg_elements[j] && reg_elements[j] != std::string(
"*"))
298 if (real_elements.size() < reg_elements.size() && !*is_parent)
303 return_value = reg_id;
305 else if (real_elements.size() == reg_elements.size())
320 std::pair<std::multimap<std::string, Syntax::ActionInfo>::const_iterator,
321 std::multimap<std::string, Syntax::ActionInfo>::const_iterator>
332 for (
const auto & task_it :
as_range(iters))
333 if (task == task_it.second)
337 for (
const auto & task_it :
as_range(iters))
338 if (task == task_it.second)
340 std::string object_tasks =
"";
342 object_tasks += (object_tasks ==
"" ?
"" :
" ") + other_task.second;
345 "Adding objects from system '" + base +
"' through task '" + task +
346 "' is deprecated. This object should only be added from task(s): " + object_tasks +
347 ". This is likely caused by adding objects in a block they no longer belong to. For " 348 "example, FunctorMaterials should no longer be added in the [Materials] block.");
361 const std::multimap<std::string, std::string> &
367 const std::multimap<std::string, Syntax::ActionInfo> &
375 const std::string & action,
376 const std::string & task)
const bool hasTask(const std::string &task) const
Returns a Boolean indicating whether or not a task is registered with the syntax object.
void appendTaskName(const std::string &task, const std::string &moose_object_type, bool deprecated)
Method to associate another "allowed" pluggable MOOSE system to an existing registered task...
void clear()
Clear Items from the resolver.
const std::multimap< std::string, std::string > & getAssociatedTypes() const
Get a multimap of registered associations of syntax with type.
std::pair< std::multimap< std::string, ActionInfo >::const_iterator, std::multimap< std::string, ActionInfo >::const_iterator > getActions(const std::string &syntax) const
Returns a pair of multimap iterators to all the ActionInfo objects associated with a given piece of s...
void tokenize(const std::string &str, std::vector< T > &elements, unsigned int min_len=1, const std::string &delims="/")
This function will split the passed in string on a set of delimiters appending the substrings to the ...
const std::multimap< std::string, ActionInfo > & getAssociatedActions() const
Return all Syntax to Action associations.
bool _actions_to_syntax_valid
Boolean indicating whether the _actions_to_syntax map is built and valid and synced.
void deleteTaskDependencies(const std::string &task)
Deletes or removes the dependencies that this task depends on.
void addDependency(const std::string &task, const std::string &pre_req)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
FileLineInfoMap _syntax_to_line
DependencyResolver< std::string > _tasks
The dependency resolver.
void swap(std::vector< T > &data, const std::size_t idx0, const std::size_t idx1, const libMesh::Parallel::Communicator &comm)
Swap function for serial or distributed vector of data.
void registerTaskName(const std::string &task, bool should_auto_build=false)
Method to register a new task.
const std::vector< T > & getSortedValues()
This function also returns dependency resolved values but with a simpler single vector interface...
std::multimap< std::string, std::pair< std::string, std::string > > _actions_to_syntax
The ActionInfo (Action+task) to syntax associations (built only when needed) Action -> (Syntax...
FileLineInfo getLineInfo(const std::string &syntax, const std::string &action, const std::string &task) const
Gets the file and line where the syntax/action/task combo was registered.
void registerActionSyntax(const std::string &action, const std::string &syntax, const std::string &task="", const std::string &file="", int line=-1)
Registration function for associating Moose Actions with syntax.
const std::vector< std::string > & getSortedTask()
Get a list of serialized tasks in a correct dependency order.
const std::vector< std::vector< T > > & getSortedValuesSets()
Returns a vector of sets that represent dependency resolved values.
bool isActionRequired(const std::string &task) const
Returns a Boolean indicating whether the specified task is required.
std::multimap< std::string, std::string > _deprecated_list_moose_systems_to_tasks
A list of Moose system objects to tasks that are deprecated for these systems.
FileLineInfo getInfo(const std::string &key0) const
Get file/line info for a key.
void addInfo(const std::string &key0, const std::string &file, int line)
Associate a key with file/line info.
std::vector< std::string > getSyntaxByAction(const std::string &action, const std::string &task="")
Retrieve the syntax associated with the passed in action type string.
bool shouldAutoBuild(const std::string &task) const
Returns a Boolean indicating whether MOOSE should attempt to automatically create an Action to satisf...
void addItem(const T &value)
Add an independent item to the set.
std::vector< std::string > getNonDeprecatedSyntaxByAction(const std::string &action, const std::string &task="")
Retrieve the non-deprecated syntax associated with the passed in action type string.
bool isDeprecatedSyntax(const std::string &syntax) const
Returns a Boolean indicating whether the syntax has been deprecated through a call to deprecateAction...
std::map< std::string, bool > _registered_tasks
The list of registered tasks and a flag indicating whether or not they should be auto-built.
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
const std::vector< std::vector< std::string > > & getSortedTaskSet()
Get a list of serialized tasks in a correct dependency order.
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
void replaceActionSyntax(const std::string &action, const std::string &syntax, const std::string &task, const std::string &file="", int line=-1)
Registration function that replaces existing Moose Actions with a completely new action Note: This fu...
void clearTaskDependencies()
Clears all tasks from the system object.
void deleteDependenciesOfKey(const T &key)
Removes dependencies of the given key.
Holds file and line information.
void addDependencySets(const std::string &action_sets)
Adds all dependencies in a single call.
std::string isAssociated(const std::string &real_id, bool *is_parent, const std::map< std::string, std::set< std::string >> &alt_map={}) const
Method for determining whether a piece of syntax is associated with an Action an optional syntax map ...
std::multimap< std::string, std::string > _moose_systems_to_tasks
The list of Moose system objects to tasks. This map indicates which tasks are allowed to build certai...
const std::vector< T > & getCyclicDependencies() const
void registerSyntaxType(const std::string &syntax, const std::string &type)
Register a type with a block.
std::map< std::string, std::string > _deprecated_syntax
The list of deprecated syntax items and the associated deprecated message.
bool verifyMooseObjectTask(const std::string &base, const std::string &task) const
Returns a Boolean indicating whether a task is associated with on of the MOOSE pluggable systems (BAS...
std::multimap< std::string, ActionInfo > _syntax_to_actions
The syntax object to ActionInfo (Action+task) associations.
std::string deprecatedActionSyntaxMessage(const std::string syntax)
Returns the deprecation message for a given syntax that has been deprecated by deprecateActionSyntax...
void deprecateActionSyntax(const std::string &syntax)
This method deprecates previously registered syntax.
void insertDependency(const T &key, const T &value)
Insert a dependency pair - the first value or the "key" depends on the second value or the "value"...
std::multimap< std::string, std::string > _associated_types
Syntax/Type association.
std::string join(const T &strings, const std::string &delimiter)
Python like join function for strings.