added Verlet scheme and NxN non-bonded functionality
[gromacs.git] / src / gmxlib / vmdplugin.h
blob895bf14023f0fbc5a6bf44d7df6b1f4d08e9774b
1 /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
3 *
4 * This file is part of Gromacs Copyright (c) 1991-2008
5 * David van der Spoel, Erik Lindahl, Berk Hess, University of Groningen.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * To help us fund GROMACS development, we humbly ask that you cite
13 * the research papers on the package. Check out http://www.gromacs.org
15 * And Hey:
16 * Gnomes, ROck Monsters And Chili Sauce
19 /***************************************************************************
20 *cr
21 *cr (C) Copyright 1995-2006 The Board of Trustees of the
22 *cr University of Illinois
23 *cr All Rights Reserved
24 *cr
25 Developed by: Theoretical and Computational Biophysics Group
26 University of Illinois at Urbana-Champaign
27 http://www.ks.uiuc.edu/
29 Permission is hereby granted, free of charge, to any person obtaining a copy of
30 this software and associated documentation files (the Software), to deal with
31 the Software without restriction, including without limitation the rights to
32 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
33 of the Software, and to permit persons to whom the Software is furnished to
34 do so, subject to the following conditions:
36 Redistributions of source code must retain the above copyright notice,
37 this list of conditions and the following disclaimers.
39 Redistributions in binary form must reproduce the above copyright notice,
40 this list of conditions and the following disclaimers in the documentation
41 and/or other materials provided with the distribution.
43 Neither the names of Theoretical and Computational Biophysics Group,
44 University of Illinois at Urbana-Champaign, nor the names of its contributors
45 may be used to endorse or promote products derived from this Software without
46 specific prior written permission.
48 THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
49 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
50 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
51 THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
52 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
53 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
54 OTHER DEALINGS WITH THE SOFTWARE.
55 ***************************************************************************/
57 /***************************************************************************
58 * RCS INFORMATION:
60 * $RCSfile: vmdplugin.h,v $
61 * $Author: johns $ $Locker: $ $State: Exp $
62 * $Revision: 1.32 $ $Date: 2009/02/24 05:12:35 $
64 ***************************************************************************/
66 /** @file
67 * This header must be included by every VMD plugin library. It defines the
68 * API for every plugin so that VMD can organize the plugins it finds.
71 #ifndef VMD_PLUGIN_H
72 #define VMD_PLUGIN_H
75 /*
76 * Preprocessor tricks to make it easier for us to redefine the names of
77 * functions when building static plugins.
79 #if !defined(VMDPLUGIN)
80 /**
81 * macro defining VMDPLUGIN if it hasn't already been set to the name of
82 * a static plugin that is being compiled. This is the catch-all case.
84 #define VMDPLUGIN vmdplugin
85 #endif
86 /** concatenation macro, joins args x and y together as a single string */
87 #define xcat(x, y) cat(x, y)
88 /** concatenation macro, joins args x and y together as a single string */
89 #define cat(x, y) x ## y
92 * macros to correctly define plugin function names depending on whether
93 * the plugin is being compiled for static linkage or dynamic loading.
94 * When compiled for static linkage, each plugin needs to have unique
95 * function names for all of its entry points. When compiled for dynamic
96 * loading, the plugins must name their entry points consistently so that
97 * the plugin loading mechanism can find the register, register_tcl, init,
98 * and fini routines via dlopen() or similar operating system interfaces.
100 /*@{*/
101 /** Macro names entry points correctly for static linkage or dynamic loading */
102 #define VMDPLUGIN_register xcat(VMDPLUGIN, _register)
103 #define VMDPLUGIN_register_tcl xcat(VMDPLUGIN, _register_tcl)
104 #define VMDPLUGIN_init xcat(VMDPLUGIN, _init)
105 #define VMDPLUGIN_fini xcat(VMDPLUGIN, _fini)
106 /*@}*/
109 /** "WIN32" is defined on both WIN32 and WIN64 platforms... */
110 #if (defined(WIN32))
111 #define WIN32_LEAN_AND_MEAN
112 #include <windows.h>
114 #if !defined(STATIC_PLUGIN)
115 #if defined(VMDPLUGIN_EXPORTS)
116 /**
117 * Only define DllMain for plugins, not in VMD or in statically linked plugins
118 * VMDPLUGIN_EXPORTS is only defined when compiling dynamically loaded plugins
120 BOOL APIENTRY DllMain( HANDLE hModule,
121 DWORD ul_reason_for_call,
122 LPVOID lpReserved
125 return TRUE;
128 #define VMDPLUGIN_API __declspec(dllexport)
129 #else
130 #define VMDPLUGIN_API __declspec(dllimport)
131 #endif /* VMDPLUGIN_EXPORTS */
132 #else /* ! STATIC_PLUGIN */
133 #define VMDPLUGIN_API
134 #endif /* ! STATIC_PLUGIN */
135 #else
136 /** If we're not compiling on Windows, then this macro is defined empty */
137 #define VMDPLUGIN_API
138 #endif
140 /** define plugin linkage correctly for both C and C++ based plugins */
141 #ifdef __cplusplus
142 #define VMDPLUGIN_EXTERN extern "C" VMDPLUGIN_API
143 #else
144 #define VMDPLUGIN_EXTERN extern VMDPLUGIN_API
145 #endif /* __cplusplus */
148 * Plugin API functions start here
152 /**
153 * Init routine: called the first time the library is loaded by the
154 * application and before any other API functions are referenced.
155 * Return 0 on success.
157 VMDPLUGIN_EXTERN int VMDPLUGIN_init(void);
160 * Macro for creating a struct header used in all plugin structures.
162 * This header should be placed at the top of every plugin API definition
163 * so that it can be treated as a subtype of the base plugin type.
165 * abiversion: Defines the ABI for the base plugin type (not for other plugins)
166 * type: A string descriptor of the plugin type.
167 * name: A name for the plugin.
168 * author: A string identifier, possibly including newlines.
169 * Major and minor version.
170 * is_reentrant: Whether this library can be run concurrently with itself.
172 #define vmdplugin_HEAD \
173 int abiversion; \
174 const char *type; \
175 const char *name; \
176 const char *prettyname; \
177 const char *author; \
178 int majorv; \
179 int minorv; \
180 int is_reentrant
182 /**
183 * Typedef for generic plugin header, individual plugins can
184 * make their own structures as long as the header info remains
185 * the same as the generic plugin header, most easily done by
186 * using the vmdplugin_HEAD macro.
188 typedef struct {
189 vmdplugin_HEAD;
190 } vmdplugin_t;
193 * Use this macro to initialize the abiversion member of each plugin
195 #define vmdplugin_ABIVERSION 16
197 /*@{*/
198 /** Use this macro to indicate a plugin's thread-safety at registration time */
199 #define VMDPLUGIN_THREADUNSAFE 0
200 #define VMDPLUGIN_THREADSAFE 1
201 /*@}*/
203 /*@{*/
204 /** Error return code for use in the plugin registration and init functions */
205 #define VMDPLUGIN_SUCCESS 0
206 #define VMDPLUGIN_ERROR -1
207 /*@}*/
209 /**
210 * Function pointer typedef for register callback functions
212 typedef int (*vmdplugin_register_cb)(void *, vmdplugin_t *);
215 * Allow the library to register plugins with the application.
216 * The callback should be called using the passed-in void pointer, which
217 * should not be interpreted in any way by the library. Each vmdplugin_t
218 * pointer passed to the application should point to statically-allocated
219 * or heap-allocated memory and should never be later modified by the plugin.
220 * Applications must be permitted to retain only a copy of the the plugin
221 * pointer, without making any deep copy of the items in the struct.
223 VMDPLUGIN_EXTERN int VMDPLUGIN_register(void *, vmdplugin_register_cb);
226 * Allow the library to register Tcl extensions.
227 * This API is optional; if found by dlopen, it will be called after first
228 * calling init and register.
230 VMDPLUGIN_EXTERN int VMDPLUGIN_register_tcl(void *, void *tcl_interp,
231 vmdplugin_register_cb);
234 * The Fini method is called when the application will no longer use
235 * any plugins in the library.
237 VMDPLUGIN_EXTERN int VMDPLUGIN_fini(void);
239 #endif /* VMD_PLUGIN_H */