FERS 1.0.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
world.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 world.h
10 * @brief Header file for the World class in the simulator.
11 */
12
13#pragma once
14
15#include <memory>
16#include <queue>
17#include <string>
18#include <unordered_map>
19#include <vector>
20
22#include "core/sim_events.h"
24#include "radar/platform.h"
25#include "radar/receiver.h"
26#include "radar/target.h"
27#include "radar/transmitter.h"
28#include "signal/radar_signal.h"
30
31namespace core
32{
33 /**
34 * @class World
35 * @brief The World class manages the simulator environment.
36 */
37 class World
38 {
39 public:
40 World() = default;
41
42 ~World() noexcept = default;
43
44 World(const World&) = delete;
45
46 World& operator=(const World&) = delete;
47
48 World(World&&) = delete;
49
50 World& operator=(World&&) = delete;
51
52 /**
53 * @brief Adds a radar platform to the simulation world.
54 *
55 * @param plat A unique pointer to a Platform object.
56 */
57 void add(std::unique_ptr<radar::Platform> plat) noexcept;
58
59 /**
60 * @brief Adds a radar transmitter to the simulation world.
61 *
62 * @param trans A unique pointer to a Transmitter object.
63 */
64 void add(std::unique_ptr<radar::Transmitter> trans) noexcept;
65
66 /**
67 * @brief Adds a radar receiver to the simulation world.
68 *
69 * @param recv A unique pointer to a Receiver object.
70 */
71 void add(std::unique_ptr<radar::Receiver> recv) noexcept;
72
73 /**
74 * @brief Adds a radar target to the simulation world.
75 *
76 * @param target A unique pointer to a Target object.
77 */
78 void add(std::unique_ptr<radar::Target> target) noexcept;
79
80 /**
81 * @brief Adds a radar signal (waveform) to the simulation world.
82 *
83 * @param waveform A unique pointer to a RadarSignal object.
84 * @throws std::runtime_error if a waveform with the same name already exists.
85 */
86 void add(std::unique_ptr<fers_signal::RadarSignal> waveform);
87
88 /**
89 * @brief Adds an antenna to the simulation world.
90 *
91 * @param antenna A unique pointer to an Antenna object.
92 * @throws std::runtime_error if an antenna with the same name already exists.
93 */
94 void add(std::unique_ptr<antenna::Antenna> antenna);
95
96 /**
97 * @brief Adds a timing source to the simulation world.
98 *
99 * @param timing A unique pointer to a PrototypeTiming object.
100 * @throws std::runtime_error if a timing source with the same name already exists.
101 */
102 void add(std::unique_ptr<timing::PrototypeTiming> timing);
103
104 /**
105 * @brief Finds a radar signal by name.
106 *
107 * @param name The name of the radar signal to find.
108 * @return A pointer to the RadarSignal if found, or nullptr if not found.
109 */
110 [[nodiscard]] fers_signal::RadarSignal* findWaveform(const std::string& name);
111
112 /**
113 * @brief Finds an antenna by name.
114 *
115 * @param name The name of the antenna to find.
116 * @return A pointer to the Antenna if found, or nullptr if not found.
117 */
118 [[nodiscard]] antenna::Antenna* findAntenna(const std::string& name);
119
120 /**
121 * @brief Finds a timing source by name.
122 *
123 * @param name The name of the timing source to find.
124 * @return A pointer to the PrototypeTiming if found, or nullptr if not found.
125 */
126 [[nodiscard]] timing::PrototypeTiming* findTiming(const std::string& name);
127
128 /**
129 * @brief Retrieves the list of platforms.
130 *
131 * @return A const reference to a vector of unique pointers to Platform objects.
132 */
133 [[nodiscard]] const std::vector<std::unique_ptr<radar::Platform>>& getPlatforms() const noexcept
134 {
135 return _platforms;
136 }
137
138 /**
139 * @brief Retrieves the list of radar targets.
140 *
141 * @return A const reference to a vector of unique pointers to Target objects.
142 */
143 [[nodiscard]] const std::vector<std::unique_ptr<radar::Target>>& getTargets() const noexcept
144 {
145 return _targets;
146 }
147
148 /**
149 * @brief Retrieves the list of radar receivers.
150 *
151 * @return A const reference to a vector of unique pointers to Receiver objects.
152 */
153 [[nodiscard]] const std::vector<std::unique_ptr<radar::Receiver>>& getReceivers() const noexcept
154 {
155 return _receivers;
156 }
157
158 /**
159 * @brief Retrieves the list of radar transmitters.
160 *
161 * @return A const reference to a vector of unique pointers to Transmitter objects.
162 */
163 [[nodiscard]] const std::vector<std::unique_ptr<radar::Transmitter>>& getTransmitters() const noexcept
164 {
165 return _transmitters;
166 }
167
168 /**
169 * @brief Retrieves the map of radar signals (waveforms).
170 * @return A const reference to the map of signal names to RadarSignal objects.
171 */
172 [[nodiscard]] const std::unordered_map<std::string, std::unique_ptr<fers_signal::RadarSignal>>&
173 getWaveforms() const noexcept
174 {
175 return _waveforms;
176 }
177
178 /**
179 * @brief Retrieves the map of antennas.
180 * @return A const reference to the map of antenna names to Antenna objects.
181 */
182 [[nodiscard]] const std::unordered_map<std::string, std::unique_ptr<antenna::Antenna>>&
183 getAntennas() const noexcept
184 {
185 return _antennas;
186 }
187
188 /**
189 * @brief Retrieves the map of timing prototypes.
190 * @return A const reference to the map of timing names to PrototypeTiming objects.
191 */
192 [[nodiscard]] const std::unordered_map<std::string, std::unique_ptr<timing::PrototypeTiming>>&
193 getTimings() const noexcept
194 {
195 return _timings;
196 }
197
198 /**
199 * @brief Clears all objects and assets from the simulation world.
200 */
201 void clear() noexcept;
202
203 /**
204 * @brief Populates the event queue with the initial events for the simulation.
205 * This method should be called after all simulation objects have been parsed and added to the world.
206 */
208
209 /**
210 * @brief Dumps the current state of the event queue to a string for debugging.
211 * @return A formatted string representing the contents of the event queue.
212 */
213 [[nodiscard]] std::string dumpEventQueue() const;
214
215 /**
216 * @brief Gets a mutable reference to the global event queue.
217 * @return A reference to the priority queue of events.
218 */
219 [[nodiscard]] std::priority_queue<Event, std::vector<Event>, EventComparator>& getEventQueue() noexcept
220 {
221 return _event_queue;
222 }
223
224 /**
225 * @brief Gets a mutable reference to the global simulation state.
226 * @return A reference to the SimulationState object.
227 */
228 [[nodiscard]] SimulationState& getSimulationState() noexcept { return _simulation_state; }
229
230 private:
231 std::vector<std::unique_ptr<radar::Platform>> _platforms;
232
233 std::vector<std::unique_ptr<radar::Transmitter>> _transmitters;
234
235 std::vector<std::unique_ptr<radar::Receiver>> _receivers;
236
237 std::vector<std::unique_ptr<radar::Target>> _targets;
238
239 std::unordered_map<std::string, std::unique_ptr<fers_signal::RadarSignal>> _waveforms;
240
241 std::unordered_map<std::string, std::unique_ptr<antenna::Antenna>> _antennas;
242
243 std::unordered_map<std::string, std::unique_ptr<timing::PrototypeTiming>> _timings;
244
245 std::priority_queue<Event, std::vector<Event>, EventComparator> _event_queue;
246
247 SimulationState _simulation_state;
248 };
249}
Header file defining various types of antennas and their gain patterns.
The World class manages the simulator environment.
Definition world.h:38
void scheduleInitialEvents()
Populates the event queue with the initial events for the simulation.
Definition world.cpp:98
timing::PrototypeTiming * findTiming(const std::string &name)
Finds a timing source by name.
Definition world.cpp:80
World()=default
void add(std::unique_ptr< radar::Platform > plat) noexcept
Adds a radar platform to the simulation world.
Definition world.cpp:35
antenna::Antenna * findAntenna(const std::string &name)
Finds an antenna by name.
Definition world.cpp:75
~World() noexcept=default
const std::vector< std::unique_ptr< radar::Target > > & getTargets() const noexcept
Retrieves the list of radar targets.
Definition world.h:143
const std::unordered_map< std::string, std::unique_ptr< fers_signal::RadarSignal > > & getWaveforms() const noexcept
Retrieves the map of radar signals (waveforms).
Definition world.h:173
fers_signal::RadarSignal * findWaveform(const std::string &name)
Finds a radar signal by name.
Definition world.cpp:70
void clear() noexcept
Clears all objects and assets from the simulation world.
Definition world.cpp:85
SimulationState & getSimulationState() noexcept
Gets a mutable reference to the global simulation state.
Definition world.h:228
const std::vector< std::unique_ptr< radar::Platform > > & getPlatforms() const noexcept
Retrieves the list of platforms.
Definition world.h:133
std::string dumpEventQueue() const
Dumps the current state of the event queue to a string for debugging.
Definition world.cpp:180
std::priority_queue< Event, std::vector< Event >, EventComparator > & getEventQueue() noexcept
Gets a mutable reference to the global event queue.
Definition world.h:219
const std::vector< std::unique_ptr< radar::Transmitter > > & getTransmitters() const noexcept
Retrieves the list of radar transmitters.
Definition world.h:163
const std::unordered_map< std::string, std::unique_ptr< timing::PrototypeTiming > > & getTimings() const noexcept
Retrieves the map of timing prototypes.
Definition world.h:193
const std::vector< std::unique_ptr< radar::Receiver > > & getReceivers() const noexcept
Retrieves the list of radar receivers.
Definition world.h:153
const std::unordered_map< std::string, std::unique_ptr< antenna::Antenna > > & getAntennas() const noexcept
Retrieves the map of antennas.
Definition world.h:183
Defines the Platform class used in radar simulation.
Header file for the PrototypeTiming class.
Classes for handling radar waveforms and signals.
Radar Receiver class for managing signal reception and response handling.
Defines the core structures for the event-driven simulation engine.
Defines the global state for the event-driven simulation engine.
A custom comparator for the event priority queue.
Definition sim_events.h:57
Represents a single event in the simulation's time-ordered queue.
Definition sim_events.h:43
Holds the dynamic global state of the simulation.
Defines classes for radar targets and their Radar Cross-Section (RCS) models.
Header file for the Transmitter class in the radar namespace.