/* grav - N-body gravity simulation Copyright (C) 2011 Ian Cowburn This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . $Id$ This file provides a common interface shared between the core grav program and the GFX drivers. */ #ifndef GRAV_GRAVIFACE_H #define GRAV_GRAVIFACE_H "$Id$" #include /* --------------------------------------------------------------------------- This determinate the version of the interface, so both sides can check they were built with the same interface. */ #define GRAV_INTERFACE_VERSION 1 /* --------------------------------------------------------------------------- This type defines an instance of any data that the driver needs to maintain. As the drivers are sharable objects, it is recommended that this points to dynamic memory. */ typedef void *grav_interface_t; /* --------------------------------------------------------------------------- This structure is passed to the driver on initialisation so it can check compataility. The first field is guaranteed to be an int holding GRAV_INTERFACE_VERSION. */ typedef struct { /* Interface version info. */ int grav_interface_version; /* The version of the GNU MP library the core is compiled against. */ int grav_mp_version_major; int grav_mp_version_minor; /* An interface the driver can use to iterate over loaded config. p_func is called for every variable in the section along with the pass client data. */ const char (*grav_config_func)(const char *p_section, void (*p_func)(void *p_client_data, const char *p_section, const char *p_value), void *p_client_data); /* An interface the driver can use to request termination. p_reason can be NULL. */ void (*grav_exit_func)(const char *p_reason);, } grav_icb_t; /* --------------------------------------------------------------------------- This structure defines a mass to be drawn. Masses are passed in arbitary order. Each mass has a unique identifier, which is defined by "id". */ typedef struct { mpz_t id; } grav_public_mass_t; /* --------------------------------------------------------------------------- This function must be exported by the driver, and is used to initialise the driver. If the driver disagrees with the version then false should be returned, otherwise true. The passed pointer is a pointer to a grav_icb_t. */ typedef int (*grav_interface_init_func)(const void *p); #endif /* GRAV_GRAVIFACE_H */