Panda3D

pvector.h

00001 // Filename: pvector.h
00002 // Created by:  drose (05Jun01)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef PVECTOR_H
00016 #define PVECTOR_H
00017 
00018 #include <vector>
00019 
00020 #include "dtoolbase.h"
00021 #include "pallocator.h"
00022 #include "register_type.h"
00023 
00024 #ifndef USE_STL_ALLOCATOR
00025 // If we're not using custom allocators, just use the standard class
00026 // definition.
00027 #define pvector vector
00028 
00029 #else
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //       Class : pvector
00033 // Description : This is our own Panda specialization on the default
00034 //               STL vector.  Its main purpose is to call the hooks
00035 //               for MemoryUsage to properly track STL-allocated
00036 //               memory.
00037 ////////////////////////////////////////////////////////////////////
00038 template<class Type>
00039 class pvector : public vector<Type, pallocator_array<Type> > {
00040 public:
00041   typedef pallocator_array<Type> allocator;
00042   typedef vector<Type, allocator> base_class;
00043   typedef TYPENAME base_class::size_type size_type;
00044 
00045   pvector(TypeHandle type_handle = pvector_type_handle) : base_class(allocator(type_handle)) { }
00046   pvector(const pvector<Type> &copy) : base_class(copy) { }
00047   pvector(size_type n, TypeHandle type_handle = pvector_type_handle) : base_class(n, Type(), allocator(type_handle)) { }
00048   pvector(size_type n, const Type &value, TypeHandle type_handle = pvector_type_handle) : base_class(n, value, allocator(type_handle)) { }
00049   pvector(const Type *begin, const Type *end, TypeHandle type_handle = pvector_type_handle) : base_class(begin, end, allocator(type_handle)) { }
00050 };
00051 
00052 #endif  // USE_STL_ALLOCATOR
00053 #endif
00054 
 All Classes Functions Variables Enumerations