https://mooseframework.inl.gov
Syntax.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
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 #pragma once
11 
12 #include <string>
13 #include <map>
14 #include <set>
15 #include "DependencyResolver.h"
16 #include "FileLineInfo.h"
17 
21 class Syntax
22 {
23 public:
24  struct ActionInfo
25  {
26  std::string _action;
27  std::string _task;
28  };
29 
30  Syntax();
31 
39  void registerTaskName(const std::string & task, bool should_auto_build = false);
40 
47  void registerTaskName(const std::string & task,
48  const std::string & moose_object_type,
49  bool should_auto_build = false);
50 
58  void
59  appendTaskName(const std::string & task, const std::string & moose_object_type, bool deprecated);
60 
61  void addDependency(const std::string & task, const std::string & pre_req);
62 
67  void addDependencySets(const std::string & action_sets);
68 
73  void deleteTaskDependencies(const std::string & task);
74 
78  void clearTaskDependencies();
79 
84  const std::vector<std::string> & getSortedTask();
85 
90  const std::vector<std::vector<std::string>> & getSortedTaskSet();
91 
95  bool hasTask(const std::string & task) const;
96 
101  bool isActionRequired(const std::string & task) const;
102 
107  bool shouldAutoBuild(const std::string & task) const;
108 
112  void registerActionSyntax(const std::string & action,
113  const std::string & syntax,
114  const std::string & task = "",
115  const std::string & file = "",
116  int line = -1);
117 
121  void removeAllActionsForSyntax(const std::string & syntax);
122 
128  void replaceActionSyntax(const std::string & action,
129  const std::string & syntax,
130  const std::string & task,
131  const std::string & file = "",
132  int line = -1);
133 
139  void registerSyntaxType(const std::string & syntax, const std::string & type);
140 
144  const std::multimap<std::string, std::string> & getAssociatedTypes() const;
145 
150  void deprecateActionSyntax(const std::string & syntax);
151  void deprecateActionSyntax(const std::string & syntax, const std::string & message);
152 
157  std::string deprecatedActionSyntaxMessage(const std::string syntax);
158 
163  bool isDeprecatedSyntax(const std::string & syntax) const;
164 
169  std::vector<std::string> getSyntaxByAction(const std::string & action,
170  const std::string & task = "");
171 
176  std::vector<std::string> getNonDeprecatedSyntaxByAction(const std::string & action,
177  const std::string & task = "");
178 
184  std::string isAssociated(const std::string & real_id,
185  bool * is_parent,
186  const std::map<std::string, std::set<std::string>> & alt_map = {}) const;
187 
192  std::pair<std::multimap<std::string, ActionInfo>::const_iterator,
193  std::multimap<std::string, ActionInfo>::const_iterator>
194  getActions(const std::string & syntax) const;
195 
199  const std::multimap<std::string, ActionInfo> & getAssociatedActions() const;
200 
206  bool verifyMooseObjectTask(const std::string & base, const std::string & task) const;
207 
215  FileLineInfo getLineInfo(const std::string & syntax,
216  const std::string & action,
217  const std::string & task) const;
218 
219 protected:
221  std::map<std::string, bool> _registered_tasks;
222 
224  std::multimap<std::string, std::string> _moose_systems_to_tasks;
225 
229  std::multimap<std::string, std::string> _deprecated_list_moose_systems_to_tasks;
230 
233 
235  std::multimap<std::string, ActionInfo> _syntax_to_actions;
236 
239  std::multimap<std::string, std::pair<std::string, std::string>> _actions_to_syntax;
240 
242  std::multimap<std::string, std::string> _associated_types;
243 
246 
248  std::map<std::string, std::string> _deprecated_syntax;
249 
251 };
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:125
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...
Definition: Syntax.C:46
const std::multimap< std::string, std::string > & getAssociatedTypes() const
Get a multimap of registered associations of syntax with type.
Definition: Syntax.C:368
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:328
const std::multimap< std::string, ActionInfo > & getAssociatedActions() const
Return all Syntax to Action associations.
Definition: Syntax.C:374
bool _actions_to_syntax_valid
Boolean indicating whether the _actions_to_syntax map is built and valid and synced.
Definition: Syntax.h:245
void deleteTaskDependencies(const std::string &task)
Deletes or removes the dependencies that this task depends on.
Definition: Syntax.C:90
void addDependency(const std::string &task, const std::string &pre_req)
Definition: Syntax.C:60
FileLineInfoMap _syntax_to_line
Definition: Syntax.h:250
DependencyResolver< std::string > _tasks
The dependency resolver.
Definition: Syntax.h:232
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:239
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:380
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
const std::vector< std::string > & getSortedTask()
Get a list of serialized tasks in a correct dependency order.
Definition: Syntax.C:105
bool isActionRequired(const std::string &task) const
Returns a Boolean indicating whether the specified task is required.
Definition: Syntax.C:131
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
std::string _action
Definition: Syntax.h:26
void removeAllActionsForSyntax(const std::string &syntax)
De-registers all actions associated with a given syntax.
Definition: Syntax.C:175
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
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
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.
Definition: Syntax.C:237
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::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
const std::vector< std::vector< std::string > > & getSortedTaskSet()
Get a list of serialized tasks in a correct dependency order.
Definition: Syntax.C:119
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:164
void clearTaskDependencies()
Clears all tasks from the system object.
Definition: Syntax.C:99
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:69
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 ...
Definition: Syntax.C:251
std::string _task
Definition: Syntax.h:27
Syntax()
Definition: Syntax.C:17
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
void registerSyntaxType(const std::string &syntax, const std::string &type)
Register a type with a block.
Definition: Syntax.C:362
Holding syntax for parsing input files.
Definition: Syntax.h:21
std::map< std::string, std::string > _deprecated_syntax
The list of deprecated syntax items and the associated deprecated message.
Definition: Syntax.h:248
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:334
std::multimap< std::string, ActionInfo > _syntax_to_actions
The syntax object to ActionInfo (Action+task) associations.
Definition: Syntax.h:235
std::string deprecatedActionSyntaxMessage(const std::string syntax)
Returns the deprecation message for a given syntax that has been deprecated by deprecateActionSyntax...
Definition: Syntax.C:194
void deprecateActionSyntax(const std::string &syntax)
This method deprecates previously registered syntax.
Definition: Syntax.C:181
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:242