torcs - 1.2.2

src/libs/tgf/tgf.h File Reference


Detailed Description

The Gaming Framework API.

Author:
Eric Espie
Version:
Id
tgf.h,v 1.37 2003/08/23 23:43:14 torcs Exp

#include <stdio.h>
#include <sys/param.h>
#include <assert.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include <osspec.h>

Include dependency graph for tgf.h:

Include dependency graph

Go to the source code of this file.

Compounds

struct  FList
 List of (DLL) files for a Directory. More...

struct  ModInfo
 Module information structure. More...

struct  ModList
 list of module interfaces More...

struct  t3Dd
 3D point. More...

struct  t3Df
struct  t3Di
struct  tDynPt
 Dynamic point structure. More...

struct  tForces
 Forces and moments. More...

struct  tMeanVal
struct  tPosd
 6 DOF position. More...


Defines

#define MAX(x, y)   ((x) > (y) ? (x) : (y))
#define MIN(x, y)   ((x) < (y) ? (x) : (y))
#define FREEZ(x)
#define freez   FREEZ
#define RADS2RPM(x)   ((x)*9.549296585)
 Radian/s to RPM conversion.

#define RPM2RADS(x)   ((x)*.104719755)
 RPM to Radian/s conversion.

#define RAD2DEG(x)   ((x)*(180.0/PI))
 Radian to degree conversion.

#define DEG2RAD(x)   ((x)*(PI/180.0))
 Degree to radian conversion.

#define FEET2M(x)   ((x)*0.304801)
 Feet to meter conversion.

#define SIGN(x)   ((x) < 0 ? -1.0 : 1.0)
 Sign of the expression.

#define NORM0_2PI(x)
 Angle normalization between 0 and 2 * PI.

#define NORM_PI_PI(x)
 Angle normalization between -PI and PI.

#define DIST(x1, y1, x2, y2)   sqrt(((x1) - (x2)) * ((x1) - (x2)) + ((y1) - (y2)) * ((y1) - (y2)))
 Distance between two points.

#define MAX_MOD_ITF   10
 Maximum number of interface in one DLL.

#define GFPARM_PARAMETER   0
 Parameter file.

#define GFPARM_TEMPLATE   1
 Template file.

#define GFPARM_PARAM_STR   "param"
#define GFPARM_TEMPL_STR   "template"
#define GFPARM_MODIFIABLE   1
 Parameter file allowed to be modified.

#define GFPARM_WRITABLE   2
 Parameter file allowed to be saved on disk.

#define GFPARM_RMODE_STD   0x01
 if handle already openned return it

#define GFPARM_RMODE_REREAD   0x02
 reread the parameters from file and release the previous ones

#define GFPARM_RMODE_CREAT   0x04
 Create the file if doesn't exist.

#define GFPARM_RMODE_PRIVATE   0x08
#define GFPARM_MMODE_SRC   1
 use ref and modify existing parameters with tgt

#define GFPARM_MMODE_DST   2
 use tgt and verify ref parameters

#define GFPARM_MMODE_RELSRC   4
 release ref after the merge

#define GFPARM_MMODE_RELDST   8
 release tgt after the merge

#define GfTrace   printf
#define GfError   printf
#define GfOut   printf
#define GF_MEAN_MAX_VAL   5
#define GF_TAILQ_HEAD(name, type)
 Head type definition.

#define GF_TAILQ_ENTRY(type)
 Entry in structure.

#define GF_TAILQ_FIRST(head)   ((head)->tqh_first)
 First element of a TAILQ.

#define GF_TAILQ_NEXT(elm, field)   ((elm)->field.tqe_next)
 Next element of a TAILQ.

#define GF_TAILQ_END(head)   NULL
 End of a TAILQ.

#define GF_TAILQ_LAST(head, headname)   (*(((struct headname *)((head)->tqh_last))->tqh_last))
 Last element of a TAILQ.

#define GF_TAILQ_PREV(elm, headname, field)   (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
 Previous element of a TAILQ.

#define GF_TAILQ_INIT(head)
 Head initialization (Mandatory).

#define GF_TAILQ_INIT_ENTRY(elm, field)
 Entry initialization (optionnal if inserted).

#define GF_TAILQ_INSERT_HEAD(head, elm, field)
 Insert an element at the head.

