libcmdbm 0.2.0
MyBatis-like SQL mapping library for C99
Loading...
Searching...
No Matches
CMDBM_Database Struct Reference

A datasource: one database, its pool and its statements. More...

Data Fields

CMBool(* AddMapper )(CMDBM_Database *db, const char *mapperfile)
 Load one mapper file into this datasource.
 
CMBool(* AddMapperSet )(CMDBM_Database *db, const char *basepath, const char *filepattern, CMBool recursive)
 Load every mapper file matching a pattern.
 
CMBool(* SetMonitor )(CMDBM_Database *db, int interval)
 How often the mapper files are checked for changes.
 
void(* Destroy )(CMDBM_Database *db)
 Destroy the datasource, closing every connection it pooled.
 

Detailed Description

A datasource: one database, its pool and its statements.

Field Documentation

◆ AddMapper

CMBool(* CMDBM_Database::AddMapper) (CMDBM_Database *db, const char *mapperfile)

Load one mapper file into this datasource.

The statements of the file become available under "namespace.statement". Loading a path which is already loaded replaces it, statement by statement - which is what the reload monitor uses when a file changes on disk.

Parameters
dbThe datasource.
mapperfilePath of the XML mapper file.
Returns
CMFalse when the file cannot be read or is not a valid mapper, and then nothing of it is loaded.

◆ AddMapperSet

CMBool(* CMDBM_Database::AddMapperSet) (CMDBM_Database *db, const char *basepath, const char *filepattern, CMBool recursive)

Load every mapper file matching a pattern.

The set is remembered as a whole, so the reload monitor notices files which appear, change or disappear under basepath afterwards.

Parameters
dbThe datasource.
basepathDirectory to look in.
filepatternGlob pattern the file names must match, "*.xml" being the usual one.
recursiveWhether subdirectories are searched too.
Returns
CMTrue. Files which fail to parse are logged and skipped, and do not make the call fail.

◆ SetMonitor

CMBool(* CMDBM_Database::SetMonitor) (CMDBM_Database *db, int interval)

How often the mapper files are checked for changes.

Must be called before the datasource is handed to CMDBM_Context::AddDatabase, which is where the task is scheduled. Without it the interval is 30 seconds.

Parameters
dbThe datasource.
intervalSeconds between two checks.
Returns
CMTrue.

◆ Destroy

void(* CMDBM_Database::Destroy) (CMDBM_Database *db)

Destroy the datasource, closing every connection it pooled.

Only for a datasource which was never added to a context, or whose CMDBM_Context::AddDatabase failed: a context destroys the datasources it took over.

Parameters
dbThe datasource.

The documentation for this struct was generated from the following file: