pdeque.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Filename: pdeque.h
  2. // Created by: drose (05Jun01)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef PDEQUE_H
  19. #define PDEQUE_H
  20. #include "dtoolbase.h"
  21. #include "pallocator.h"
  22. #include "register_type.h"
  23. #include <deque>
  24. #ifndef USE_STL_ALLOCATOR
  25. // If we're not using custom allocators, just use the standard class
  26. // definition.
  27. #define pdeque deque
  28. #else
  29. ////////////////////////////////////////////////////////////////////
  30. // Class : pdeque
  31. // Description : This is our own Panda specialization on the default
  32. // STL deque. Its main purpose is to call the hooks
  33. // for MemoryUsage to properly track STL-allocated
  34. // memory.
  35. ////////////////////////////////////////////////////////////////////
  36. template<class Type>
  37. class pdeque : public deque<Type, pallocator_array<Type> > {
  38. public:
  39. typedef pallocator_array<Type> allocator;
  40. typedef TYPENAME deque<Type, allocator>::size_type size_type;
  41. pdeque(TypeHandle type_handle = pdeque_type_handle) : deque<Type, pallocator_array<Type> >(allocator(type_handle)) { }
  42. pdeque(const pdeque<Type> &copy) : deque<Type, pallocator_array<Type> >(copy) { }
  43. pdeque(size_type n, TypeHandle type_handle = pdeque_type_handle) : deque<Type, pallocator_array<Type> >(n, Type(), allocator(type_handle)) { }
  44. pdeque(size_type n, const Type &value, TypeHandle type_handle = pdeque_type_handle) : deque<Type, pallocator_array<Type> >(n, value, allocator(type_handle)) { }
  45. };
  46. #endif // USE_STL_ALLOCATOR
  47. #endif