https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Attributes | List of all members
Syntax Class Reference

Holding syntax for parsing input files. More...

#include <Syntax.h>

Classes

struct  ActionInfo
 

Public Member Functions

 Syntax ()
 
void registerTaskName (const std::string &task, bool should_auto_build=false)
 Method to register a new task.
 
void registerTaskName (const std::string &task, const std::string &moose_object_type, bool should_auto_build=false)
 Method to register a new task (see overload method with same name).
 
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 addDependency (const std::string &task, const std::string &pre_req)
 
void addDependencySets (const std::string &action_sets)
 Adds all dependencies in a single call.
 
void deleteTaskDependencies (const std::string &task)
 Deletes or removes the dependencies that this task depends on.
 
void clearTaskDependencies ()
 Clears all tasks from the system object.
 
const std::vector< std::string > & getSortedTask ()
 Get a list of serialized tasks in a correct dependency order.
 
const std::vector< std::vector< std::string > > & getSortedTaskSet ()
 Get a list of serialized tasks in a correct dependency order.
 
bool hasTask (const std::string &task) const
 Returns a Boolean indicating whether or not a task is registered with the syntax object.
 
bool isActionRequired (const std::string &task) const
 Returns a Boolean indicating whether the specified task is required.
 
bool shouldAutoBuild (const std::string &task) const
 Returns a Boolean indicating whether MOOSE should attempt to automatically create an Action to satisfy a task if an Action doesn't already exist to service that task.
 
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.
 
void removeAllActionsForSyntax (const std::string &syntax)
 De-registers all actions associated with a given 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 function will remove all actions associated with this piece of syntax NOT just a single match of some kind.
 
void registerSyntaxType (const std::string &syntax, const std::string &type)
 Register a type with a block.
 
const std::multimap< std::string, std::string > & getAssociatedTypes () const
 Get a multimap of registered associations of syntax with type.
 
void deprecateActionSyntax (const std::string &syntax)
 This method deprecates previously registered syntax.
 
void deprecateActionSyntax (const std::string &syntax, const std::string &message)
 
std::string deprecatedActionSyntaxMessage (const std::string syntax)
 Returns the deprecation message for a given syntax that has been deprecated by deprecateActionSyntax.
 
bool isDeprecatedSyntax (const std::string &syntax) const
 Returns a Boolean indicating whether the syntax has been deprecated through a call to 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.
 
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.
 
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 may be given to traverse instead of _syntax_to_actions TODO: I need a better name.
 
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 syntax.
 
const std::multimap< std::string, ActionInfo > & getAssociatedActions () const
 Return all Syntax to Action associations.
 
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 (BASE CLASSES).
 
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.
 

Protected Attributes

std::map< std::string, bool > _registered_tasks
 The list of registered tasks and a flag indicating whether or not they should be auto-built.
 
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 certain MooseObjects.
 
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.
 
DependencyResolver< std::string > _tasks
 The dependency resolver.
 
std::multimap< std::string, ActionInfo_syntax_to_actions
 The syntax object to ActionInfo (Action+task) associations.
 
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, Task)
 
std::multimap< std::string, std::string > _associated_types
 Syntax/Type association.
 
bool _actions_to_syntax_valid
 Boolean indicating whether the _actions_to_syntax map is built and valid and synced.
 
std::map< std::string, std::string > _deprecated_syntax
 The list of deprecated syntax items and the associated deprecated message.
 
FileLineInfoMap _syntax_to_line
 

Detailed Description

Holding syntax for parsing input files.

Definition at line 21 of file Syntax.h.

Constructor & Destructor Documentation

◆ Syntax()

Syntax::Syntax ( )

Definition at line 17 of file Syntax.C.

bool _actions_to_syntax_valid
Boolean indicating whether the _actions_to_syntax map is built and valid and synced.
Definition Syntax.h:245

Member Function Documentation

◆ addDependency()