#define GF_TAILQ_INSERT_TAIL(head, elm, field)
 Insert an element at the tail.

#define GF_TAILQ_INSERT_AFTER(head, listelm, elm, field)
 Insert an element after another element.

#define GF_TAILQ_INSERT_BEFORE(listelm, elm, field)
 Insert an element before another element.

#define GF_TAILQ_REMOVE(head, elm, field)
 Remove an element.

#define START_PROFILE(a)
#define STOP_PROFILE(a)
#define STOP_ACTIVE_PROFILES()
#define PRINT_PROFILE()
#define GF_HASH_TYPE_STR   0
 String key based hash table.

#define GF_HASH_TYPE_BUF   1
 Memory buffer key based hash table.


Typedefs

typedef float tdble
 Floating point type used in TORCS.

typedef int(* tfModPrivInit )(int index, void *)
 initialisation of the function table

typedef ModInfo tModInfo
 Module information structure.

typedef int(* tfModInfo )(tModInfo *)
typedef int(* tfModShut )(void)
typedef ModList tModList
 list of module interfaces

typedef FList tFList
 List of (DLL) files for a Directory.

typedef void(* tfDirfreeUserData )(void *)
 Function to call for releasing the user data associated with file entry.

typedef void(* tfHashFree )(void *)
 Function to call for releasing the user data associated with hash table.


Functions

void GfInit (void)
int GfModLoad (unsigned int gfid, char *dllname, tModList **modlist)
 Load the specified DLLs.

int GfModLoadDir (unsigned int gfid, char *dir, tModList **modlist)
 Load the DLLs in the specified directory.

int GfModUnloadList (tModList **modlist)
 Unload the DLLs of a list.

int GfModInfo (unsigned int gfid, char *filename, tModList **modlist)
 Get the generic information of the specified DLL.

int GfModInfoDir (unsigned int gfid, char *dir, int level, tModList **modlist)
 Get the generic module information of the DLLs of the specified directory.

int GfModFreeInfoList (tModList **modlist)
 Free the info contained in the specified list.

tFListGfDirGetList (char *dir)
 Get the list of files of a given directory.

void GfDirFreeList (tFList *list, tfDirfreeUserData freeUserData)
 Free a directory list.

void * GfParmReadFile (const char *file, int mode)
 Read a configuration file.

int GfParmWriteFile (const char *file, void *handle, char *name)
 Write a configuration file.

char * GfParmGetName (void *handle)
 Get the pararmeters name.

char * GfParmGetFileName (void *handle)
 Get the pararmeters file name.

char * GfParmGetStr (void *handle, char *path, char *key, char *deflt)
 Get string parameter value.

char * GfParmGetCurStr (void *handle, char *path, char *key, char *deflt)
 Get a string parameter in a config file.

int GfParmSetStr (void *handle, char *path, char *key, char *val)
 Set a string parameter in a config file.

int GfParmSetCurStr (void *handle, char *path, char *key, char *val)
 Set a string parameter in a config file.

tdble GfParmGetNum (void *handle, char *path, char *key, char *unit, tdble deflt)
 Get a numerical parameter in a config file.

tdble GfParmGetCurNum (void *handle, char *path, char *key, char *unit, tdble deflt)
 Get a numerical parameter in a config file.

int GfParmSetNum (void *handle, char *path, char *key, char *unit, tdble val)
 Set a numerical parameter in a config file.

int GfParmSetCurNum (void *handle, char *path, char *key, char *unit, tdble val)
 Set a numerical parameter in a config file.

void GfParmClean (void *handle)
 Clean all the parameters of a set.

void GfParmReleaseHandle (void *handle)
 Clean the parms and release the handle without updating the file.

tdble GfParmUnit2SI (char *unit, tdble val)
 Convert a value in "units" into SI.

tdble GfParmSI2Unit (char *unit, tdble val)
 Convert a value in SI to "units".

int GfParmCheckHandle (void *ref, void *tgt)
 Check a parameter set against another.

void * GfParmMergeHandles (void *ref, void *tgt, int mode)
 Merge two parameters sets into a new one.

int GfParmGetNumBoundaries (void *handle, char *path, char *key, tdble *min, tdble *max)
 Get the min and max of a numerical parameter.

