-
Notifications
You must be signed in to change notification settings - Fork 0
/
Simulator.h
41 lines (32 loc) · 923 Bytes
/
Simulator.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
//
// Created by zeronsix on 5/12/19.
//
#ifndef DCFSIMULATOR_SIMULATOR_H
#define DCFSIMULATOR_SIMULATOR_H
#include <cstdint>
#include <functional>
#include <map>
#include <random>
#include <iostream>
//#define DBG
#ifdef DBG
#define LOG_FUNCTION(smth) do { std::cout << Simulator::Now() << " " << __PRETTY_FUNCTION__ << " " << smth " \n"; } while (0)
#else
#define LOG_FUNCTION(smth) do {} while (0)
#endif
using Time = int64_t;
using EventHandler = std::function<void ()>;
class Simulator {
public:
static void Configure(Time simTime, int seed);
static void Schedule(Time time, EventHandler handler);
static Time Now();
static void Run();
static int GenerateUniformRandomVariable(int min, int max);
private:
static Time m_simTime;
static Time m_nowTime;
static std::multimap<Time, EventHandler> m_eventQueue;
static std::mt19937 m_engine;
};
#endif //DCFSIMULATOR_SIMULATOR_H