Panda3D
|
00001 // Filename: plist.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 PLIST_H 00016 #define PLIST_H 00017 00018 #include "dtoolbase.h" 00019 #include "pallocator.h" 00020 #include "register_type.h" 00021 #include <list> 00022 00023 #ifndef USE_STL_ALLOCATOR 00024 // If we're not using custom allocators, just use the standard class 00025 // definition. 00026 #define plist list 00027 00028 #else 00029 00030 //////////////////////////////////////////////////////////////////// 00031 // Class : plist 00032 // Description : This is our own Panda specialization on the default 00033 // STL list. Its main purpose is to call the hooks 00034 // for MemoryUsage to properly track STL-allocated 00035 // memory. 00036 //////////////////////////////////////////////////////////////////// 00037 template<class Type> 00038 class plist : public list<Type, pallocator_single<Type> > { 00039 public: 00040 typedef pallocator_single<Type> allocator; 00041 typedef list<Type, allocator> base_class; 00042 typedef TYPENAME base_class::size_type size_type; 00043 plist(TypeHandle type_handle = plist_type_handle) : base_class(allocator(type_handle)) { } 00044 plist(const plist<Type> ©) : base_class(copy) { } 00045 plist(size_type n, TypeHandle type_handle = plist_type_handle) : base_class(n, Type(), allocator(type_handle)) { } 00046 plist(size_type n, const Type &value, TypeHandle type_handle = plist_type_handle) : base_class(n, value, allocator(type_handle)) { } 00047 00048 typedef TYPENAME base_class::iterator iterator; 00049 typedef TYPENAME base_class::const_iterator const_iterator; 00050 typedef TYPENAME base_class::reverse_iterator reverse_iterator; 00051 typedef TYPENAME base_class::const_reverse_iterator const_reverse_iterator; 00052 }; 00053 00054 #endif // USE_STL_ALLOCATOR 00055 #endif