Panda3D
 All Classes Functions Variables Enumerations
pvector.h
1 // Filename: pvector.h
2 // Created by: drose (05Jun01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef PVECTOR_H
16 #define PVECTOR_H
17 
18 #include <vector>
19 
20 #include "dtoolbase.h"
21 #include "pallocator.h"
22 #include "register_type.h"
23 
24 #ifndef USE_STL_ALLOCATOR
25 // If we're not using custom allocators, just use the standard class
26 // definition.
27 #define pvector vector
28 
29 #else
30 
31 ////////////////////////////////////////////////////////////////////
32 // Class : pvector
33 // Description : This is our own Panda specialization on the default
34 // STL vector. Its main purpose is to call the hooks
35 // for MemoryUsage to properly track STL-allocated
36 // memory.
37 ////////////////////////////////////////////////////////////////////
38 template<class Type>
39 class pvector : public vector<Type, pallocator_array<Type> > {
40 public:
42  typedef vector<Type, allocator> base_class;
43  typedef TYPENAME base_class::size_type size_type;
44 
45  pvector(TypeHandle type_handle = pvector_type_handle) : base_class(allocator(type_handle)) { }
46  pvector(const pvector<Type> &copy) : base_class(copy) { }
47  pvector(size_type n, TypeHandle type_handle = pvector_type_handle) : base_class(n, Type(), allocator(type_handle)) { }
48  pvector(size_type n, const Type &value, TypeHandle type_handle = pvector_type_handle) : base_class(n, value, allocator(type_handle)) { }
49  pvector(const Type *begin, const Type *end, TypeHandle type_handle = pvector_type_handle) : base_class(begin, end, allocator(type_handle)) { }
50 };
51 
52 #endif // USE_STL_ALLOCATOR
53 
54 #endif
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:39
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85