Debian Codegraph @

src/include/subsys.h

raw
1 //
2 // Copyright (C) 2004-2006 Jasmine Langridge, [email protected]
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 //
18
19 #pragma once
20
21 #include <string>
22 #include <vector>
23
24
25 ///
26 /// @brief A PResource basically is just a name
27 ///
28 class PResource
29 {
30 protected:
31 std::string name;
32
33 public:
34 const std::string & getName() const
35 {
36 return name;
37 }
38 };
39
40 ///
41 /// @brief Implementation of a buffer where you can push inside stuff and clear everything if you want
42 /// @todo Actually is not a list. Why is called this way?
43 ///
44 template <class T>
45 class PResourceList
46 {
47 private:
48
49 std::vector<T *> reslist;
50
51 public:
52
53 ~PResourceList()
54 {
55 clear();
56 }
57
58 T * add(T *newresource)
59 {
60 reslist.push_back(newresource);
61 return newresource;
62 }
63
64 T * find(const std::string &name)
65 {
66 for (T *res: reslist)
67 if (name == res->getName())
68 return res;
69 return nullptr;
70 }
71
72 void clear()
73 {
74 for (T *res: reslist)
75 delete res;
76
77 reslist.clear();
78 }
79 };
80
81 class PSubsystem
82 {
83 protected:
84
85 PApp &app;
86
87 public:
88
89 PSubsystem(PApp &parentApp):
90 app(parentApp)
91 {
92 }
93
94 virtual ~PSubsystem()
95 {
96 }
97
98 virtual void tick(float delta, const vec3f &eyepos, const mat44f &eyeori, const vec3f &eyevel)
99 {
100 UNREFERENCED_PARAMETER(delta);
101 UNREFERENCED_PARAMETER(eyepos);
102 UNREFERENCED_PARAMETER(eyeori);
103 UNREFERENCED_PARAMETER(eyevel);
104 }
105 };
106