hivemind 1.0.0
Loading...
Searching...
No Matches
scenario.h
Go to the documentation of this file.
1#pragma once
2
3#include "core/serializer.h"
6
7#include <algorithm>
8#include <memory>
9#include <string>
10
12{
13
14 ///
15 /// \brief The Scenario class represents a scenario with keyframes and
16 /// routes.
17 ///
18 /// The Scenario class provides functionality for creating a scenario with
19 /// keyframes and routes, as well as saving and loading the scenario to and
20 /// from file.
21 class Scenario : JSON
22 {
23 public:
24 using RouteMap =
25 std::map<int, std::vector<std::vector<Core::CartesianCoordinate>>>;
26 ///
27 /// \brief Constructs a new Scenario object with the given name, origin,
28 /// and size. \param name The name of the scenario. \param origin The
29 /// geographical coordinates of the origin. \param size The size of the
30 /// scenario.
31 Scenario(std::string name, Core::GeographicalCoordinate origin, int size);
32
33 ///
34 /// \brief Compiles the scenario into a map of routes.
35 /// \return A map of routes.
37
38 ///
39 /// \brief Saves the scenario to a file with the given filename.
40 /// \param filename The name of the file to save to.
41 void save(std::string filename);
42
43 ///
44 /// \brief Loads a scenario from a file with the given filename.
45 /// \param filename The name of the file to load from.
46 void load(std::string filename);
47
48 inline std::pair<RouteMap::iterator, RouteMap::iterator>
50 {
51 return std::make_pair<RouteMap::iterator, RouteMap::iterator>(
52 m_Routes.begin(), m_Routes.end());
53 }
54
55 inline std::pair<std::vector<Core::Agent>::iterator,
56 std::vector<Core::Agent>::iterator>
58 {
59 return std::make_pair<std::vector<Core::Agent>::iterator,
60 std::vector<Core::Agent>::iterator>(
61 m_Agents.begin(), m_Agents.end());
62 }
63
64 void AddAgent(Core::Agent newAgent);
65
66 ///
67 /// \brief Sets the origin of the scenario to the given geographical
68 /// coordinates and size. \param GeoCoord The geographical coordinates
69 /// of the origin. \param size The size of the scenario.
70 void SetOrigin(Core::GeographicalCoordinate GeoCoord, int size);
71
72 private:
74 std::vector<Core::Agent> m_Agents;
76 std::unique_ptr<Routemaker::Routemaker> m_Routemaker;
77 std::string m_Name;
79 int m_Size;
80
86 };
87
88} // namespace CompileScenario
The Scenario class represents a scenario with keyframes and routes.
Definition: scenario.h:22
void save(std::string filename)
Saves the scenario to a file with the given filename.
Definition: scenario.cpp:90
std::vector< Core::Agent > m_Agents
Definition: scenario.h:74
std::pair< RouteMap::iterator, RouteMap::iterator > GetRoutes()
Definition: scenario.h:49
KeyframeManagement::KeyframeManager & m_KeyframeManager
Definition: scenario.h:73
std::unique_ptr< Routemaker::Routemaker > m_Routemaker
Definition: scenario.h:76
JSONSTART JSONMEMBER(Core::GeographicalCoordinate, m_Origin)
RouteMap & Compile()
Compiles the scenario into a map of routes.
Definition: scenario.cpp:39
Core::GeographicalCoordinate m_Origin
Definition: scenario.h:78
void AddAgent(Core::Agent newAgent)
Definition: scenario.cpp:84
std::map< int, std::vector< std::vector< Core::CartesianCoordinate > > > RouteMap
Definition: scenario.h:25
void load(std::string filename)
Loads a scenario from a file with the given filename.
Definition: scenario.cpp:96
std::pair< std::vector< Core::Agent >::iterator, std::vector< Core::Agent >::iterator > GetAgents()
Definition: scenario.h:57
JSONSTART JSONINT(m_Size)
void SetOrigin(Core::GeographicalCoordinate GeoCoord, int size)
Sets the origin of the scenario to the given geographical coordinates and size.
Definition: scenario.cpp:27
This is the class that manages keyframes.
#define JSONEND
Definition: serializer.h:590
#define JSONSTART
Definition: serializer.h:529
#define JSONMEMBER(T, m)
Definition: serializer.h:577
#define JSON
Macros To serialize an object you need to have the GetProperty() function in the object.
Definition: serializer.h:525
#define JSONMEMBERVECTOR(T, m)
Definition: serializer.h:581
#define JSONSTRING(m)
Definition: serializer.h:561
A structure that represents a geographic coordinate.
Definition: types.h:29