void Syntax::addDependency ( const std::string &  task,
const std::string &  pre_req 
)

Definition at line 60 of file Syntax.C.

61{
62 if (_registered_tasks.find(task) == _registered_tasks.end())
63 mooseError("A ", task, " is not a registered task name.");
64
65 _tasks.insertDependency(task, pre_req);
66}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
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".
DependencyResolver< std::string > _tasks
The dependency resolver.
Definition Syntax.h:232
std::map< std::string, bool > _registered_tasks
The list of registered tasks and a flag indicating whether or not they should be auto-built.
Definition Syntax.h:221

Referenced by addDependencySets(), and MooseApp::setupOptions().

◆ addDependencySets()

void Syntax::addDependencySets ( const std::string &  action_sets)

Adds all dependencies in a single call.

The string is split on parenthesis and each task listed within the parenthesis is given equal precedence.

Definition at line 69 of file Syntax.C.

70{
71 std::vector<std::string> sets, prev_names, tasks;
72 MooseUtils::tokenize(action_sets, sets, 1, "()");
73
74 for (unsigned int i = 0; i < sets.size(); ++i)
75 {
76 tasks.clear();
77 MooseUtils::tokenize(sets[i], tasks, 0, ", ");
78 for (unsigned int j = 0; j < tasks.size(); ++j)
79 {
80 // Each line should depend on each item in the previous line
81 for (unsigned int k = 0; k < prev_names.size(); ++k)
82 addDependency(tasks[j], prev_names[k]);
83 }
84 // Copy the the current items to the previous items for the next iteration
85 std::swap(tasks, prev_names);
86 }
87}
void addDependency(const std::string &task, const std::string &pre_req)
Definition Syntax.C:60
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 ...

◆ appendTaskName()

void Syntax::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.

Each object created during a task is checked against associated systems.

Parameters
taskthe task to allow a new type of moose objects for
moose_object_typethe type of objects to allow with this task
deprecatedwhether constructing this moose object with this task is deprecated

Definition at line 46 of file Syntax.C.

49{
50 if (_registered_tasks.find(task) == _registered_tasks.end())
51 mooseError("A ", task, " is not a registered task name.");
52
53 if (!deprecated)
54 _moose_systems_to_tasks.insert(std::make_pair(moose_object_type, task));
55 else
56 _deprecated_list_moose_systems_to_tasks.insert(std::make_pair(moose_object_type, task));
57}
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...
Definition Syntax.h:224
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.
Definition Syntax.h:229

◆ clearTaskDependencies()

void Syntax::clearTaskDependencies ( )

Clears all tasks from the system object.

Definition at line 99 of file Syntax.C.

100{
101 _tasks.clear();
102}
void clear()
Clear Items from the resolver.

◆ deleteTaskDependencies()

void Syntax::deleteTaskDependencies ( const std::string &  task)

Deletes or removes the dependencies that this task depends on.

This method does not fixup or change the graph in any other way.

Definition at line 90 of file Syntax.C.

91{
92 if (_registered_tasks.find(task) == _registered_tasks.end())
93 mooseError("A ", task, " is not a registered task name.");
94
96}
void deleteDependenciesOfKey(const T &key)
Removes dependencies of the given key.

◆ deprecateActionSyntax() [1/2]

void Syntax::deprecateActionSyntax ( const std::string &  syntax)

This method deprecates previously registered syntax.

You should use the exact form that you want deprecated in the passed in parameter.

Definition at line 181 of file Syntax.C.

182{
183 const std::string message = "\"[" + syntax + "]\" is deprecated.";
184 deprecateActionSyntax(syntax, message);
185}
void deprecateActionSyntax(const std::string &syntax)
This method deprecates previously registered syntax.
Definition Syntax.C:181

Referenced by deprecateActionSyntax().

◆ deprecateActionSyntax() [2/2]

void Syntax::deprecateActionSyntax ( const std::string &  syntax,
const std::string &  message 
)

