Re #307 Added GfParmShutdown, GfParmRemoveSection and renamed GfParmRemove to GfParmExistsSection (Warning: this revision does not compile)

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3562 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 7aa602429202a8ad7eb314567b8d165c7ce1f8a4
Former-commit-id: 2616e8b3526f997efae3fef8ff20e7f2c9a73ab3
This commit is contained in:
pouillot 2011-05-14 15:45:41 +00:00
parent 691299895a
commit f7a7800687
4 changed files with 45 additions and 7 deletions

View file

@ -1762,6 +1762,37 @@ GfParmRemove (void *parmHandle, const char *sectionName, const char *paramName)
}
/** Remove a section with given path.
@ingroup conf
@param handle handle of parameters
@param path path of section
@return 0 Ok
<br>-1 Error
*/
int
GfParmRemoveSection (void *handle, const char *path)
{
struct parmHandle *parmHandle = (struct parmHandle *)handle;
struct parmHeader *conf;
struct section *section;
if ((parmHandle == NULL) || (parmHandle->magic != PARM_MAGIC)) {
GfLogError ("GfParmRemoveSection: bad handle (%p)\n", parmHandle);
return -1;
}
conf = parmHandle->conf;
section = (struct section *)GfHashGetStr (conf->sectionHash, path);
if (!section) {
GfLogError ("GfParmRemoveSection: Section \"%s\" not found\n", path);
return -1;
}
removeSection (conf, section);
return 0;
}
static void parmClean (struct parmHeader *conf)
{
struct section *section;
@ -1868,8 +1899,9 @@ void GfParmReleaseHandle (void *parmHandle)
static void
evalUnit (char *unit, tdble *dest, int invert)
{
// TODO: Use a static std::map<const char*, tdble> to make this code faster ?
tdble coeff = 1.0;
// SI units.
if (strcmp(unit, "m") == 0) return;
if (strcmp(unit, "N") == 0) return;
@ -1882,7 +1914,7 @@ evalUnit (char *unit, tdble *dest, int invert)
if ((strcmp(unit, "l") == 0) || (strcmp(unit, "litre") == 0)) return;
// Non-SI units conversion
// (please keep the order of the following tests : it is staticstically optimized).
// (please keep the order of the following tests : it is statistically optimized).
if (strcmp(unit, "deg") == 0) {
coeff = (float) (M_PI/180.0); /* rad */
} else if ((strcmp(unit, "lbs") == 0) || (strcmp(unit, "lb") == 0)) {
@ -2168,10 +2200,10 @@ GfParmGetEltNb (void *handle, const char *path)
@ingroup paramsdata
@param handle handle of parameters
@param path path of section
@return 0 if doesn't exist, not 0 otherwise.
@return 0 if doesn't exist, 1 otherwise.
*/
int
GfParmExists (void *handle, const char *path)
GfParmExistsSection (void *handle, const char *path)
{
struct parmHandle *parmHandle = (struct parmHandle *)handle;
struct parmHeader *conf;
@ -2186,7 +2218,7 @@ GfParmExists (void *handle, const char *path)
section = (struct section *)GfHashGetStr (conf->sectionHash, path);
return section != 0;
return section != 0 ? 1 : 0;
}

View file

@ -473,6 +473,9 @@ void GfShutdown(void)
// Shutdown the active profilers and dump the report if any.
GfProfStopActiveProfiles();
GfProfPrintReport();
// Shutdown the params system.
GfParmShutdown();
}
/** Restart the gaming framework (restart the current process).

View file

@ -367,7 +367,8 @@ TGF_API void *GfParmMergeHandles(void *ref, void *tgt, int mode);
TGF_API int GfParmGetNumBoundaries(void *handle, char *path, char *key, tdble *min, tdble *max);
TGF_API void GfParmRemove(void *handle, const char *path, const char *key);
TGF_API int GfParmExists(void *handle, const char *path);
TGF_API int GfParmRemoveSection (void *handle, const char *path);
TGF_API int GfParmExistsSection(void *handle, const char *path);
TGF_API int GfParmGetEltNb(void *handle, const char *path);
TGF_API int GfParmListSeekFirst(void *handle, const char *path);
TGF_API int GfParmListSeekNext(void *handle, const char *path);
@ -380,6 +381,8 @@ TGF_API void GfParmSetVariable(void *handle, char const *path, char const *key,
TGF_API void GfParmRemoveVariable(void *handle, char const *path, char const *key);
TGF_API tdble GfParmGetVariable(void *handle, char const *path, char const *key);
TGF_API void GfParmShutdown (void);
/********************************************************************************
* Log/Trace Interface *
* - Write formated string messages at run-time to the log stream, *

View file

@ -332,7 +332,7 @@ PutPlayerSettings(unsigned index)
GraphHdle = GfParmReadFile(pszGraphFileName, GFPARM_RMODE_REREAD);
}
if (GfParmExists(GraphHdle, drvDispSecPath)) { // Change section name.
if (GfParmExistsSection(GraphHdle, drvDispSecPath)) { // Change section name.
GfParmListRenameElt(GraphHdle, GR_SCT_DISPMODE, pszOldDispName, player->dispName());
}