PandA-2024.02
xml_script_command.hpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2004-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
45 #ifndef _XML_SCRIPT_COMMAND_HPP_
46 #define _XML_SCRIPT_COMMAND_HPP_
47 
48 #include <vector>
49 
50 #include "refcount.hpp"
51 
52 #include "polixml.hpp"
53 #include "xml_helper.hpp"
54 
63 
64 // Tags of XML nodes
65 #define TAG_VARIABLE "set"
66 #define TAG_ENTRY "entry"
67 #define TAG_PARAMETER "param"
68 #define TAG_COMMAND "cmd"
69 #define TAG_SHELL "sh"
70 #define TAG_ITE_BLOCK "if"
71 #define TAG_FOREACH "foreach"
72 
75  NODE_UNKNOWN = 0,
76  NODE_ENTRY = 1,
77  NODE_VARIABLE = 2,
78  NODE_PARAMETER = 3,
79  NODE_COMMAND = 4,
80  NODE_SHELL = 5,
81  NODE_ITE_BLOCK = 6,
82  NODE_FOREACH = 7
83 };
84 
90 {
91  public:
93 
95  virtual std::string get_xml_name() const = 0;
97  virtual xml_nodeRef create_xml_node() const = 0;
98 
100  virtual void clean() = 0;
101 
106  virtual bool checkCondition(const DesignParametersRef& dp) const;
107 
112  static xml_script_node_enum_t find_type(const xml_element* element);
117  static xml_script_node_t* create(const xml_element* element);
118 
127  static bool evaluate_condition(const std::string* condition);
138  static bool evaluate_condition(const std::string* condition, const DesignParametersRef& dp);
139 
140  explicit xml_script_node_t(xml_script_node_enum_t _type) : nodeType(_type)
141  {
142  }
143  virtual ~xml_script_node_t();
144 };
146 
151 {
152  public:
153  std::string value;
154  std::string* condition;
155 
156  xml_set_entry_t(std::string _value, const std::string* _condition);
157  explicit xml_set_entry_t(const xml_element* element);
158 
159  ~xml_set_entry_t() override;
160 
161  std::string get_xml_name() const override;
162  xml_nodeRef create_xml_node() const override;
163 
164  void clean() override;
165 
166  bool checkCondition(const DesignParametersRef& dp) const override;
167 };
169 
174 {
175  public:
176  std::string name;
177  std::string* singleValue;
178  std::vector<xml_set_entry_tRef> multiValues;
179  std::string* condition;
180 
181  xml_set_variable_t(std::string _name, const std::string* _singleValue, const std::string* _condition);
182  explicit xml_set_variable_t(const xml_element* element);
183 
184  ~xml_set_variable_t() override;
185 
186  std::string get_xml_name() const override;
187  xml_nodeRef create_xml_node() const override;
188 
189  void clean() override;
190 
191  bool checkCondition(const DesignParametersRef& dp) const override;
192 };
194 
200 {
201  public:
202  std::string* name;
203  std::string* singleValue;
204  std::vector<xml_set_entry_tRef> multiValues;
205  std::string* condition;
206  std::string separator;
208 
209  xml_parameter_t(const std::string* _name, const std::string* _singleValue, const std::string* _condition,
210  const std::string& _separator, bool _curlyBrackets);
211  explicit xml_parameter_t(const xml_element* element);
212 
213  ~xml_parameter_t() override;
214 
215  std::string get_xml_name() const override;
216  xml_nodeRef create_xml_node() const override;
217 
218  void clean() override;
219 
220  bool checkCondition(const DesignParametersRef& dp) const override;
221 };
223 
228 {
229  public:
230  std::string* name;
231  std::string* value;
232  std::vector<xml_parameter_tRef> parameters;
233  std::string* condition;
234  std::string* output;
235 
236  xml_command_t(const std::string* _name, const std::string* _value, const std::string* _condition,
237  const std::string* _output);
238  explicit xml_command_t(const xml_element* element);
239 
240  ~xml_command_t() override;
241 
242  std::string get_xml_name() const override;
243  xml_nodeRef create_xml_node() const override;
244 
245  void clean() override;
246 
247  bool checkCondition(const DesignParametersRef& dp) const override;
248 };
250 
255 {
256  public:
257  std::string* name;
258  std::string* value;
259  std::vector<xml_parameter_tRef> parameters;
260  std::string* condition;
261  std::string* output;
262 
263  xml_shell_t(const std::string* _name, const std::string* _value, const std::string* _condition,
264  const std::string* _output);
265  explicit xml_shell_t(const xml_element* element);
266 
267  ~xml_shell_t() override;
268 
269  std::string get_xml_name() const override;
270  xml_nodeRef create_xml_node() const override;
271 
272  void clean() override;
273 
274  bool checkCondition(const DesignParametersRef& dp) const override;
275 };
277 
282 {
283  public:
284  std::string condition;
285  std::vector<xml_script_node_tRef> thenNodes;
286  std::vector<xml_script_node_tRef> elseNodes;
287 
288  explicit xml_ite_block_t(const std::string* _condition);
289  explicit xml_ite_block_t(const xml_element* element);
290 
291  std::string get_xml_name() const override;
292  xml_nodeRef create_xml_node() const override;
293 
294  ~xml_ite_block_t() override;
295 
296  void clean() override;
297 
298  bool checkCondition(const DesignParametersRef& dp) const override;
299 };
301 
306 {
307  public:
308  std::string variable;
309  std::vector<xml_script_node_tRef> Nodes;
310 
311  explicit xml_foreach_t(std::string _variable);
312  explicit xml_foreach_t(const xml_element* element);
313 
314  std::string get_xml_name() const override;
315  xml_nodeRef create_xml_node() const override;
316 
317  ~xml_foreach_t() override;
318 
319  void clean() override;
320 };
322 
323 #endif
std::string * condition
virtual ~xml_script_node_t()
Command line parameter.
xml_script_node_t(xml_script_node_enum_t _type)
std::string * condition
std::string * value
xml_script_node_enum_t nodeType
std::vector< xml_parameter_tRef > parameters
virtual std::string get_xml_name() const =0
Gets the XML element name of this node type.
std::vector< xml_script_node_tRef > Nodes
std::string * name
std::vector< xml_script_node_tRef > elseNodes
static bool evaluate_condition(const std::string *condition)
Evaluates a string condition.
If/Then/Else block, evaluated at compile-time.
std::string * name
std::string * value
std::string * output
std::string * condition
REF_FORWARD_DECL(xml_script_node_t)
static xml_script_node_t * create(const xml_element *element)
Creates a script node by parsing the XML element.
std::vector< xml_parameter_tRef > parameters
Template definition of refcount.
virtual void clean()=0
Cleans object attributes.
virtual xml_nodeRef create_xml_node() const =0
Creates an XML node for polixml data structures.
This is the abstract class which describes a generic synthesis script node, and some static helper me...
std::string * singleValue
std::string * condition
std::string value
std::vector< xml_set_entry_tRef > multiValues
std::vector< xml_set_entry_tRef > multiValues
Variable assignment, either single value or multiple entries set.
Command line of the synthesis tool.
Some macro used to interface with the XML library.
Command line of the native shell.
virtual bool checkCondition(const DesignParametersRef &dp) const
If the node has a compile-time condition, this method evaluates it.
Foreach block, where the set of script nodes is applied to each parameter.
std::string * output
std::vector< xml_script_node_tRef > thenNodes
static xml_script_node_enum_t find_type(const xml_element *element)
Finds the type of an XML element.
String entry of a multiple values variable (set).
enum xml_script_node_enum_t { NODE_UNKNOWN=0, NODE_ENTRY=1, NODE_VARIABLE=2, NODE_PARAMETER=3, NODE_COMMAND=4, NODE_SHELL=5, NODE_ITE_BLOCK=6, NODE_FOREACH=7 } xml_script_node_enum_t
Node types.

Generated on Mon Feb 12 2024 13:02:56 for PandA-2024.02 by doxygen 1.8.13