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)
85 std::swap(tasks, prev_names);
93 mooseError(
"A ", task,
" is not a registered task name.");
104const std::vector<std::string> &
114 mooseError(
"Cyclic dependencies detected: ", MooseUtils::join(cycle,
" <- "));
118const 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,
183 const std::string message =
"\"[" + syntax +
"]\" is deprecated.";
201 mooseError(
"The action syntax ", syntax,
" is not deprecated");
210std::vector<std::string>
219 [](
const std::pair<std::string, ActionInfo> pair)
221 return std::make_pair(pair.second._action,
222 std::make_pair(pair.first, pair.second._task));
227 std::vector<std::string> syntax;
229 for (
const auto & syntax_pair : as_range(it_pair))
231 if (task ==
"" || syntax_pair.second.second == task)
232 syntax.emplace_back(syntax_pair.second.first);
237std::vector<std::string>
241 for (
auto syntax_it = begin(syntaxes); syntax_it != end(syntaxes);)
244 syntax_it = syntaxes.erase(syntax_it);
254 const std::map<std::string, std::set<std::string>> & alt_map)
const
257 std::set<std::string> syntax_to_traverse;
258 if (!alt_map.empty())
259 std::transform(alt_map.begin(),
261 std::inserter(syntax_to_traverse, syntax_to_traverse.end()),
262 [](
auto pair) { return pair.first; });
266 std::inserter(syntax_to_traverse, syntax_to_traverse.end()),
267 [](
auto pair) { return pair.first; });
275 bool local_is_parent;
276 if (is_parent ==
nullptr)
277 is_parent = &local_is_parent;
279 std::vector<std::string> real_elements, reg_elements;
280 std::string return_value;
285 for (
auto it = syntax_to_traverse.rbegin(); it != syntax_to_traverse.rend(); ++it)
287 std::string reg_id = *it;
288 if (reg_id == real_id)
293 reg_elements.clear();
295 if (real_elements.size() <= reg_elements.size())
297 bool keep_going =
true;
298 for (
unsigned int j = 0; keep_going && j < real_elements.size(); ++j)
300 if (real_elements[j] != reg_elements[j] && reg_elements[j] != std::string(
"*"))
305 if (real_elements.size() < reg_elements.size() && !*is_parent)
310 return_value = reg_id;
312 else if (real_elements.size() == reg_elements.size())
327std::pair<std::multimap<std::string, Syntax::ActionInfo>::const_iterator,
328 std::multimap<std::string, Syntax::ActionInfo>::const_iterator>
339 for (
const auto & task_it : as_range(iters))
340 if (task == task_it.second)
344 for (
const auto & task_it : as_range(iters))
345 if (task == task_it.second)
347 std::string object_tasks =
"";
349 object_tasks += (object_tasks ==
"" ?
"" :
" ") + other_task.second;
352 "Adding objects from system '" + base +
"' through task '" + task +
353 "' is deprecated. This object should only be added from task(s): " + object_tasks +
354 ". This is likely caused by adding objects in a block they no longer belong to. For "
355 "example, FunctorMaterials should no longer be added in the [Materials] block.");
368const std::multimap<std::string, std::string> &
374const std::multimap<std::string, Syntax::ActionInfo> &
382 const std::string & action,
383 const std::string & task)
const
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
const std::vector< T > & getCyclicDependencies() const
void addItem(const T &value)
Add an independent item to the set.
void clear()
Clear Items from the resolver.
const std::vector< T > & getSortedValues()
This function also returns dependency resolved values but with a simpler single vector interface.
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".
void deleteDependenciesOfKey(const T &key)
Removes dependencies of the given key.
const std::vector< std::vector< T > > & getSortedValuesSets()
Returns a vector of sets that represent dependency resolved values.
void addInfo(const std::string &key0, const std::string &file, int line)
Associate a key with file/line info.
FileLineInfo getInfo(const std::string &key0) const
Get file/line info for a key.
Holds file and line information.
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.
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...
DependencyResolver< std::string > _tasks
The dependency resolver.
const std::multimap< std::string, ActionInfo > & getAssociatedActions() const
Return all Syntax to Action associations.
std::map< std::string, bool > _registered_tasks
The list of registered tasks and a flag indicating whether or not they should be auto-built.
void addDependencySets(const std::string &action_sets)
Adds all dependencies in a single call.
void registerTaskName(const std::string &task, bool should_auto_build=false)
Method to register a new task.
const std::vector< std::vector< std::string > > & getSortedTaskSet()
Get a list of serialized tasks in a correct dependency order.
bool _actions_to_syntax_valid
Boolean indicating whether the _actions_to_syntax map is built and valid and synced.
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 ...
void registerSyntaxType(const std::string &syntax, const std::string &type)
Register a type with a block.
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...
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 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...
void addDependency(const std::string &task, const std::string &pre_req)
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.
const std::multimap< std::string, std::string > & getAssociatedTypes() const
Get a multimap of registered associations of syntax with type.
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,...
void deprecateActionSyntax(const std::string &syntax)
This method deprecates previously registered syntax.
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...
bool isDeprecatedSyntax(const std::string &syntax) const
Returns a Boolean indicating whether the syntax has been deprecated through a call to deprecateAction...
const std::vector< std::string > & getSortedTask()
Get a list of serialized tasks in a correct dependency order.
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.
std::string deprecatedActionSyntaxMessage(const std::string syntax)
Returns the deprecation message for a given syntax that has been deprecated by deprecateActionSyntax.
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 deleteTaskDependencies(const std::string &task)
Deletes or removes the dependencies that this task depends on.
bool hasTask(const std::string &task) const
Returns a Boolean indicating whether or not a task is registered with the syntax object.
std::map< std::string, std::string > _deprecated_syntax
The list of deprecated syntax items and the associated deprecated message.
std::multimap< std::string, ActionInfo > _syntax_to_actions
The syntax object to ActionInfo (Action+task) associations.
void removeAllActionsForSyntax(const std::string &syntax)
De-registers all actions associated with a given syntax.
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.
std::multimap< std::string, std::string > _associated_types
Syntax/Type association.
void clearTaskDependencies()
Clears all tasks from the system object.
bool isActionRequired(const std::string &task) const
Returns a Boolean indicating whether the specified task is required.
FileLineInfoMap _syntax_to_line
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 ...