summaryrefslogtreecommitdiff
path: root/Simulator/include/modeling/Datacenter.h
blob: a9558f0aba31defa0589de6c633867e14c60ac29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once
#include "modeling/Room.h"
#include "simulation/schedulers/Scheduler.h"
#include "modeling/TypeIndex.h"

#include <vector>

namespace Modeling
{
	/*
		The Datacenter class models a datacenter with rooms/entities.
	*/
	template<typename ...RoomTypes>
	class Datacenter
	{
	public:
		/*
			Returns a reference to the vector of rooms in this datacenter.
		*/
		template<typename RoomType>
		std::vector<RoomType>& getRoomsOfType()
		{
			return std::get<indexOfType<RoomType, RoomTypes...>::value>(rooms);
		}

		/*
			Adds a room to this datacenter.
		*/
		template<typename RoomType>
		void addRoomOfType(RoomType& room)
		{
			std::get<indexOfType<RoomType, RoomTypes...>::value>(rooms).push_back(std::move(room));
		}

	
	private:
		// A vector of rooms that are part of this datacenter.
		std::tuple<std::vector<RoomTypes>...> rooms;
	};
}