Definition at line 188 of file Syntax.C.

189{
190 _deprecated_syntax.insert(std::make_pair(syntax, message));
191}
std::map< std::string, std::string > _deprecated_syntax
The list of deprecated syntax items and the associated deprecated message.
Definition Syntax.h:248

◆ deprecatedActionSyntaxMessage()

std::string Syntax::deprecatedActionSyntaxMessage ( const std::string  syntax)

Returns the deprecation message for a given syntax that has been deprecated by deprecateActionSyntax.

Definition at line 194 of file Syntax.C.

195{
196 auto it = _deprecated_syntax.find(syntax);
197
198 if (it != _deprecated_syntax.end())
199 return it->second;
200 else
201 mooseError("The action syntax ", syntax, " is not deprecated");
202}

Referenced by Moose::Builder::walkRaw().

◆ getActions()

std::pair< std::multimap< std::string, Syntax::ActionInfo >::const_iterator, std::multimap< std::string, Syntax::ActionInfo >::const_iterator > Syntax::getActions ( const std::string &  syntax) const

Returns a pair of multimap iterators to all the ActionInfo objects associated with a given piece of syntax.

Definition at line 329 of file Syntax.C.

330{
331 return _syntax_to_actions.equal_range(syntax);
332}
std::multimap< std::string, ActionInfo > _syntax_to_actions
The syntax object to ActionInfo (Action+task) associations.
Definition Syntax.h:235

Referenced by MooseServer::getActionParameters(), Moose::Builder::listValidParams(), and Moose::Builder::walkRaw().

◆ getAssociatedActions()

const std::multimap< std::string, Syntax::ActionInfo > & Syntax::getAssociatedActions ( ) const

◆ getAssociatedTypes()

const std::multimap< std::string, std::string > & Syntax::getAssociatedTypes ( ) const

Get a multimap of registered associations of syntax with type.

Definition at line 369 of file Syntax.C.

370{
371 return _associated_types;
372}
std::multimap< std::string, std::string > _associated_types
Syntax/Type association.
Definition Syntax.h:242

Referenced by MooseServer::addValuesToList(), Moose::Builder::buildJsonSyntaxTree(), MooseServer::gatherDocumentReferencesLocations(), MooseServer::getCompletionItemKind(), and MooseServer::getInputLookupDefinitionNodes().

◆ getLineInfo()

FileLineInfo Syntax::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.

Parameters
syntaxSyntax name
actionAction name
taskTask name
Returns
A FileLineInfo associated with the syntax/action/task triplet

Definition at line 381 of file Syntax.C.

384{
385 return _syntax_to_line.getInfo(syntax, action, task);
386}
FileLineInfo getInfo(const std::string &key0) const
Get file/line info for a key.
FileLineInfoMap _syntax_to_line
Definition Syntax.h:250

Referenced by Moose::Builder::buildJsonSyntaxTree().

◆ getNonDeprecatedSyntaxByAction()

std::vector< std::string > Syntax::getNonDeprecatedSyntaxByAction ( const std::string &  action,
const std::string &  task = "" 
)

Retrieve the non-deprecated syntax associated with the passed in action type string.

If a task string is also passed in, only syntax associated with that action+task combo will be returned.

Definition at line 238 of file Syntax.C.

239{
240 auto syntaxes = getSyntaxByAction(action, task);
241 for (auto syntax_it = begin(syntaxes); syntax_it != end(syntaxes);)
242 {
243 if (isDeprecatedSyntax(*syntax_it))
244 syntax_it = syntaxes.erase(syntax_it);
245 else
246 ++syntax_it;
247 }
248 return syntaxes;
249}
bool isDeprecatedSyntax(const std::string &syntax) const
Returns a Boolean indicating whether the syntax has been deprecated through a call to deprecateAction...
Definition Syntax.C:205
std::vector< std::string > getSyntaxByAction(const std::string &action, const std::string &task="")
Retrieve the syntax associated with the passed in action type string.
Definition Syntax.C:211

Referenced by ActionWarehouse::addActionBlock().

◆ getSortedTask()

const std::vector< std::string > & Syntax::getSortedTask ( )

Get a list of serialized tasks in a correct dependency order.

The order my be more ordered than specified.

Definition at line 105 of file Syntax.C.

106{
107 try
108 {
109 return _tasks.getSortedValues();
110 }
112 {
113 const auto & cycle = e.getCyclicDependencies();
114 mooseError("Cyclic dependencies detected: ", MooseUtils::join(cycle, " <- "));
115 }
116}
const std::vector< T > & getCyclicDependencies() const
const std::vector< T > & getSortedValues()
This function also returns dependency resolved values but with a simpler single vector interface.

Referenced by ActionWarehouse::build().

◆ getSortedTaskSet()

const std::vector< std::vector< std::string > > & Syntax::getSortedTaskSet ( )

Get a list of serialized tasks in a correct dependency order.

The vector of sets return type assures that tasks with equal precedence appear in a single set.

Definition at line 119 of file Syntax.C.

120{
122}
const std::vector< std::vector< T > > & getSortedValuesSets()
Returns a vector of sets that represent dependency resolved values.

Referenced by ActionWarehouse::printActionDependencySets().

◆ getSyntaxByAction()

std::vector< std::string > Syntax::getSyntaxByAction ( const std::string &  action,
const std::string &  task = "" 
)

Retrieve the syntax associated with the passed in action type string.

If a task string is also passed in, only syntax associated with that action+task combo will be returned.

Definition at line 211 of file Syntax.C.

212{
213 // See if the reverse multimap has been built yet, if not build it now
215 {
216 std::transform(_syntax_to_actions.begin(),
217 _syntax_to_actions.end(),
218 std::inserter(_actions_to_syntax, _actions_to_syntax.begin()),
219 [](const std::pair<std::string, ActionInfo> pair)
220 {
221 return std::make_pair(pair.second._action,
222 std::make_pair(pair.first, pair.second._task));
223 });
225 }
226
227 std::vector<std::string> syntax;
228 auto it_pair = _actions_to_syntax.equal_range(action);
229 for (const auto & syntax_pair : as_range(it_pair))
230 // If task is blank, return all syntax, otherwise filter by task
231 if (task == "" || syntax_pair.second.second == task)
232 syntax.emplace_back(syntax_pair.second.first);
233
234 return syntax;
235}
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD
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,...
Definition Syntax.h:239
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)

Referenced by Moose::Builder::build(), getNonDeprecatedSyntaxByAction(), and Moose::Builder::queryGlobalParamsNode().

◆ hasTask()

bool Syntax::hasTask ( const std::string &  task) const

Returns a Boolean indicating whether or not a task is registered with the syntax object.

Definition at line 125 of file Syntax.C.

126{
127 return (_registered_tasks.find(task) != _registered_tasks.end());
128}

Referenced by ActionWarehouse::addActionBlock(), and ActionWarehouse::setFinalTask().

◆ isActionRequired()

bool Syntax::isActionRequired ( const std::string &  task) const

Returns a Boolean indicating whether the specified task is required.

DEPRECATED (use shouldAutoBuild).

Definition at line 131 of file Syntax.C.

132{
133 mooseDeprecated("Syntax::isActionRequired is deprecated, use shouldAutoBuild() instead");
134 return shouldAutoBuild(task);
135}
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition MooseError.h:363
bool shouldAutoBuild(const std::string &task) const
Returns a Boolean indicating whether MOOSE should attempt to automatically create an Action to satisf...
Definition Syntax.C:138

◆ isAssociated()

std::string Syntax::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 may be given to traverse instead of _syntax_to_actions TODO: I need a better name.

