www.mooseframework.org
Syntax.h
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
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 
123  void replaceActionSyntax(const std::string & action,
124  const std::string & syntax,
125  const std::string & task,
126  const std::string & file = "",
127  int line = -1);
128 
134  void registerSyntaxType(const std::string & syntax, const std::string & type);
135 
139  const std::multimap<std::string, std::string> & getAssociatedTypes() const;
140 
145  void deprecateActionSyntax(const std::string & syntax);
146  void deprecateActionSyntax(const std::string & syntax, const std::string & message);
147 
152  std::string deprecatedActionSyntaxMessage(const std::string syntax);
153 
158  bool isDeprecatedSyntax(const std::string & syntax) const;
159 
164  std::vector<std::string> getSyntaxByAction(const std::string & action,
165  const std::string & task = "");
166 
171  std::vector<std::string> getNonDeprecatedSyntaxByAction(const std::string & action,
172  const std::string & task = "");
173 
179  std::string isAssociated(const std::string & real_id,
180  bool * is_parent,
181  const std::map<std::string, std::set<std::string>> & alt_map = {}) const;
182 
187  std::pair<std::multimap<std::string, ActionInfo>::const_iterator,
188  std::multimap<std::string, ActionInfo>::const_iterator>
189  getActions(const std::string & syntax) const;
190 
194  const std::multimap<std::string, ActionInfo> & getAssociatedActions() const;
195 
201  bool verifyMooseObjectTask(const std::string & base, const std::string & task) const;
202 
210  FileLineInfo getLineInfo(const std::string & syntax,
211  const std::string & action,
212  const std::string & task) const;
213 
214 protected:
216  std::map<std::string, bool> _registered_tasks;
217 
219  std::multimap<std::string, std::string> _moose_systems_to_tasks;
220 
224  std::multimap<std::string, std::string> _deprecated_list_moose_systems_to_tasks;
225 
228 
230  std::multimap<std::string, ActionInfo> _syntax_to_actions;
231 
234  std::multimap<std::string, std::pair<std::string, std::string>> _actions_to_syntax;
235 
237  std::multimap<std::string, std::string> _associated_types;
238 
241 
243  std::map<std::string, std::string> _deprecated_syntax;
244 
246 };
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:362
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:322
const std::multimap< std::string, ActionInfo > & getAssociatedActions() const
Return all Syntax to Action associations.
Definition: Syntax.C:368
bool _actions_to_syntax_valid
Boolean indicating whether the _actions_to_syntax map is built and valid and synced.
Definition: Syntax.h:240
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:245
DependencyResolver< std::string > _tasks
The dependency resolver.
Definition: Syntax.h:227
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:234
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:374
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:224
std::string _action
Definition: Syntax.h:26
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:205
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:231
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:199
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:216
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:245
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:219
void registerSyntaxType(const std::string &syntax, const std::string &type)
Register a type with a block.
Definition: Syntax.C:356
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:243
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:328
std::multimap< std::string, ActionInfo > _syntax_to_actions
The syntax object to ActionInfo (Action+task) associations.
Definition: Syntax.h:230
std::string deprecatedActionSyntaxMessage(const std::string syntax)
Returns the deprecation message for a given syntax that has been deprecated by deprecateActionSyntax...
Definition: Syntax.C:188
void deprecateActionSyntax(const std::string &syntax)
This method deprecates previously registered syntax.
Definition: Syntax.C:175
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:237