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 --- .../include/simulation/history/SimulationHistory.h | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 Simulator/include/simulation/history/SimulationHistory.h (limited to 'Simulator/include/simulation/history/SimulationHistory.h') diff --git a/Simulator/include/simulation/history/SimulationHistory.h b/Simulator/include/simulation/history/SimulationHistory.h new file mode 100644 index 00000000..f43968b7 --- /dev/null +++ b/Simulator/include/simulation/history/SimulationHistory.h @@ -0,0 +1,81 @@ +#pragma once +#include "History.h" +#include "WorkloadSnapshot.h" +#include "MachineSnapshot.h" + +#include + +namespace Simulation +{ + using WorkloadHistory = History; + using MachineHistory = History; + using HistoryRef = std::tuple, std::reference_wrapper>; + + class SimulationHistory + { + public: + /* + Adds the workload snapshot at the given tick. + */ + void addSnapshot(uint32_t tick, WorkloadSnapshot snapshots) + { + workloadHistory.addSnapshotAtTick(tick, snapshots); + } + + /* + Adds the machine snapshot at the given tick. + */ + void addSnapshot(uint32_t tick, MachineSnapshot snapshots) + { + machineHistory.addSnapshotAtTick(tick, snapshots); + } + + /* + Returns the equal_range of the workload snapshots at the given tick. + */ + auto getWorkloadSnapshot(uint32_t tick) + { + return workloadHistory.snapshotsAtTick(tick); + } + + /* + Returns the equal_range of the machine snapshots at the given tick. + */ + auto getMachineSnapshot(uint32_t tick) + { + return machineHistory.snapshotsAtTick(tick); + } + + /* + Returns a const tuple ref of the entire cached history of machines and workloads. + */ + const HistoryRef getHistory() + { + return std::make_tuple( + std::ref(workloadHistory), + std::ref(machineHistory) + ); + } + + /* + Clears the cache of history. + */ + void clearHistory() + { + workloadHistory.clear(); + machineHistory.clear(); + } + + /* + Returns the number of snapshots that are in the history cache. + */ + size_t historySize() + { + return workloadHistory.size(); + } + + private: + WorkloadHistory workloadHistory; + MachineHistory machineHistory; + }; +} \ No newline at end of file -- cgit v1.2.3