neoGFX
Cross-platform C++ app/game engine
system.hpp
Go to the documentation of this file.
1 // system.hpp
2 /*
3  neogfx C++ GUI Library
4  Copyright (c) 2018 Leigh Johnston. All Rights Reserved.
5 
6  This program is free software: you can redistribute it and / or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 #pragma once
20 
21 #include <neogfx/neogfx.hpp>
22 #include <neolib/set.hpp>
23 #include <neolib/allocator.hpp>
24 #include <neogfx/game/i_system.hpp>
25 
26 namespace neogfx::game
27 {
28  class i_ecs;
29 
30  class system : public i_system
31  {
32  private:
34  public:
35  system(game::i_ecs& aEcs);
36  template <typename ComponentIdIter>
37  system(game::i_ecs& aEcs, ComponentIdIter aFirstComponent, ComponentIdIter aLastComponent) :
38  iEcs{ aEcs }, iComponents{ aFirstComponent, aLastComponent }, iPaused{ 0u }
39  {
40  }
41  system(const system& aOther);
42  system(system&& aOther);
43  public:
44  game::i_ecs& ecs() const;
45  public:
46  const neolib::i_set<component_id>& components() const override;
48  public:
49  const i_component& component(component_id aComponentId) const override;
50  i_component& component(component_id aComponentId) override;
51  public:
52  bool paused() const override;
53  void pause() override;
54  void resume() override;
55  void terminate() override;
56  protected:
57  void yield();
58  private:
59  game::i_ecs& iEcs;
60  component_list iComponents;
61  std::atomic<uint32_t> iPaused;
62  };
63 }
bool paused() const override
system(game::i_ecs &aEcs, ComponentIdIter aFirstComponent, ComponentIdIter aLastComponent)
Definition: system.hpp:37
const neolib::i_set< component_id > & components() const override
game::i_ecs & ecs() const
void terminate() override
system(game::i_ecs &aEcs)
void resume() override
void pause() override
const i_component & component(component_id aComponentId) const override
boost::fast_pool_allocator< T, boost::default_user_allocator_new_delete, boost::details::pool::null_mutex, NextSize > fast_pool_allocator
Definition: allocator.hpp:570