int GfParmGetEltNb (void *handle, char *path)
 Count the number of section elements of a list.

int GfParmListSeekFirst (void *handle, char *path)
 Seek the first section element of a list.

int GfParmListSeekNext (void *handle, char *path)
 Go to the next section element in the current list.

char * GfParmListGetCurEltName (void *handle, char *path)
 Get The current element name.

int GfParmListClean (void *handle, char *path)
 Remove all the section elements of a list.

double GfTimeClock (void)
 Get the time in seconds.

char * GfGetTimeStr (void)
tdble gfMean (tdble v, tMeanVal *pvt, int n, int w)
void gfMeanReset (tdble v, tMeanVal *pvt)
char * GetLocalDir (void)
void SetLocalDir (char *buf)
char * GetLibDir (void)
void SetLibDir (char *buf)
char * GetDataDir (void)
void SetDataDir (char *buf)
int GetSingleTextureMode (void)
void SetSingleTextureMode (void)
int GfNearestPow2 (int x)
void * GfHashCreate (int type)
 Create a new hash table.

int GfHashAddStr (void *hash, char *key, void *data)
 Add an element with a string key to a hash table.

void * GfHashRemStr (void *hash, char *key)
 Remove an element with a string key from a hash table.

void * GfHashGetStr (void *hash, char *key)
 Get the user data associated with a string key.

void GfHashAddBuf (void *hash, char *key, size_t sz, void *data)
 Add an element with a memory buffer key to a hash table.

void * GfHashRemBuf (void *hash, char *key, size_t sz)
 Remove an element with a memory buffer key from a hash table.

void * GfHashGetBuf (void *hash, char *key, size_t sz)
 Get the user data associated with a memory buffer key.

void GfHashRelease (void *hash, tfHashFree hashFree)
 Release a hash table.

void * GfHashGetFirst (void *hash)
 Get the first user data of a hash table.

void * GfHashGetNext (void *hash)
 Get the next user data of a hash table.


Variables

const double PI = 3.14159265358979323846
 PI.

const tdble G = 9.80665
 m/s/s


Define Documentation

#define DEG2RAD x   )     ((x)*(PI/180.0))
 

Degree to radian conversion.

#define DIST x1,
y1,
x2,
y2   )     sqrt(((x1) - (x2)) * ((x1) - (x2)) + ((y1) - (y2)) * ((y1) - (y2)))
 

Distance between two points.

#define FEET2M x   )     ((x)*0.304801)
 

Feet to meter conversion.

#define freez   FREEZ
 

#define FREEZ x   ) 
 

Value:

do {                            \
    if (x) {                                    \
        free(x);                                \
        x = 0;                                  \
    }                                           \
} while (0)

#define GF_HASH_TYPE_BUF   1
 

Memory buffer key based hash table.

#define GF_HASH_TYPE_STR   0
 

String key based hash table.

#define GF_MEAN_MAX_VAL   5
 

#define GfError   printf
 

#define GfOut   printf
 

#define GFPARM_MMODE_DST   2
 

use tgt and verify ref parameters

#define GFPARM_MMODE_RELDST   8
 

release tgt after the merge

#define GFPARM_MMODE_RELSRC   4
 

release ref after the merge

#define GFPARM_MMODE_SRC   1
 

use ref and modify existing parameters with tgt

#define GFPARM_MODIFIABLE   1
 

Parameter file allowed to be modified.

#define GFPARM_PARAM_STR   "param"
 

#define GFPARM_PARAMETER   0
 

Parameter file.

#define GFPARM_RMODE_CREAT   0x04
 

Create the file if doesn't exist.

#define GFPARM_RMODE_PRIVATE   0x08
 

#define GFPARM_RMODE_REREAD   0x02
 

reread the parameters from file and release the previous ones

#define GFPARM_RMODE_STD   0x01
 

if handle already openned return it

#define GFPARM_TEMPL_STR   "template"
 

#define GFPARM_TEMPLATE   1
 

Template file.

#define GFPARM_WRITABLE   2
 

Parameter file allowed to be saved on disk.

#define GfTrace   printf
 

#define MAX x,
y   )     ((x) > (y) ? (x) : (y))
 

#define MAX_MOD_ITF   10
 

