00001 // Filename: vector_src.h 00002 // Created by: drose (15May01) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // 00022 // This file defines the interface to declare and export from the DLL 00023 // an STL vector of some type. 00024 // 00025 // To use this file you must #define a number of symbols and then 00026 // #include it from a .h file. You also must do the same thing with 00027 // vector_something_src.cxx from a .cxx file. 00028 // 00029 // This is necessary because of the complexity involved in exporting a 00030 // vector class from a DLL. If we are using the Dinkumware STL 00031 // implementation, it is even more complex. However, all this 00032 // complexity is only needed to support Windows builds; Unix shared 00033 // libraries are able to export symbols (including templates) without 00034 // any special syntax. 00035 // 00036 //////////////////////////////////////////////////////////////////// 00037 00038 // The following variables should be defined prior to including this 00039 // file: 00040 // 00041 // EXPCL - the appropriate EXPCL_* symbol for this DLL. 00042 // EXPTP - the appropriate EXPTP_* symbol for this DLL. 00043 // TYPE - the type of thing we are building a vector on. 00044 // NAME - The name of the resulting vector typedef, e.g. vector_int. 00045 // 00046 // They will automatically be undefined at the end of the file. 00047 00048 #include "pvector.h" 00049 00050 #if defined(WIN32_VC) && !defined(CPPPARSER) 00051 00052 #ifdef HAVE_DINKUM 00053 // With the Dinkum library, we must first export the base class, 00054 // _Vector_val. 00055 #define VV_BASE std::_Vector_val<TYPE, pallocator<TYPE> > 00056 #pragma warning (disable : 4231) 00057 EXPORT_TEMPLATE_CLASS(EXPCL, EXPTP, VV_BASE) 00058 #undef VV_BASE 00059 #endif 00060 00061 // Now we can export the vector class. 00062 #pragma warning (disable : 4231) 00063 00064 #ifdef NO_STYLE_ALLOCATOR 00065 EXPORT_TEMPLATE_CLASS(EXPCL, EXPTP, std::vector<TYPE>) 00066 #else 00067 #define STD_VECTOR std::vector<TYPE, pallocator<TYPE> > 00068 EXPORT_TEMPLATE_CLASS(EXPCL, EXPTP, STD_VECTOR) 00069 #undef STD_VECTOR 00070 EXPORT_TEMPLATE_CLASS(EXPCL, EXPTP, pvector<TYPE>) 00071 #endif 00072 00073 #endif 00074 00075 // Now make a typedef for the vector. 00076 00077 #ifdef NO_STYLE_ALLOCATOR 00078 typedef std::vector<TYPE> NAME; 00079 #else 00080 typedef pvector<TYPE> NAME; 00081 #endif 00082 00083 // Finally, we must define a non-inline function that performs the 00084 // insert operation given a range of pointers. We do this because 00085 // the Dinkum STL implementation uses member templates to handle 00086 // this, but we cannot export the member templates from the DLL. 00087 00088 /* 00089 extern EXPCL void 00090 insert_into_vector(NAME &vec, NAME::iterator where, 00091 const TYPE *begin, const TYPE *end); 00092 */ 00093 00094 00095 #undef EXPCL 00096 #undef EXPTP 00097 #undef TYPE 00098 #undef NAME 00099