-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calendar.h
48 lines (41 loc) · 1.36 KB
/
Calendar.h
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
/************************************************************
* SimLib simulation library for event-based simulations *
* Author: Martin Ubl (A16N0026P) *
************************************************************/
#pragma once
#include "Types.h"
#include <queue>
#include <list>
#include <memory>
/*
* Comparator functor for time-ordered priority queue
*/
struct TimePriorityCmp
{
bool operator()(SimulationObjectPtr const& a, SimulationObjectPtr const& b);
};
/*
* Calendar class used for scheduling simulation events
*/
class Calendar : public std::priority_queue<SimulationObjectPtr, std::vector<SimulationObjectPtr>, TimePriorityCmp>
{
public:
// removes specified simulation object from calendar (using its GUID)
bool remove(const SimulationObjectPtr obj);
// creates new calendar instance
static CalendarPtr Create();
};
/*
* Class representing a list of calendars with joined top and pop methods
*/
class CalendarList : public std::list<CalendarPtr>
{
public:
// get simulation object on top of dominant calendar
SimulationObjectPtr top() const;
// pops element from top
void pop();
// are all calendars empty?
bool all_empty() const;
};