Maximum number of interface in one DLL.

See also:
ModList

#define MIN x,
y   )     ((x) < (y) ? (x) : (y))
 

#define NORM0_2PI x   ) 
 

Value:

do {                                            \
        while ((x) > 2*PI) { (x) -= 2*PI; }     \
        while ((x) < 0) { (x) += 2*PI; }        \
} while (0)
Angle normalization between 0 and 2 * PI.

#define NORM_PI_PI x   ) 
 

Value:

do {                                            \
        while ((x) > PI) { (x) -= 2*PI; }       \
        while ((x) < -PI) { (x) += 2*PI; }      \
} while (0)
Angle normalization between -PI and PI.

 
#define PRINT_PROFILE  ) 
 

#define RAD2DEG x   )     ((x)*(180.0/PI))
 

Radian to degree conversion.

#define RADS2RPM x   )     ((x)*9.549296585)
 

Radian/s to RPM conversion.

#define RPM2RADS x   )     ((x)*.104719755)
 

RPM to Radian/s conversion.

#define SIGN x   )     ((x) < 0 ? -1.0 : 1.0)
 

Sign of the expression.

#define START_PROFILE a   ) 
 

 
#define STOP_ACTIVE_PROFILES  ) 
 

#define STOP_PROFILE a   ) 
 


Typedef Documentation

typedef void(* tfDirfreeUserData)(void*)
 

Function to call for releasing the user data associated with file entry.

typedef void(* tfHashFree)(void*)
 

Function to call for releasing the user data associated with hash table.

typedef struct FList tFList
 

List of (DLL) files for a Directory.

See also:
GfDirGetList

typedef int(* tfModInfo)(tModInfo *)
 

typedef int(* tfModPrivInit)(int index, void *)
 

initialisation of the function table

See also:
ModInfo

typedef int(* tfModShut)(void)
 

typedef struct ModInfo tModInfo
 

Module information structure.

typedef struct ModList tModList
 

list of module interfaces


Function Documentation

char* GetDataDir void   ) 
 

char* GetLibDir void   ) 
 

char* GetLocalDir void   ) 
 

int GetSingleTextureMode void   ) 
 

char* GfGetTimeStr void   ) 
 

void GfInit void   ) 
 

Here is the call graph for this function:

tdble gfMean tdble  v,
tMeanVal pvt,
int  n,
int  w
 

void gfMeanReset tdble  v,
tMeanVal pvt
 

int GfNearestPow2 int  x  ) 
 

void GfParmClean void *  parmHandle  ) 
 

Clean all the parameters of a set.

Parameters:
parmHandle Configuration handle
Returns:
0 if OK
-1 if Error

void* GfParmReadFile const char *  file,
int  mode
 

Read a configuration file.

Note:
Called by #gfInitThread
Parameters:
logHandle log handle
file name of the file to read or content if input is a buffer.
mode openning mode is a mask of: #GF_PARM_RMODE_STD #GF_PARM_RMODE_REREAD #GF_PARM_RMODE_CREAT #GF_PARM_RMODE_PRIVATE
Returns:
handle on the configuration data
0 if Error

void GfParmReleaseHandle void *  parmHandle  ) 
 

Clean the parms and release the handle without updating the file.

Note:
Called by #gfShutdownThread
Parameters:
logHandle log handle
parmHandle Configuration handle
Returns:
none

int GfParmWriteFile const char *  file,
void *  parmHandle,
char *  name
 

Write a configuration file.

Parameters:
parmHandle Configuration handle
file Name of the file to write (NULL if previously read file)
name Name of the parameters
Returns:
0 if OK
1 if Error

double GfTimeClock void   ) 
 

Get the time in seconds.

Returns:
Time in seconds since the start of the system

void SetDataDir char *  buf  ) 
 

void SetLibDir char *  buf  ) 
 

void SetLocalDir char *  buf  ) 
 

void SetSingleTextureMode void   ) 
 


Variable Documentation

const tdble G = 9.80665
 

m/s/s

const double PI = 3.14159265358979323846
 

PI.


Generated at Thu Feb 26 21:53:08 2004 for torcs by doxygen 1.3.3 written by Dimitri van Heesch, © 1997-1999
TORCS © Eric Espié 1999, 2002.