Debian Codegraph @

src/common/objects.cpp

raw symbols SCIP
1 // This file is part of Dust Racing 2D.
2 // Copyright (C) 2011 Jussi Lind <[email protected]>
3 //
4 // Dust Racing 2D is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 // Dust Racing 2D is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with Dust Racing 2D. If not, see <http://www.gnu.org/licenses/>.
15
16 #include "objects.hpp"
17
18 #include <algorithm>
19
20 Objects::Objects()
21 {
22 }
23
24 void Objects::add(ObjectBasePtr object)
25 {
26 auto i = std::find(m_objects.begin(), m_objects.end(), object);
27 if (i == m_objects.end())
28 {
29 m_objects.push_back(object);
30 }
31 }
32
33 void Objects::remove(ObjectBase & object)
34 {
35 for (auto i = m_objects.begin(); i != m_objects.end(); i++)
36 {
37 if ((*i).get() == &object)
38 {
39 m_objects.erase(i);
40 return;
41 }
42 }
43 }
44
45 void Objects::clear()
46 {
47 m_objects.clear();
48 }
49
50 size_t Objects::count() const
51 {
52 return m_objects.size();
53 }
54
55 ObjectBasePtr Objects::object(size_t index) const
56 {
57 return m_objects.at(index);
58 }
59
60 Objects::ObjectVector::iterator Objects::begin()
61 {
62 return m_objects.begin();
63 }
64
65 Objects::ObjectVector::iterator Objects::end()
66 {
67 return m_objects.end();
68 }
69
70 Objects::ObjectVector::const_iterator Objects::cbegin() const
71 {
72 return m_objects.cbegin();
73 }
74
75 Objects::ObjectVector::const_iterator Objects::cend() const
76 {
77 return m_objects.cend();
78 }