diff options
author | Ian C <ianc@noddybox.co.uk> | 2011-01-14 15:14:14 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2011-01-14 15:14:14 +0000 |
commit | 44525767b158902ea0183b4e5e36973bea010a08 (patch) | |
tree | 5e677e61168aa0e2ebedd04255bccbcf475846b1 /src | |
parent | bb652fd56a4515acecae5631641d3a0ac2909bef (diff) |
Development checkin
Diffstat (limited to 'src')
-rw-r--r-- | src/graviface.h | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/src/graviface.h b/src/graviface.h new file mode 100644 index 0000000..a34f7b5 --- /dev/null +++ b/src/graviface.h @@ -0,0 +1,101 @@ +/* + grav - N-body gravity simulation + + Copyright (C) 2011 Ian Cowburn <ianc@noddybox.co.uk> + + 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 <http://www.gnu.org/licenses/>. + + $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 <mp.h> + + +/* --------------------------------------------------------------------------- + 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; + const char *name; +} 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 */ |