www.mooseframework.org
Syntax.h
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #ifndef SYNTAX_H
16 #define SYNTAX_H
17 
18 #include <string>
19 #include <map>
20 #include "DependencyResolver.h"
21 #include "FileLineInfo.h"
22 
26 class Syntax
27 {
28 public:
29  struct ActionInfo
30  {
31  std::string _action;
32  std::string _task;
33  };
34 
35 public:
36  Syntax();
37 
38  void registerTaskName(std::string task, bool is_required);
39  void registerTaskName(std::string task, std::string moose_object_type, bool is_required);
40  void appendTaskName(std::string task, std::string moose_object_type);
41 
42  void addDependency(std::string task, std::string pre_req);
43  void addDependencySets(const std::string & action_sets);
44 
45  const std::vector<std::string> & getSortedTask();
46  const std::vector<std::vector<std::string>> & getSortedTaskSet();
47 
48  bool hasTask(const std::string & task);
49 
50  bool isActionRequired(const std::string & task);
51 
52  // Registration function for associating Moose Actions with syntax
53  void registerActionSyntax(const std::string & action,
54  const std::string & syntax,
55  const std::string & task = "",
56  const std::string & file = "",
57  int line = -1);
58 
64  void replaceActionSyntax(const std::string & action,
65  const std::string & syntax,
66  const std::string & task,
67  const std::string & file = "",
68  int line = -1);
69 
75  void registerSyntaxType(const std::string & syntax, const std::string & type);
76 
80  const std::multimap<std::string, std::string> & getAssociatedTypes() const
81  {
82  return _associated_types;
83  }
84 
90  void deprecateActionSyntax(const std::string & syntax);
91 
93  bool isDeprecatedSyntax(const std::string & syntax) const;
94 
95  // Retrieve the Syntax associated with the passed Action and task
96  std::string getSyntaxByAction(const std::string & action, const std::string & task);
97 
102  std::string isAssociated(const std::string & real_id, bool * is_parent);
103 
104  std::pair<std::multimap<std::string, ActionInfo>::iterator,
105  std::multimap<std::string, ActionInfo>::iterator>
106  getActions(const std::string & name);
107 
108  const std::multimap<std::string, ActionInfo> & getAssociatedActions() const
109  {
110  return _associated_actions;
111  }
112 
113  bool verifyMooseObjectTask(const std::string & base, const std::string & task) const;
114 
122  FileLineInfo getLineInfo(const std::string & syntax,
123  const std::string & action,
124  const std::string & task) const;
125 
126 protected:
128  std::map<std::string, bool> _registered_tasks;
129 
131  std::multimap<std::string, std::string> _moose_systems_to_tasks;
132 
135 
137  std::multimap<std::string, ActionInfo> _associated_actions;
138 
140  std::multimap<std::string, std::string> _associated_types;
141 
142  std::set<std::string> _deprecated_syntax;
144 };
145 
146 #endif // MOOSESYNTAX_H
const std::multimap< std::string, ActionInfo > & getAssociatedActions() const
Definition: Syntax.h:108
std::set< std::string > _deprecated_syntax
Definition: Syntax.h:142
FileLineInfoMap _syntax_to_line
Definition: Syntax.h:143
DependencyResolver< std::string > _tasks
The dependency resolver.
Definition: Syntax.h:134
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:252
void addDependency(std::string task, std::string pre_req)
Definition: Syntax.C:51
void registerActionSyntax(const std::string &action, const std::string &syntax, const std::string &task="", const std::string &file="", int line=-1)
Definition: Syntax.C:105
const std::vector< std::string > & getSortedTask()
Definition: Syntax.C:81
std::string _action
Definition: Syntax.h:31
void registerTaskName(std::string task, bool is_required)
Definition: Syntax.C:21
bool verifyMooseObjectTask(const std::string &base, const std::string &task) const
Definition: Syntax.C:231
std::string isAssociated(const std::string &real_id, bool *is_parent)
Method for determining whether a piece of syntax is associated with an Action TODO: I need a better n...
Definition: Syntax.C:159
std::map< std::string, bool > _registered_tasks
The list of registered tasks and a flag indicating whether or not they are required.
Definition: Syntax.h:128
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:137
const std::vector< std::vector< std::string > > & getSortedTaskSet()
Definition: Syntax.C:87
std::pair< std::multimap< std::string, ActionInfo >::iterator, std::multimap< std::string, ActionInfo >::iterator > getActions(const std::string &name)
Definition: Syntax.C:225
bool isActionRequired(const std::string &task)
Definition: Syntax.C:99
std::string getSyntaxByAction(const std::string &action, const std::string &task)
Definition: Syntax.C:143
std::multimap< std::string, ActionInfo > _associated_actions
Actions/Syntax association.
Definition: Syntax.h:137
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:120
Holds file and line information.
Definition: FileLineInfo.h:24
void addDependencySets(const std::string &action_sets)
Definition: Syntax.C:60
std::string _task
Definition: Syntax.h:32
Syntax()
Definition: Syntax.C:18
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:131
void registerSyntaxType(const std::string &syntax, const std::string &type)
Registration a type with a block.
Definition: Syntax.C:246
const std::multimap< std::string, std::string > & getAssociatedTypes() const
Get a multimap of registered associations of syntax with type.
Definition: Syntax.h:80
Holding syntax for parsing input files.
Definition: Syntax.h:26
void deprecateActionSyntax(const std::string &syntax)
This method deprecates previously registered syntax.
Definition: Syntax.C:131
bool hasTask(const std::string &task)
Definition: Syntax.C:93
A mapping between a series of keys to a FileLineInfo.
Definition: FileLineInfo.h:46
std::multimap< std::string, std::string > _associated_types
Syntax/Type association.
Definition: Syntax.h:140
void appendTaskName(std::string task, std::string moose_object_type)
Definition: Syntax.C:42