Gamedev Framework (gf)  0.4.0 A C++11 framework for 2D games
ModelContainer.h
1 /*
2  * Gamedev Framework (gf)
3  * Copyright (C) 2016-2017 Julien Bernard
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  *
9  * Permission is granted to anyone to use this software for any purpose,
10  * including commercial applications, and to alter it and redistribute it
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  * 2. Altered source versions must be plainly marked as such, and must not be
18  * misrepresented as being the original software.
19  * 3. This notice may not be removed or altered from any source distribution.
20  */
21 #ifndef GF_MODEL_CONTAINER_H
22 #define GF_MODEL_CONTAINER_H
23
24 #include <vector>
25
26 #include "Portability.h"
27
28 namespace gf {
29 #ifndef DOXYGEN_SHOULD_SKIP_THIS
30 inline namespace v1 {
31 #endif
32
33  class Model;
34
35  /**
36  * @ingroup game
37  * @brief A collection of models
38  *
39  * gf::ModelContainer represents a collection of models that are updated
40  * automatically.
41  *
42  * The model manager is *not* responsible for the memory of the models. The
43  * models must be allocated by the user and not deleted while they are
44  * handled by the model manager.
45  *
46  * Generally, you only need one model manager in your game. You create it
47  * at the beginning of the game and put all your models in it. Then you
48  * can call gf::ModelContainer::update() in your game loop.
49  *
50  * @sa gf::Model
51  */
53  public:
54
55  /**
56  * @brief Update the models
57  *
58  * @param dt The time (in seconds) since the last update
59  * @sa gf::Model::update()
60  */
61  void update(float dt);
62
63  /**
64  * @brief Add a model to the collection
65  *
66  * The model must not be deleted while it is handled by the model manager.
67  *
68  * @param model A model
69  * @sa removeModel()
70  */
72
73  /**
74  * @brief Remove a model from the collection
75  *
76  * @param model The model to remove
77  * @return The removed model or nullptr if the model was not present
79  */
80  Model *removeModel(Model *model);
81
82  private:
83  std::vector<Model *> m_models;
84  };
85
86 #ifndef DOXYGEN_SHOULD_SKIP_THIS
87 }
88 #endif
89 }
90
91 #endif // GF_MODEL_CONTAINER_H
Model * removeModel(Model *model)
Remove a model from the collection.
A collection of models.
Definition: ModelContainer.h:52
A game object that can be updated.
Definition: Model.h:45
void update(float dt)
Update the models.
The namespace for gf classes.
Definition: Action.h:34
#define GF_API
Definition: Portability.h:35