FERS 1.0.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
xml_parser.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-only
2//
3// Copyright (c) 2006-2008 Marc Brooker and Michael Inggs
4// Copyright (c) 2008-present FERS Contributors (see AUTHORS.md).
5//
6// See the GNU GPLv2 LICENSE file in the FERS project root for more information.
7
8/**
9 * @file xml_parser.h
10 * @brief High-level facade for parsing XML configuration files into the FERS simulation environment.
11 *
12 * This header provides the main entry points for loading FERS scenario definitions
13 * from XML files or strings. It handles validation, file inclusion, asset loading,
14 * and pushing the parsed configuration into the global simulation state.
15 */
16
17#pragma once
18
19#include <random>
20#include <string>
21
22namespace core
23{
24 class World;
25}
26
27namespace serial
28{
29 /**
30 * @brief Parses a simulation configuration from an XML file.
31 *
32 * This function acts as the primary facade for the simulator's XML loading pipeline.
33 * It performs the following steps:
34 * 1. Resets the target `World` and global parameters (`params::params`).
35 * 2. Loads the main XML file.
36 * 3. Recursively finds and merges any `<include>` files into the main document.
37 * 4. Optionally validates the combined document against the built-in DTD and XSD schemas.
38 * 5. Uses the internal parser utilities to instantiate simulation objects.
39 * 6. Updates the global `params::params` with the parsed context parameters.
40 *
41 * @param filename The filesystem path to the main XML simulation script.
42 * @param world A pointer to the `World` object to be populated with parsed components.
43 * @param validate A boolean indicating whether to perform strict XML schema validation.
44 * @param masterSeeder A reference to the master random number generator used for assigning independent seeds to
45 * components.
46 *
47 * @throws XmlException if the XML is malformed, fails schema validation, or contains invalid scenario logic.
48 * @throws std::runtime_error for file I/O errors or other critical setup issues.
49 */
50 void parseSimulation(const std::string& filename, core::World* world, bool validate, std::mt19937& masterSeeder);
51
52 /**
53 * @brief Parses a simulation configuration directly from an XML string in memory.
54 *
55 * Similar to `parseSimulation`, but operates on a raw string instead of a file.
56 * Because it does not load from the filesystem, `<include>` tags are ignored,
57 * and any relative paths for file-backed assets (like waveforms or antennas)
58 * will be resolved against the current working directory (`.`).
59 *
60 * @param xmlContent The raw XML string containing the scenario definition.
61 * @param world A pointer to the `World` object to be populated with parsed components.
62 * @param validate A boolean indicating whether to perform strict XML schema validation.
63 * @param masterSeeder A reference to the master random number generator used for assigning independent seeds to
64 * components.
65 *
66 * @throws XmlException if the XML string is malformed, fails schema validation, or contains invalid scenario logic.
67 */
68 void parseSimulationFromString(const std::string& xmlContent, core::World* world, bool validate,
69 std::mt19937& masterSeeder);
70}
The World class manages the simulator environment.
Definition world.h:39
void parseSimulation(const std::string &filename, core::World *world, const bool validate, std::mt19937 &masterSeeder)
Parses a simulation configuration from an XML file.
void parseSimulationFromString(const std::string &xmlContent, core::World *world, const bool validate, std::mt19937 &masterSeeder)
Parses a simulation configuration directly from an XML string in memory.