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
10 #pragma once
12 #include <string>
13 #include <map>
14 #include "DependencyResolver.h"
15 #include "FileLineInfo.h"
20 class Syntax
21 {
22 public:
23  struct ActionInfo
24  {
25  std::string _action;
26  std::string _task;
27  };
29  Syntax();
38  void registerTaskName(const std::string & task, bool should_auto_build = false);
46  void registerTaskName(const std::string & task,
47  const std::string & moose_object_type,
48  bool should_auto_build = false);
54  void appendTaskName(const std::string & task, const std::string & moose_object_type);
59  void addDependency(const std::string & task, const std::string & pre_req);
65  void addDependencySets(const std::string & action_sets);
71  void deleteTaskDependencies(const std::string & task);
76  void clearTaskDependencies();
82  const std::vector<std::string> & getSortedTask();
88  const std::vector<std::vector<std::string>> & getSortedTaskSet();
93  bool hasTask(const std::string & task) const;
99  bool isActionRequired(const std::string & task) const;
105  bool shouldAutoBuild(const std::string & task) const;
110  void registerActionSyntax(const std::string & action,
111  const std::string & syntax,
112  const std::string & task = "",
113  const std::string & file = "",
114  int line = -1);
121  void replaceActionSyntax(const std::string & action,
122  const std::string & syntax,
123  const std::string & task,
124  const std::string & file = "",
125  int line = -1);
132  void registerSyntaxType(const std::string & syntax, const std::string & type);
137  const std::multimap<std::string, std::string> & getAssociatedTypes() const;
143  void deprecateActionSyntax(const std::string & syntax);
144  void deprecateActionSyntax(const std::string & syntax, const std::string & message);
150  std::string deprecatedActionSyntaxMessage(const std::string syntax);
156  bool isDeprecatedSyntax(const std::string & syntax) const;
162  std::vector<std::string> getSyntaxByAction(const std::string & action,
163  const std::string & task = "");
169  std::string isAssociated(const std::string & real_id, bool * is_parent) const;
175  std::pair<std::multimap<std::string, ActionInfo>::const_iterator,
176  std::multimap<std::string, ActionInfo>::const_iterator>
177  getActions(const std::string & syntax) const;
182  const std::multimap<std::string, ActionInfo> & getAssociatedActions() const;
189  bool verifyMooseObjectTask(const std::string & base, const std::string & task) const;
198  FileLineInfo getLineInfo(const std::string & syntax,
199  const std::string & action,
200  const std::string & task) const;
202 protected:
204  std::map<std::string, bool> _registered_tasks;
207  std::multimap<std::string, std::string> _moose_systems_to_tasks;
213  std::multimap<std::string, ActionInfo> _syntax_to_actions;
217  std::multimap<std::string, std::pair<std::string, std::string>> _actions_to_syntax;
220  std::multimap<std::string, std::string> _associated_types;
226  std::map<std::string, std::string> _deprecated_syntax;
229 };
bool hasTask(const std::string &task) const
Returns a Boolean indicating whether or not a task is registered with the syntax object.
Definition: Syntax.C:112
const std::multimap< std::string, std::string > & getAssociatedTypes() const
Get a multimap of registered associations of syntax with type.
Definition: Syntax.C:304
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...
Definition: Syntax.C:280
const std::multimap< std::string, ActionInfo > & getAssociatedActions() const
Return all Syntax to Action associations.
Definition: Syntax.C:310
bool _actions_to_syntax_valid
Boolean indicating whether the _actions_to_syntax map is built and valid and synced.
Definition: Syntax.h:223
void deleteTaskDependencies(const std::string &task)
Deletes or removes the dependencies that this task depends on.
Definition: Syntax.C:85
void addDependency(const std::string &task, const std::string &pre_req)
Method to insert a new task in the list of existing tasks at the specified location.
Definition: Syntax.C:55
FileLineInfoMap _syntax_to_line
Definition: Syntax.h:228
DependencyResolver< std::string > _tasks
The dependency resolver.
Definition: Syntax.h:210
void registerTaskName(const std::string &task, bool should_auto_build=false)
Method to register a new task.
Definition: Syntax.C:20
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:217
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.
Definition: Syntax.C:316
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:134
const std::vector< std::string > & getSortedTask()
Get a list of serialized tasks in a correct dependency order.
Definition: Syntax.C:100
bool isActionRequired(const std::string &task) const
Returns a Boolean indicating whether the specified task is required.
Definition: Syntax.C:118
std::string _action
Definition: Syntax.h:25
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:192
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:125
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:186
std::string isAssociated(const std::string &real_id, bool *is_parent) const
Method for determining whether a piece of syntax is associated with an Action TODO: I need a better n...
Definition: Syntax.C:218
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:204
const std::vector< std::vector< std::string > > & getSortedTaskSet()
Get a list of serialized tasks in a correct dependency order.
Definition: Syntax.C:106
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...
Definition: Syntax.C:151
void clearTaskDependencies()
Clears all tasks from the system object.
Definition: Syntax.C:94
Holds file and line information.
Definition: FileLineInfo.h:18
void addDependencySets(const std::string &action_sets)
Adds all dependencies in a single call.
Definition: Syntax.C:64
std::string _task
Definition: Syntax.h:26
Definition: Syntax.C:17
MatType type
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:207
void registerSyntaxType(const std::string &syntax, const std::string &type)
Register a type with a block.
Definition: Syntax.C:298
Holding syntax for parsing input files.
Definition: Syntax.h:20
std::map< std::string, std::string > _deprecated_syntax
The list of deprecated syntax items and the associated deprecated message.
Definition: Syntax.h:226
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...
Definition: Syntax.C:286
std::multimap< std::string, ActionInfo > _syntax_to_actions
The syntax object to ActionInfo (Action+task) associations.
Definition: Syntax.h:213
void appendTaskName(const std::string &task, const std::string &moose_object_type)
Method to associate another "allowed" pluggable MOOSE system to an existing registered task...
Definition: Syntax.C:46
std::string deprecatedActionSyntaxMessage(const std::string syntax)
Returns the deprecation message for a given syntax that has been deprecated by deprecateActionSyntax...
Definition: Syntax.C:175
void deprecateActionSyntax(const std::string &syntax)
This method deprecates previously registered syntax.
Definition: Syntax.C:162
A mapping between a series of keys to a FileLineInfo.
Definition: FileLineInfo.h:40
std::multimap< std::string, std::string > _associated_types
Syntax/Type association.
Definition: Syntax.h:220