Panda3D
Loading...
Searching...
No Matches
physxObjectCollection.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file physxObjectCollection.I
10 * @author enn0x
11 * @date 2009-11-08
12 */
13
14/**
15 *
16 */
17template <class T>
18INLINE unsigned int PhysxObjectCollection<T>::
19size() const {
20
21 return _objects.size();
22}
23
24/**
25 *
26 */
27template <class T>
29add(PT(T) object) {
30
31 _objects.push_back(object);
33
34/**
35 *
36 */
37template <class T>
39remove(PT(T) object) {
40
41 typename pvector<PT(T)>::iterator it;
42
43 it = find(_objects.begin(), _objects.end(), object);
44 if (it != _objects.end()) {
45 _objects.erase(it);
46 }
47 else
48 {
49 physx_cat.warning() << "object not found in collection" << std::endl;
50 }
51}
52
53/**
54 * Returns the n-th PhysxObject in the collection. The operator [] is maybe a
55 * more convenient way to access objects from the collection.
56 */
57template <class T>
59get(unsigned int index) const {
60
61 nassertr(index < _objects.size(), nullptr);
62 return _objects[index];
63}
64
65/**
66 * Returns the n-th PhysxObject in the collection. This is the same as the
67 * get() method.
68 */
69template <class T>
71operator [] (unsigned int index) const {
72
73 nassertr(index < _objects.size(), nullptr);
74 return _objects[index];
75}
76
77/**
78 *
79 */
80template <class T>
82ls() const {
83
84 ls(nout);
85}
86
87/**
88 *
89 */
90template <class T>
92ls(std::ostream &out, int indent_level) const {
93
94 for (unsigned int i=0; i < size(); i++) {
95 get(i)->ls(out, indent_level + 2);
96 }
97}
T * operator[](unsigned int index) const
Returns the n-th PhysxObject in the collection.
T * get(unsigned int index) const
Returns the n-th PhysxObject in the collection.
This is our own Panda specialization on the default STL vector.
Definition pvector.h:42