Molmodel

common.h

Go to the documentation of this file.
00001 #ifndef SimTK_MOLMODEL_COMMON_H_
00002 #define SimTK_MOLMODEL_COMMON_H_
00003 
00004 /* -------------------------------------------------------------------------- *
00005  *                      SimTK Core: SimTK Molmodel                             *
00006  * -------------------------------------------------------------------------- *
00007  * This is part of the SimTK Core biosimulation toolkit originating from      *
00008  * Simbios, the NIH National Center for Physics-Based Simulation of           *
00009  * Biological Structures at Stanford, funded under the NIH Roadmap for        *
00010  * Medical Research, grant U54 GM072970. See https://simtk.org.               *
00011  *                                                                            *
00012  * Portions copyright (c) 2007 Stanford University and the Authors.           *
00013  * Authors: Christopher Bruns                                                 *
00014  * Contributors:                                                              *
00015  *                                                                            *
00016  * Permission is hereby granted, free of charge, to any person obtaining a    *
00017  * copy of this software and associated documentation files (the "Software"), *
00018  * to deal in the Software without restriction, including without limitation  *
00019  * the rights to use, copy, modify, merge, publish, distribute, sublicense,   *
00020  * and/or sell copies of the Software, and to permit persons to whom the      *
00021  * Software is furnished to do so, subject to the following conditions:       *
00022  *                                                                            *
00023  * The above copyright notice and this permission notice shall be included in *
00024  * all copies or substantial portions of the Software.                        *
00025  *                                                                            *
00026  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
00027  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   *
00028  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    *
00029  * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,    *
00030  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR      *
00031  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE  *
00032  * USE OR OTHER DEALINGS IN THE SOFTWARE.                                     *
00033  * -------------------------------------------------------------------------- */
00034 
00040 #include "SimTKcommon.h"
00041 
00042 #include <cassert>
00043 #include <vector>
00044 #include <limits>
00045 
00046 // Shared libraries are messy in Visual Studio. We have to distinguish three
00047 // cases:
00048 //   (1) this header is being used to build the molmodel shared library (dllexport)
00049 //   (2) this header is being used by a *client* of the molmodel shared
00050 //       library (dllimport)
00051 //   (3) we are building the molmodel static library, or the client is
00052 //       being compiled with the expectation of linking with the
00053 //       molmodel static library (nothing special needed)
00054 // In the CMake script for building this library, we define one of the symbols
00055 //     SimTK_MOLMODEL_BUILDING_{SHARED|STATIC}_LIBRARY
00056 // Client code normally has no special symbol defined, in which case we'll
00057 // assume it wants to use the shared library. However, if the client defines
00058 // the symbol SimTK_USE_STATIC_LIBRARIES we'll suppress the dllimport so
00059 // that the client code can be linked with static libraries. Note that
00060 // the client symbol is not library dependent, while the library symbols
00061 // affect only the molmodel library, meaning that other libraries can
00062 // be clients of this one. However, we are assuming all-static or all-shared.
00063 
00064 #ifdef _WIN32
00065 
00066     // avoid warning about use of non-standard "extern template" constructs
00067     // #ifdef _MSC_VER
00068     // #pragma warning(disable:4231)
00069     // #endif
00070 
00071     #if defined(SimTK_MOLMODEL_BUILDING_SHARED_LIBRARY)
00072         #define SimTK_MOLMODEL_EXPORT __declspec(dllexport)
00073 
00074         // Keep MS VC++ quiet when it tries to instantiate incomplete template classes in a DLL.
00075         #ifdef _MSC_VER
00076         #pragma warning(disable:4661)
00077 
00078         // and lack of dll export of private members
00079         #pragma warning(disable:4251)
00080         #endif
00081 
00082     #elif defined(SimTK_MOLMODEL_BUILDING_STATIC_LIBRARY) || defined(SimTK_USE_STATIC_LIBRARIES)
00083         #define SimTK_MOLMODEL_EXPORT
00084     #else
00085         #define SimTK_MOLMODEL_EXPORT __declspec(dllimport)   // i.e., a client of a shared library
00086     #endif
00087 #else
00088     #define SimTK_MOLMODEL_EXPORT // Linux, Mac
00089 #endif
00090 
00091 // Every SimTK Core library must provide these two routines, with the library
00092 // name appearing after the "version_" and "about_".
00093 extern "C" {
00094     SimTK_MOLMODEL_EXPORT void SimTK_version_molmodel(int* major, int* minor, int* build);
00095     SimTK_MOLMODEL_EXPORT void SimTK_about_molmodel(const char* key, int maxlen, char* value);
00096 }
00097 
00098 #endif // SimTK_MOLMODEL_COMMON_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines