From 070ce923574dcc57435cb3fb2dfe86b6a38cd249 Mon Sep 17 00:00:00 2001 From: MDBijman Date: Tue, 24 Jan 2017 12:15:26 +0100 Subject: Initial code commit with organized dependencies --- Simulator/include/modeling/Room.h | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Simulator/include/modeling/Room.h (limited to 'Simulator/include/modeling/Room.h') diff --git a/Simulator/include/modeling/Room.h b/Simulator/include/modeling/Room.h new file mode 100644 index 00000000..a57b045e --- /dev/null +++ b/Simulator/include/modeling/Room.h @@ -0,0 +1,52 @@ +#pragma once +#include "modeling/Rack.h" +#include "modeling/TypeIndex.h" + +#include + +namespace Modeling +{ + /* + The Room class models the rooms that can be created in the simulation. It contains a list of all entities in the room. + */ + template + class Room + { + //static_assert(std::is_base_of..., "Each type must be derived from Entity!"); + public: + /* + Initializes the room with the given name. + */ + explicit Room(int id) : id(id) {} + + /* + Adds the entity to the list of entities in this room. + */ + template + void addEntity(EntityType& e) + { + std::get::value>(entities).push_back(e); + } + + /* + Returns all entities of the given type. + */ + template + std::vector& getEntitiesOfType() + { + return std::get::value>(entities); + } + + // The id of this room corresponding to its id in the database. + const int id; + + private: + // A vector for each type of entity + std::tuple...> entities; + }; + + using ServerRoom = Room; + using Hallway = Room<>; + using PowerRoom = Room<>; + +} -- cgit v1.2.3