TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
Parameter Data Handling API

Handling of data in parameter sets. More...

Collaboration diagram for Parameter Data Handling API:

Functions

void GfParmRemove (void *parmHandle, char *sectionName, char *paramName)
 Remove a parameter from a parameter set.
tdble GfParmUnit2SI (const char *unit, tdble val)
 Convert a value given in unit to SI.
tdble GfParmSI2Unit (const char *unit, tdble val)
 Convert a value from SI to given unit.
char * GfParmGetName (void *handle)
 Get the name property of the parameter set handle.
const char * GfParmGetStr (void *parmHandle, const char *path, const char *key, const char *deflt)
 Get a string parameter from the parameter set handle.
tdble GfParmGetNum (void *handle, const char *path, const char *key, const char *unit, tdble deflt)
 Get a numerical parameter from the parameter set handle.
int GfParmSetStr (void *handle, const char *path, const char *key, const char *val)
 Set a string parameter in the parameter set handle.
int GfParmSetNum (void *handle, const char *path, const char *key, const char *unit, tdble val)
 Set a numerical parameter in the parameter set handle.
int GfParmSetNumEx (void *handle, const char *path, const char *key, const char *unit, tdble val, tdble min, tdble max)
 Set a numerical parameter and its bounds, creating it if necessary.
int GfParmGetNumBoundaries (void *handle, const char *path, const char *key, tdble *min, tdble *max)
 Get the min and max of a numerical parameter from the parameter set handle.

Detailed Description

Handling of data in parameter sets.

Function Documentation

◆ GfParmGetName()

char * GfParmGetName ( void * handle)

Get the name property of the parameter set handle.

Parameters
[in]handleparameter set handle
Returns
Borrowed name; do not modify or free it despite the char* return type.
NULL if failed or not set
Note
The pointer returned is for immediate use, if you plan to keep the value for a long time, it is necessary to copy the string, because manipulating the handle will produce an incoherent pointer.

Definition at line 2192 of file params.cpp.

Here is the call graph for this function:

◆ GfParmGetNum()

tdble GfParmGetNum ( void * handle,
const char * path,
const char * key,
const char * unit,
tdble deflt )

Get a numerical parameter from the parameter set handle.

If the parameter does not exist the given default value is returned without unit conversion.

Parameters
[in]handleparameter set handle
[in]pathpath of the parameter
[in]keyparameter key name
[in]unitunit to convert the result to (NULL if SI is desired)
[in]defltFallback value already expressed in the requested unit.
Returns
Converted numeric value, or deflt unchanged if missing or not numeric.

Definition at line 2534 of file params.cpp.

Here is the call graph for this function:

◆ GfParmGetNumBoundaries()

int GfParmGetNumBoundaries ( void * handle,
const char * path,
const char * key,
tdble * min,
tdble * max )

Get the min and max of a numerical parameter from the parameter set handle.

Parameters
[in]handleparameter set handle
[in]pathpath of the parameter
[in]keyparameter key name
[out]minNon-NULL destination for the minimum in SI units.
[out]maxNon-NULL destination for the maximum in SI units.
Returns
0 Ok
-1 if the parameter is missing or not numeric; both outputs remain unchanged.

Definition at line 3268 of file params.cpp.

Here is the call graph for this function:

◆ GfParmGetStr()

const char * GfParmGetStr ( void * parmHandle,
const char * path,
const char * key,
const char * deflt )

Get a string parameter from the parameter set handle.

If the parameter does not yet exist the given default is returned.

Parameters
[in]parmHandleparameter set handle
[in]pathpath of the parameter
[in]keyparameter key name
[in]defltBorrowed fallback string, possibly NULL.
Returns
Borrowed parameter value, or deflt if missing, empty or not a string. No allocation or ownership transfer occurs; do not free the result.
Note
The pointer returned is for immediate use, if you plan to keep the value for a long time, it is necessary to copy the string, because removing the attribute will produce an incoherent pointer.

Definition at line 2453 of file params.cpp.

Here is the call graph for this function:

◆ GfParmRemove()

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

Remove a parameter from a parameter set.

Not declared in the public tgf.h API. Public callers can remove an attribute with GfParmSetStr(handle, path, key, NULL), including a numeric attribute.

