blob: 3c11b073eb40b9141c073b68d1001847ced9f416 (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
#pragma once
#include "modeling/Datacenter.h"
#include "modeling/Room.h"
#include "simulation/history/SimulationHistory.h"
#include <vector>
#include <iterator>
namespace Simulation
{
/**
* \brief Holds a datacenter and the tick on which the parent experiment should switch to this section.
* \tparam DatacenterType The type of datacenter to be used.
*/
template<typename DatacenterType>
class Section
{
public:
/**
* \brief Initializes the datacenter in the simulation. Sets paused to false and finished to false.
* \param dc The topology of this section.
* \param startTick The tick on which the experiment should start using the topology of this section.
*/
Section(DatacenterType& dc, uint32_t startTick) : datacenter(dc), startTick(startTick)
{}
/**
* \return A reference to the datacenter of this section.
*/
DatacenterType& getDatacenter()
{
return datacenter;
}
/**
* \return All machines in the datacenter of section.
*/
std::vector<std::reference_wrapper<Modeling::Machine>> getMachines()
{
using namespace std;
vector<reference_wrapper<Modeling::Machine>> machineAccumulator;
// For each serverroom, we get the racks in the room
vector<Modeling::ServerRoom>& rooms = datacenter.template getRoomsOfType<Modeling::ServerRoom>();
for(auto& room : rooms)
// For each rack get the machines inside that rack
for(auto& rack : room.getEntitiesOfType<Modeling::Rack>())
// Add each machine to the accumulator
for(auto& machine : rack.getMachines())
machineAccumulator.push_back(ref(machine.second));
return machineAccumulator;
}
/**
* \return The tick on which the experiment should start using the topology of this section.
*/
uint32_t getStartTick() const
{
return startTick;
}
private:
/**
* \brief The datacenter that is used for experiments.
*/
DatacenterType datacenter;
/**
* \brief The tick when the next sections starts. This is -1 if this is the last section.
*/
uint32_t startTick;
};
}
|