This implementation assumes that wildcards can occur in the place of an entire token but not as part of a token (i.e. 'Variables/ * /InitialConditions' is valid but not 'Variables/Partial* /InitialConditions'. Since maps are ordered, a reverse traversal through the registered list will always select a more specific match before a wildcard match ('*' == char(42)).

Definition at line 252 of file Syntax.C.

255{
256 // if non-empty alt_map was provided then traverse its syntax instead of _syntax_to_actions
257 std::set<std::string> syntax_to_traverse;
258 if (!alt_map.empty())
259 std::transform(alt_map.begin(),
260 alt_map.end(),
261 std::inserter(syntax_to_traverse, syntax_to_traverse.end()),
262 [](auto pair) { return pair.first; });
263 else
264 std::transform(_syntax_to_actions.begin(),
265 _syntax_to_actions.end(),
266 std::inserter(syntax_to_traverse, syntax_to_traverse.end()),
267 [](auto pair) { return pair.first; });
268
275 bool local_is_parent;
276 if (is_parent == nullptr)
277 is_parent = &local_is_parent; // Just so we don't have to keep checking below when we want to
278 // set the value
279 std::vector<std::string> real_elements, reg_elements;
280 std::string return_value;
281
282 MooseUtils::tokenize(real_id, real_elements);
283
284 *is_parent = false;
285 for (auto it = syntax_to_traverse.rbegin(); it != syntax_to_traverse.rend(); ++it)
286 {
287 std::string reg_id = *it;
288 if (reg_id == real_id)
289 {
290 *is_parent = false;
291 return reg_id;
292 }
293 reg_elements.clear();
294 MooseUtils::tokenize(reg_id, reg_elements);
295 if (real_elements.size() <= reg_elements.size())
296 {
297 bool keep_going = true;
298 for (unsigned int j = 0; keep_going && j < real_elements.size(); ++j)
299 {
300 if (real_elements[j] != reg_elements[j] && reg_elements[j] != std::string("*"))
301 keep_going = false;
302 }
303 if (keep_going)
304 {
305 if (real_elements.size() < reg_elements.size() && !*is_parent)
306 {
307 // We found a parent, the longest parent in fact but we need to keep
308 // looking to make sure that the real thing isn't registered
309 *is_parent = true;
310 return_value = reg_id;
311 }
312 else if (real_elements.size() == reg_elements.size())
313 {
314 *is_parent = false;
315 return reg_id;
316 }
317 }
318 }
319 }
320
321 if (*is_parent)
322 return return_value;
323 else
324 return "";
325}

Referenced by MooseServer::addSubblocksToList(), MooseServer::gatherDocumentReferencesLocations(), MooseServer::getActionParameters(), Moose::Builder::listValidParams(), ActionWarehouse::printInputFile(), and Moose::Builder::walkRaw().

◆ isDeprecatedSyntax()

bool Syntax::isDeprecatedSyntax ( const std::string &  syntax) const

Returns a Boolean indicating whether the syntax has been deprecated through a call to deprecateActionSyntax.

Definition at line 205 of file Syntax.C.

206{
207 return _deprecated_syntax.find(syntax) != _deprecated_syntax.end();
208}

Referenced by getNonDeprecatedSyntaxByAction(), and Moose::Builder::walkRaw().

◆ registerActionSyntax()

void Syntax::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.

Definition at line 147 of file Syntax.C.

152{
153 auto range = _syntax_to_actions.equal_range(syntax);
154 for (auto it = range.first; it != range.second; ++it)
155 if (it->second._action == action && it->second._task == task)
156 return;
157
158 _syntax_to_actions.insert(std::make_pair(syntax, ActionInfo{action, task}));
159 _syntax_to_line.addInfo(syntax, action, task, file, line);
161}
void addInfo(const std::string &key0, const std::string &file, int line)
Associate a key with file/line info.

Referenced by replaceActionSyntax().

◆ registerSyntaxType()

void Syntax::registerSyntaxType ( const std::string &  syntax,
const std::string &  type 
)

Register a type with a block.

For example, associate FunctionName with the Functions block.

Parameters
syntaxThe target syntax to associate the type with
typeThe name of the type to associate with the syntax

Definition at line 363 of file Syntax.C.

364{
365 _associated_types.insert(std::make_pair(syntax, type));
366}

◆ registerTaskName() [1/2]

void Syntax::registerTaskName ( const std::string &  task,
bool  should_auto_build = false 
)

Method to register a new task.

Tasks are short verbs (strings) that describe a particular point in the simulation setup phase.

Parameters
taskThe task (verb) to be registered with MOOSE.
should_autobuildindicates whether the task should be autobuilt if not supplied elsewhere.

Definition at line 20 of file Syntax.C.

21{
22 if (_registered_tasks.count(task) > 0)
23 return;
24 _tasks.addItem(task);
25 _registered_tasks[task] = should_auto_build;
26}
void addItem(const T &value)
Add an independent item to the set.

Referenced by registerTaskName(), and MooseApp::setupOptions().

◆ registerTaskName() [2/2]

void Syntax::registerTaskName ( const std::string &  task,
const std::string &  moose_object_type,
bool  should_auto_build = false 
)

Method to register a new task (see overload method with same name).

This version also accepts a string representing a pluggable MOOSE system. When objects are created through a task, the MOOSE system is checked if it exists to make sure it's "allowed" to create those types of objects.

Definition at line 29 of file Syntax.C.

32{
33 auto range = _moose_systems_to_tasks.equal_range(moose_object_type);
34 for (auto it = range.first; it != range.second; ++it)
35 if (it->second == task)
36 return;
37
38 if (_registered_tasks.find(task) != _registered_tasks.end())
39 mooseError("A ", task, " is already registered. Do you need to use appendTaskName instead?");
40
41 registerTaskName(task, should_auto_build);
42 _moose_systems_to_tasks.insert(std::make_pair(moose_object_type, task));
43}
void registerTaskName(const std::string &task, bool should_auto_build=false)
Method to register a new task.
Definition Syntax.C:20

◆ removeAllActionsForSyntax()

void Syntax::removeAllActionsForSyntax ( const std::string &  syntax)

De-registers all actions associated with a given syntax.

Definition at line 175 of file Syntax.C.

176{
177 _syntax_to_actions.erase(syntax);
178}

◆ replaceActionSyntax()

void Syntax::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 function will remove all actions associated with this piece of syntax NOT just a single match of some kind.

Definition at line 164 of file Syntax.C.

169{
170 _syntax_to_actions.erase(syntax);
171 registerActionSyntax(action, syntax, task, file, line);
172}
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.
Definition Syntax.C:147

◆ shouldAutoBuild()

bool Syntax::shouldAutoBuild ( const std::string &  task) const

Returns a Boolean indicating whether MOOSE should attempt to automatically create an Action to satisfy a task if an Action doesn't already exist to service that task.

Definition at line 138 of file Syntax.C.

139{
140 auto map_pair = _registered_tasks.find(task);
141 mooseAssert(map_pair != _registered_tasks.end(), std::string("Unregistered task: ") + task);
142
143 return map_pair->second;
144}

Referenced by ActionWarehouse::buildBuildableActions(), and isActionRequired().

◆ verifyMooseObjectTask()

bool Syntax::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 (BASE CLASSES).

See "registerMooseObjectTask" macro in Moose.C. This information can be used to determine whether certain objects may be safely built during the specified task.

Definition at line 335 of file Syntax.C.

336{
337 auto iters = _moose_systems_to_tasks.equal_range(base);
338
339 for (const auto & task_it : as_range(iters))
340 if (task == task_it.second)
341 return true;
342
343 iters = _deprecated_list_moose_systems_to_tasks.equal_range(base);
344 for (const auto & task_it : as_range(iters))
345 if (task == task_it.second)
346 {
347 std::string object_tasks = "";
348 for (const auto & other_task : as_range(_moose_systems_to_tasks.equal_range(base)))
349 object_tasks += (object_tasks == "" ? "" : " ") + other_task.second;
350
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.");
356 return true;
357 }
358
359 return false;
360}

Referenced by ActionWarehouse::addActionBlock(), MooseServer::addValuesToList(), Moose::Builder::buildFullTree(), Moose::Builder::buildJsonSyntaxTree(), MooseServer::getHoverDisplayText(), and MooseServer::getObjectParameters().

Member Data Documentation

◆ _actions_to_syntax

std::multimap<std::string, std::pair<std::string, std::string> > Syntax::_actions_to_syntax
protected

The ActionInfo (Action+task) to syntax associations (built only when needed) Action -> (Syntax, Task)

Definition at line 239 of file Syntax.h.

Referenced by getSyntaxByAction().

◆ _actions_to_syntax_valid

bool Syntax::_actions_to_syntax_valid
protected

Boolean indicating whether the _actions_to_syntax map is built and valid and synced.

Definition at line 245 of file Syntax.h.

Referenced by getSyntaxByAction(), and registerActionSyntax().

◆ _associated_types

std::multimap<std::string, std::string> Syntax::_associated_types
protected

Syntax/Type association.

Definition at line 242 of file Syntax.h.

Referenced by getAssociatedTypes(), and registerSyntaxType().

◆ _deprecated_list_moose_systems_to_tasks

std::multimap<std::string, std::string> Syntax::_deprecated_list_moose_systems_to_tasks
protected

A list of Moose system objects to tasks that are deprecated for these systems.

If an item is in this map, the task is still allowed to build the object from the MOOSE system, but it is deprecated to do so.

Definition at line 229 of file Syntax.h.

Referenced by appendTaskName(), and verifyMooseObjectTask().

◆ _deprecated_syntax

std::map<std::string, std::string> Syntax::_deprecated_syntax
protected

The list of deprecated syntax items and the associated deprecated message.

Definition at line 248 of file Syntax.h.

Referenced by deprecateActionSyntax(), deprecatedActionSyntaxMessage(), and isDeprecatedSyntax().

◆ _moose_systems_to_tasks

std::multimap<std::string, std::string> Syntax::_moose_systems_to_tasks
protected

The list of Moose system objects to tasks. This map indicates which tasks are allowed to build certain MooseObjects.

Definition at line 224 of file Syntax.h.

Referenced by appendTaskName(), registerTaskName(), and verifyMooseObjectTask().

◆ _registered_tasks

std::map<std::string, bool> Syntax::_registered_tasks
protected

The list of registered tasks and a flag indicating whether or not they should be auto-built.

Definition at line 221 of file Syntax.h.

Referenced by addDependency(), appendTaskName(), deleteTaskDependencies(), hasTask(), registerTaskName(), registerTaskName(), and shouldAutoBuild().

◆ _syntax_to_actions

std::multimap<std::string, ActionInfo> Syntax::_syntax_to_actions
protected

The syntax object to ActionInfo (Action+task) associations.

Definition at line 235 of file Syntax.h.

Referenced by getActions(), getAssociatedActions(), getSyntaxByAction(), isAssociated(), registerActionSyntax(), removeAllActionsForSyntax(), and replaceActionSyntax().

◆ _syntax_to_line

FileLineInfoMap Syntax::_syntax_to_line
protected

Definition at line 250 of file Syntax.h.

Referenced by getLineInfo(), and registerActionSyntax().

◆ _tasks

DependencyResolver<std::string> Syntax::_tasks
protected

The dependency resolver.

Definition at line 232 of file Syntax.h.

Referenced by addDependency(), clearTaskDependencies(), deleteTaskDependencies(), getSortedTask(), getSortedTaskSet(), and registerTaskName().


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