www.mooseframework.org
SyntaxTree.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 
13 
14 #include <map>
15 #include <memory>
16 #include <set>
17 #include <string>
18 
19 // Forward declarations
20 class InputParameters;
21 class SyntaxTree;
22 
24 {
25 public:
26  SyntaxTree(bool use_long_names = false);
27  virtual ~SyntaxTree();
28 
29  void insertNode(std::string syntax,
30  const std::string & action,
31  bool is_action_params = true,
32  InputParameters * params = NULL);
33 
34  std::string print(const std::string & search_string);
35 
36  void seenIt(const std::string & prefix, const std::string & item);
37  bool haveSeenIt(const std::string & prefix, const std::string & item) const;
38 
39 protected:
43  class TreeNode
44  {
45  public:
46  TreeNode(const std::string & name,
47  SyntaxTree & syntax_tree,
48  const std::string * action = NULL,
49  InputParameters * params = NULL,
50  TreeNode * parent = NULL);
51  ~TreeNode();
52 
53  void insertNode(std::string & syntax,
54  const std::string & action,
55  bool is_action_params = true,
56  InputParameters * params = NULL);
57  std::string print(short depth, const std::string & search_string, bool & found);
58 
59  std::string getLongName(const std::string & delim = "/") const;
60 
61  protected:
62  void insertParams(const std::string & action,
63  bool is_action_params,
64  InputParameters * params = NULL);
65 
66  std::map<std::string, std::unique_ptr<TreeNode>> _children;
67  std::multimap<std::string, std::unique_ptr<InputParameters>> _action_params;
68  std::multimap<std::string, std::unique_ptr<InputParameters>> _moose_object_params;
69  std::string _name;
72  };
73 
74  bool isLongNames() const;
75 
76  std::unique_ptr<TreeNode> _root;
78 
79 private:
80  std::set<std::string> _params_printed;
81 };
std::string name(const ElemQuality q)
TreeNode * _parent
Definition: SyntaxTree.h:70
This interface is for classes that want to be called to format InputParameters.
void insertNode(std::string &syntax, const std::string &action, bool is_action_params=true, InputParameters *params=NULL)
Definition: SyntaxTree.C:82
std::string getLongName(const std::string &delim="/") const
Definition: SyntaxTree.C:218
void insertParams(const std::string &action, bool is_action_params, InputParameters *params=NULL)
Definition: SyntaxTree.C:115
std::set< std::string > _params_printed
Definition: SyntaxTree.h:80
SyntaxTree(bool use_long_names=false)
Definition: SyntaxTree.C:19
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
TreeNode(const std::string &name, SyntaxTree &syntax_tree, const std::string *action=NULL, InputParameters *params=NULL, TreeNode *parent=NULL)
Definition: SyntaxTree.C:68
std::string _name
Definition: SyntaxTree.h:69
SyntaxTree & _syntax_tree
Definition: SyntaxTree.h:71
virtual ~SyntaxTree()
std::multimap< std::string, std::unique_ptr< InputParameters > > _moose_object_params
Definition: SyntaxTree.h:68
bool _use_long_names
Definition: SyntaxTree.h:77
std::unique_ptr< TreeNode > _root
Definition: SyntaxTree.h:76
void insertNode(std::string syntax, const std::string &action, bool is_action_params=true, InputParameters *params=NULL)
Definition: SyntaxTree.C:27
std::string print(const std::string &search_string)
Definition: SyntaxTree.C:39
std::string print(short depth, const std::string &search_string, bool &found)
Definition: SyntaxTree.C:126
std::map< std::string, std::unique_ptr< TreeNode > > _children
Definition: SyntaxTree.h:66
std::multimap< std::string, std::unique_ptr< InputParameters > > _action_params
Definition: SyntaxTree.h:67
bool isLongNames() const
Definition: SyntaxTree.C:227
bool haveSeenIt(const std::string &prefix, const std::string &item) const
Definition: SyntaxTree.C:63
This class represents a single node in our tree.
Definition: SyntaxTree.h:43
void seenIt(const std::string &prefix, const std::string &item)
Definition: SyntaxTree.C:57