Simulant  21.12-574
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
stage_manager.h
1 /* * Copyright (c) 2011-2017 Luke Benstead https://simulant-engine.appspot.com
2  *
3  * This file is part of Simulant.
4  *
5  * Simulant is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * Simulant is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with Simulant. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 #include "generic/generic_tree.h"
22 #include "generic/property.h"
23 #include "generic/containers/polylist.h"
24 #include "interfaces.h"
25 #include "interfaces/updateable.h"
26 #include "types.h"
27 #include "managers/window_holder.h"
28 
29 #include "nodes/stage_node_pool.h"
30 
31 namespace smlt {
32 
33 class StageNode;
34 
35 typedef sig::signal<void (StageID)> StageAddedSignal;
36 typedef sig::signal<void (StageID)> StageRemovedSignal;
37 
38 template<typename PoolType, typename IDType, typename T, typename ...Subtypes>
39 class StageNodeManager;
40 
42  public virtual Updateable {
43 
44  friend class Application; // So we can call clean_destroyed_stages regularly
45 
46  DEFINE_SIGNAL(StageAddedSignal, signal_stage_added);
47  DEFINE_SIGNAL(StageRemovedSignal, signal_stage_removed);
48 
49 public:
50  struct IteratorPair {
51  friend class StageManager;
52 
53  std::list<Stage*>::iterator begin();
54  std::list<Stage*>::iterator end();
55 
56  private:
57  IteratorPair(StageManager* owner):
58  owner_(owner) {}
59 
60  StageManager* owner_;
61  };
62 
63  friend struct IteratorPair;
64 
65  StageManager();
66  virtual ~StageManager();
67 
68  StagePtr new_stage(AvailablePartitioner partitioner=PARTITIONER_FRUSTUM);
70  StagePtr destroy_stage(StageID s);
71  std::size_t stage_count() const;
72  bool has_stage(StageID stage_id) const;
73 
74  void fixed_update(float dt) override;
75  void update(float dt) override;
76  void late_update(float dt) override;
77 
78  void destroy_all_stages();
79 
80  IteratorPair each_stage();
81 
82  /* Implementation for TypedDestroyableObject (INTERNAL) */
83  void destroy_object(Stage* object);
84  void destroy_object_immediately(Stage* object);
85 
86 protected:
87  void clean_destroyed_stages();
88 
91 
92  StagePool* pool_ = nullptr;
93  StageList* manager_ = nullptr;
94 };
95 
96 }
smlt::StageManager::stage
StagePtr stage(StageID s)
StageManager::stage.
Definition: stage_manager.cpp:66
smlt::Application
Definition: application.h:162
smlt::Stage
Definition: stage.h:80
smlt::Updateable
The Updateable class.
Definition: updateable.h:13
smlt::StageManager::IteratorPair
Definition: stage_manager.h:50
smlt
Definition: animation.cpp:25
smlt::Polylist
Definition: polylist.h:67
smlt::UniqueID
Definition: unique_id.h:77
smlt::StageNodeManager
Definition: stage_node_manager.h:25
smlt::StageManager
Definition: stage_manager.h:42
smlt::default_init_ptr< Stage >
smlt::sig::signal
Definition: signal.h:330