Syntax validation plugin for XML plans.
More...
#include <xml_parser_plugin.hpp>
|
| void | convert_to_string (tinyxml2::XMLDocument &document_xml, std::string &document_string) |
| | convert XMLDocument to std::string
|
| |
| bool | search (std::vector< std::string > list, std::string value) |
| | search a string in a vector of strings
|
| |
| tinyxml2::XMLElement * | extract_plan (tinyxml2::XMLDocument &document) |
| | Extract the <Plan> element from the XML document.
|
| |
| bool | convert_to_string (tinyxml2::XMLElement *element, std::string ¶meters) |
| | convert XMLElement to std::string
|
| |
| bool | check_syntax (tinyxml2::XMLElement *element, std::vector< std::string > &control_list, std::vector< std::string > &rejected, std::string &error) |
| | check the plan to make sure all control and runner XML elements are valid with minimal required attributes. The function uses recursive approach to go through the xml plan
|
| |
| void | add_completion_runner (tinyxml2::XMLDocument &document, const std::string &plan_id) |
| | add a completion runner to the plan This function adds a new <Control> element with type "sequential" and a <Runner> element for the completion runner to the existing <Plan> element in the XML document.
|
| |
| int | add_parallel_all (fabric::Plan &plan, int connection_id=0, std::string description="") |
| | Adds a system connection for parallel input multiplexing with waiting for all inputs.
|
| |
| int | add_parallel_any (fabric::Plan &plan, int connection_id=0, std::string description="") |
| | Adds a system connection for parallel input multiplexing with waiting for any inputs.
|
| |
| capabilities2_events::EventParameters | convert_xml_to_event_parameters (tinyxml2::XMLElement *element) |
| | Check and update the system runner id for the successor based on the predecessor's id.
|
| |
| int | extract_connections (tinyxml2::XMLElement *element, fabric::Plan &plan, int connection_id=0, fabric::event connection_type=fabric::event::ON_SUCCESS, std::string conn_description="") |
| | parse through the plan and extract the connections
|
| |
| void | initialize_base (const rclcpp::Node::SharedPtr &node, const std::string &plugin_name) |
| | Base initialization method for derived classes.
|
| |
|
| std::vector< std::string > | control_list |
| | List of valid control tags.
|
| |
| tinyxml2::XMLDocument | system_doc |
| | XML Document for system runners.
|
| |
| int | runner_index = 0 |
| | Index for assigning unique IDs to system runners.
|
| |
| tinyxml2::XMLElement * | plan_ = nullptr |
| | Pointer to the plan element in the XML document.
|
| |
| tinyxml2::XMLDocument | default_document |
| | Default XML document for loading from file.
|
| |
| tinyxml2::XMLDocument | current_document_ |
| | XML Document to hold the current plan.
|
| |
| rclcpp::Node::SharedPtr | node_ |
| | Shared pointer to the ROS2 node.
|
| |
| std::string | plugin_name_ |
| | Name of the validation plugin.
|
| |
Syntax validation plugin for XML plans.
This plugin checks the XML plan for basic syntax errors (well-formedness, root tag, etc).
◆ XMLParser()
| fabric::XMLParser::XMLParser |
( |
| ) |
|
|
default |
◆ ~XMLParser()
| virtual fabric::XMLParser::~XMLParser |
( |
| ) |
|
|
virtualdefault |
◆ add_completion_runner()
| void fabric::XMLParser::add_completion_runner |
( |
tinyxml2::XMLDocument & |
document, |
|
|
const std::string & |
plan_id |
|
) |
| |
|
inlineprotected |
add a completion runner to the plan This function adds a new <Control> element with type "sequential" and a <Runner> element for the completion runner to the existing <Plan> element in the XML document.
- Parameters
-
| document | XML document to which the completion runner will be added |
| plan_id | ID of the plan to be associated with the completion runner |
◆ add_parallel_all()
| int fabric::XMLParser::add_parallel_all |
( |
fabric::Plan & |
plan, |
|
|
int |
connection_id = 0, |
|
|
std::string |
description = "" |
|
) |
| |
|
inlineprotected |
Adds a system connection for parallel input multiplexing with waiting for all inputs.
- Parameters
-
| connections | fabric::Plan containing connections |
| connection_id | connection id to be used for the new connection |
| description | description of the connection |
- Returns
- int next connection id
◆ add_parallel_any()
| int fabric::XMLParser::add_parallel_any |
( |
fabric::Plan & |
plan, |
|
|
int |
connection_id = 0, |
|
|
std::string |
description = "" |
|
) |
| |
|
inlineprotected |
Adds a system connection for parallel input multiplexing with waiting for any inputs.
- Parameters
-
| plan | fabric::Plan containing connections |
| connection_id | connection id to be used for the new connection |
| description | description of the connection |
- Returns
- int next connection id
◆ check_compatibility()
| bool fabric::XMLParser::check_compatibility |
( |
const fabric::Plan & |
plan | ) |
|
|
inlineoverridevirtual |
Check the compatibility of the given plan with the given parser.
- Parameters
-
| plan | The plan to check for compatibility. |
- Returns
- true if the plan is compatible, false otherwise.
Implements fabric::ParserBase.
◆ check_syntax()
| bool fabric::XMLParser::check_syntax |
( |
tinyxml2::XMLElement * |
element, |
|
|
std::vector< std::string > & |
control_list, |
|
|
std::vector< std::string > & |
rejected, |
|
|
std::string & |
error |
|
) |
| |
|
inlineprotected |
check the plan to make sure all control and runner XML elements are valid with minimal required attributes. The function uses recursive approach to go through the xml plan
- Parameters
-
| element | XML Element to be evaluated |
| control_list | list of valid control tags |
| rejected | list containing invalid tags |
| error | output string for error messages |
- Returns
true if element valid and supported and false otherwise
◆ convert_to_string() [1/2]
| void fabric::XMLParser::convert_to_string |
( |
tinyxml2::XMLDocument & |
document_xml, |
|
|
std::string & |
document_string |
|
) |
| |
|
inlineprotected |
convert XMLDocument to std::string
- Parameters
-
| document | element to be converted |
- Returns
- std::string converted document
◆ convert_to_string() [2/2]
| bool fabric::XMLParser::convert_to_string |
( |
tinyxml2::XMLElement * |
element, |
|
|
std::string & |
parameters |
|
) |
| |
|
inlineprotected |
convert XMLElement to std::string
- Parameters
-
| element | XMLElement element to be converted |
| paramters | parameter to hold std::string |
- Returns
true if element is not nullptr and conversion successful, false if element is nullptr
◆ convert_xml_to_event_parameters()
| capabilities2_events::EventParameters fabric::XMLParser::convert_xml_to_event_parameters |
( |
tinyxml2::XMLElement * |
element | ) |
|
|
inlineprotected |
Check and update the system runner id for the successor based on the predecessor's id.
This function checks if the predecessor is a system runner and has parameters. If so, it updates the successor's parameters with the predecessor's id.
- Parameters
-
| predecessor | The predecessor node_t containing the source runner |
| successor | The successor node_t to be updated |
convert tinyxml2::XMLElement attributes to EventParameters. Treats the original attributes as string and let the runners that they are related to handle the conversion from string to correct data type
- Parameters
-
| element | tinyxml2::XMLElement element to be converted. |
- Returns
- capabilities2_events::EventParameters converted parameters
◆ extract_connections()
parse through the plan and extract the connections
- Parameters
-
| element | XML Element to be evaluated |
| connections | std::map containing extracted connections |
◆ extract_plan()
| tinyxml2::XMLElement * fabric::XMLParser::extract_plan |
( |
tinyxml2::XMLDocument & |
document | ) |
|
|
inlineprotected |
Extract the <Plan> element from the XML document.
This function checks if the root element of the provided XML document is <Plan>. If so, it returns the first child element of <Plan>. Otherwise, it indicates failure.
- Parameters
-
| document | The XMLDocument to extract the plan from |
- Returns
- tinyxml2::XMLElement* Pointer to the first child of <Plan> if successful, nullptr otherwise
◆ initialize()
| void fabric::XMLParser::initialize |
( |
const rclcpp::Node::SharedPtr & |
node | ) |
|
|
inlineoverridevirtual |
Initialize the XML parser plugin.
- Parameters
-
| node | Shared pointer to the ROS2 node. |
Reimplemented from fabric::ParserBase.
◆ load_file()
| bool fabric::XMLParser::load_file |
( |
const std::string & |
file_path, |
|
|
fabric::Plan & |
plan |
|
) |
| |
|
inlineoverridevirtual |
load a file into an XML document
- Parameters
-
| document | The path to the XML file to be loaded |
- Returns
- true if the file was loaded successfully, false otherwise
Implements fabric::ParserBase.
◆ parse()
Parse the given XML plan.
- Parameters
-
| document | The XMLDocument representing the plan. |
| plan | The parsed plan. |
Implements fabric::ParserBase.
◆ search()
| bool fabric::XMLParser::search |
( |
std::vector< std::string > |
list, |
|
|
std::string |
value |
|
) |
| |
|
inlineprotected |
search a string in a vector of strings
- Parameters
-
| list | vector of strings to be searched |
| value | string to be searched in the vector |
- Returns
true if value is found in list and false otherwise
◆ control_list
| std::vector<std::string> fabric::XMLParser::control_list |
|
protected |
List of valid control tags.
◆ current_document_
| tinyxml2::XMLDocument fabric::XMLParser::current_document_ |
|
protected |
XML Document to hold the current plan.
◆ default_document
| tinyxml2::XMLDocument fabric::XMLParser::default_document |
|
protected |
Default XML document for loading from file.
◆ plan_
| tinyxml2::XMLElement* fabric::XMLParser::plan_ = nullptr |
|
protected |
Pointer to the plan element in the XML document.
◆ runner_index
| int fabric::XMLParser::runner_index = 0 |
|
protected |
Index for assigning unique IDs to system runners.
◆ system_doc
| tinyxml2::XMLDocument fabric::XMLParser::system_doc |
|
protected |
XML Document for system runners.
The documentation for this class was generated from the following file: