vector_src.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // Filename: vector_src.h
  2. // Created by: drose (15May01)
  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. ////////////////////////////////////////////////////////////////////
  19. //
  20. // This file defines the interface to declare and export from the DLL
  21. // an STL vector of some type.
  22. //
  23. // To use this file you must #define a number of symbols and then
  24. // #include it from a .h file. You also must do the same thing with
  25. // vector_something_src.cxx from a .cxx file.
  26. //
  27. // This is necessary because of the complexity involved in exporting a
  28. // vector class from a DLL. If we are using the Dinkumware STL
  29. // implementation, it is even more complex. However, all this
  30. // complexity is only needed to support Windows builds; Unix shared
  31. // libraries are able to export symbols (including templates) without
  32. // any special syntax.
  33. //
  34. ////////////////////////////////////////////////////////////////////
  35. // The following variables should be defined prior to including this
  36. // file:
  37. //
  38. // EXPCL - the appropriate EXPCL_* symbol for this DLL.
  39. // EXPTP - the appropriate EXPTP_* symbol for this DLL.
  40. // TYPE - the type of thing we are building a vector on.
  41. // NAME - The name of the resulting vector typedef, e.g. vector_int.
  42. //
  43. // They will automatically be undefined at the end of the file.
  44. #include "pvector.h"
  45. #if defined(WIN32_VC) && !defined(CPPPARSER)
  46. #ifdef HAVE_DINKUM
  47. // With the Dinkum library, we must first export the base class,
  48. // _Vector_val.
  49. #define VV_BASE std::_Vector_val<TYPE, pallocator<TYPE> >
  50. #pragma warning (disable : 4231)
  51. EXPORT_TEMPLATE_CLASS(EXPCL, EXPTP, VV_BASE)
  52. #undef VV_BASE
  53. #endif
  54. // Now we can export the vector class.
  55. #pragma warning (disable : 4231)
  56. #ifdef NO_STYLE_ALLOCATOR
  57. EXPORT_TEMPLATE_CLASS(EXPCL, EXPTP, std::vector<TYPE>)
  58. #else
  59. #define STD_VECTOR std::vector<TYPE, pallocator<TYPE> >
  60. EXPORT_TEMPLATE_CLASS(EXPCL, EXPTP, STD_VECTOR)
  61. #undef STD_VECTOR
  62. EXPORT_TEMPLATE_CLASS(EXPCL, EXPTP, pvector<TYPE>)
  63. #endif
  64. #endif
  65. // Now make a typedef for the vector.
  66. #ifdef NO_STYLE_ALLOCATOR
  67. typedef std::vector<TYPE> NAME;
  68. #else
  69. typedef pvector<TYPE> NAME;
  70. #endif
  71. // Finally, we must define a non-inline function that performs the
  72. // insert operation given a range of pointers. We do this because
  73. // the Dinkum STL implementation uses member templates to handle
  74. // this, but we cannot export the member templates from the DLL.
  75. /*
  76. extern EXPCL void
  77. insert_into_vector(NAME &vec, NAME::iterator where,
  78. const TYPE *begin, const TYPE *end);
  79. */
  80. #undef EXPCL
  81. #undef EXPTP
  82. #undef TYPE
  83. #undef NAME