torcs - 1.2.2

src/libs/tgf/params.cpp File Reference


Detailed Description

This is the parameters manipulation API.

Author:
Eric Espie
Version:
Id
params.cpp,v 1.25 2004/02/06 23:08:53 torcs Exp

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <math.h>
#include <xmlparse.h>
#include <tgf.h>
#include <assert.h>

Include dependency graph for params.cpp:

Include dependency graph

Compounds

struct  param
 Parameter header structure. More...

struct  parmHandle
 Configuration handle structure. More...

struct  parmHeader
 Configuration header structure. More...

struct  parmOutput
 Ouput control structure. More...

struct  section
 Section header structure. More...

struct  within

Defines

#define LINE_SZ   1024
#define PARAM_CREATE   0x01
#define P_NUM   0
#define P_STR   1
#define PARM_MAGIC   0x20030815
#define PARM_HANDLE_FLAG_PRIVATE   0x01
#define PARM_HANDLE_FLAG_PARSE_ERROR   0x02

Functions

 GF_TAILQ_HEAD (withinHead, struct within)
 GF_TAILQ_HEAD (paramHead, struct param)
 GF_TAILQ_HEAD (sectionHead, struct section)
 GF_TAILQ_HEAD (parmHead, struct parmHandle)
void gfParamInit (void)
 Configuration initialization.

void GfParmShutdown (void)
 Configuration shutdown.

void * GfParmReadBuf (char *buffer)
 Read a configuration buffer.

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

int GfParmWriteBuf (void *handle, char *buf, int size)
 Write a configuration buffer.

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

void GfParmRemove (void *parmHandle, char *sectionName, char *paramName)
 Remove a parameter.

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

void GfParmReleaseHandle (void *parmHandle)
 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".

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

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

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.

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

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

char * GfParmGetStr (void *parmHandle, 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.

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 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.

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

int GfParmSetNumEx (void *handle, char *path, char *key, char *unit, tdble val, tdble min, tdble max)
 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.

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.


Define Documentation

#define LINE_SZ   1024
 

#define P_NUM   0
 

#define P_STR   1
 

#define PARAM_CREATE   0x01
 

#define PARM_HANDLE_FLAG_PARSE_ERROR   0x02
 

#define PARM_HANDLE_FLAG_PRIVATE   0x01
 

#define PARM_MAGIC   0x20030815
 


Function Documentation

GF_TAILQ_HEAD parmHead  ,
struct  parmHandle
 

GF_TAILQ_HEAD sectionHead  ,
struct  section
 

GF_TAILQ_HEAD paramHead  ,
struct  param
 

GF_TAILQ_HEAD withinHead  ,
struct  within
 

void gfParamInit void   ) 
 

Configuration initialization.

Returns:
none.

void GfParmClean void *  parmHandle  ) 
 

Clean all the parameters of a set.

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

void* GfParmReadBuf char *  buffer  ) 
 

Read a configuration buffer.

Parameters:
logHandle log handle
buf input buffer.
Returns:
handle on the configuration data
0 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

void GfParmRemove void *  parmHandle,
char *  sectionName,
char *  paramName
 

Remove a parameter.

Parameters:
parmHandle Configuration handle
sectionName Parameter section name
paramName Parameter name
Returns:
none

void GfParmShutdown void   ) 
 

Configuration shutdown.

Returns:
none

int GfParmWriteBuf void *  handle,
char *  buf,
int  size
 

Write a configuration buffer.

Parameters:
logHandle log handle
parmHandle Configuration handle
buf buffer to write the configuration
size buffer size
Returns:
0 if OK
1 if Error

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


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.