Parameters
[in,out]parmHandleParameter set to modify.
[in]sectionNameSection path.
[in]paramNameParameter name. Empty sections and their empty ancestors are pruned after removal (also when the attribute was already absent).

Definition at line 1829 of file params.cpp.

Here is the call graph for this function:

◆ GfParmSetNum()

int GfParmSetNum ( void * handle,
const char * path,
const char * key,
const char * unit,
tdble val )

Set a numerical parameter in the parameter set handle.

If the parameter does not yet exist it is created. The value is assigned to the value, min and max.

Parameters
[in,out]handleparameter set handle
[in]pathpath of the parameter
[in]keyparameter key name
[in]unitUnit of the supplied value (NULL or empty for SI); copied for later serialization. The value is converted to SI for storage.
[in]valvalue to set
Returns
0 ok
-11 if the parameter could not be created; -1 for a reported bad handle.

Definition at line 2737 of file params.cpp.

Here is the call graph for this function:

◆ GfParmSetNumEx()

int GfParmSetNumEx ( void * handle,
const char * path,
const char * key,
const char * unit,
tdble val,
tdble min,
tdble max )

Set a numerical parameter and its bounds, creating it if necessary.

Replaces the existing type, value and bounds. Does not validate min <= max or clamp val into that range; callers must supply consistent values.

Parameters
[in,out]handleparameter set handle
[in]pathpath of the parameter
[in]keyparameter key name
[in]unitUnit of val, min and max (NULL or empty for SI). All three are converted to SI; a copy of the unit is retained for serialization.
[in]valvalue to set
[in]minmin value to set
[in]maxmax value to set
Returns
0 ok
-1 error

Definition at line 2783 of file params.cpp.

Here is the call graph for this function:

◆ GfParmSetStr()

int GfParmSetStr ( void * handle,
const char * path,
const char * key,
const char * val )

Set a string parameter in the parameter set handle.

Creates missing sections and the attribute, or replaces its value/type. Copies val; the string's within constraint is not checked. NULL or empty val removes the attribute and prunes empty sections/ancestors instead. Copy a borrowed value before passing it back to a setter for the same attribute, which frees the old storage first.

Parameters
[in,out]handleparameter set handle
[in]pathpath of the parameter
[in]keyparameter key name
[in]valString to copy (NULL or empty to remove the attribute).
Returns
0 ok
-1 error

Definition at line 2623 of file params.cpp.

Here is the call graph for this function:

◆ GfParmSI2Unit()

tdble GfParmSI2Unit ( const char * unit,
tdble val )

Convert a value from SI to given unit.

Parameters
[in]unitUnit expression to convert to; NULL or empty leaves val unchanged.
[in]valvalue in SI units to be converted to unit
Returns
converted value in unit
See also
GfParmUnit2SI

Definition at line 2133 of file params.cpp.

Here is the call graph for this function:

◆ GfParmUnit2SI()

tdble GfParmUnit2SI ( const char * unit,
tdble val )

Convert a value given in unit to SI.

The units can be combined with "/", "." and "2" (square), e.g. "lbf/in", "N.m", "kg.m/s2". After the first slash, all remaining factors are denominator factors, including those separated by dots. There is no dimensional validation: unknown tokens have conversion factor 1.

Parameters
[in]unitUnit expression for val; NULL or empty leaves val unchanged. Tokens are case-sensitive except for explicitly listed aliases and must fit in the internal 256-byte token buffer, including its terminator.
[in]valvalue in unit
Returns
the value converted to SI
Note
The supported units are:
  • feet or ft converted to m
  • inches,inch or in converted to m
  • km converted to m
  • cm converted to m
  • mm converted to m
  • lbs or lb converted to kg
  • mph or MPH converted to m/s
  • slug or slugs converted to kg
  • h,hour or hours converted to s
  • day or days converted to s
  • kPa or MPa converted to Pa
  • PSI or psi converted to Pa
  • deg converted to rad
  • rpm or RPM converted to rad/s
  • percent or % divided by 100
  • lbf converted to N
See also
GfParmSI2Unit

Definition at line 2079 of file params.cpp.

Here is the call graph for this function: