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

The root object: the datasources of an application and the sessions which use them. More...

Data Fields

CMBool(* AddDatabase )(CMDBM_Context *context, CMDBM_Database *database)
 Start a datasource and take it over.
 
CMDBM_Session *(* GetSession )(CMDBM_Context *context)
 Open a session on this context.
 
void(* Destroy )(CMDBM_Context *context)
 Destroy the context and every datasource in it.
 

Detailed Description

The root object: the datasources of an application and the sessions which use them.

Field Documentation

◆ AddDatabase

CMBool(* CMDBM_Context::AddDatabase) (CMDBM_Context *context, CMDBM_Database *database)

Start a datasource and take it over.

This is where a datasource comes to life: the module is initialized, the initial connections are opened, the mapper files are read and the reload task is scheduled.

Parameters
contextThe context.
databaseThe datasource, built by CMDBM_DatabaseCreate. On success the context owns it and destroys it with itself; on failure it stays the caller's, to be destroyed through CMDBM_Database::Destroy.
Returns
CMFalse when the datasource cannot be initialized - a client library which will not load, or connection parameters no connection can be opened with.

◆ GetSession

CMDBM_Session *(* CMDBM_Context::GetSession) (CMDBM_Context *context)

Open a session on this context.

Cheap: no connection is borrowed until a statement runs. Sessions are not shared between threads, and each is closed through CMDBM_Session::Close.

Parameters
contextThe context.
Returns
The session, never NULL in practice.

◆ Destroy

void(* CMDBM_Context::Destroy) (CMDBM_Context *context)

Destroy the context and every datasource in it.

Close the sessions first: a session outliving its context holds connections of pools which no longer exist.

Parameters
contextThe context.

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