aboutsummaryrefslogtreecommitdiffstats
path: root/yage/entity/engine.h
blob: 6719eeaffb9261e287e0edec6d73bfac42a306f8 (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
/** ---------------------------------------------------------------------------
 * -*- c++ -*-
 * @file: engine.h
 *
 * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
 * MIT License, see LICENSE file for more details.
 * ----------------------------------------------------------------------------
 */

#pragma once

#include "system.h"

#include "../core/window.h"
#include "../util/noncopyable.h"

#include <memory>
#include <vector>

namespace yage
{

class Space;

/**
 * Main engine class that contains a systems, the main loop and the update
 * function that updates all the systems.
 */
class Engine : public NonCopyable
{
public:
    ~Engine();

    /// Initialize window and other aspects of the engine.
    Engine &init();

    /// Main game loop of the engine.
    Engine &mainLoop();

    /// Updates the systems.
    void update();

    /// Add spaces to the engine
    Engine &addSpace(std::unique_ptr<Space> space);

    /// Returns the instance of the engine, as there is only one instance of the
    /// engine.
    static Engine &instance();

private:
    /// Window
    Window window_;

    /// A vector of all the spaces
    std::vector<std::unique_ptr<Space>> spaces_;
};

} // namespace yage