My Project
Static Public Member Functions | Static Protected Attributes | Friends | List of all members
ParaInfoCenter::CICDBManager Class Reference

it represents both a database entity and a database manager the static functions are for database manager basically use OpenDBEntity and CloseDBEntity; this class has two alias class ParaEngine::DBEntity and ParaEngine::CDBManager More...

#include <ICDBManager.h>

Static Public Member Functions

static PE_CORE_DECL DBEntityGetDB (const char16_t *name)
 get the database with a name or file path More...
 
static PE_CORE_DECL DBEntityOpenDBEntity ()
 
static PE_CORE_DECL DBEntityOpenDBEntity (const char16_t *dbname)
 only load if not loaded before. More...
 
static PE_CORE_DECL DBEntityOpenDBEntity (const char *dbname)
 
static PE_CORE_DECL DBEntityOpenDBEntity (const char16_t *name, const char16_t *dbname)
 
static PE_CORE_DECL DBEntityOpenDBEntity (const char *name, const char *dbname)
 
static PE_CORE_DECL bool CloseDBEntity (DBEntity *pEntity)
 close the database entity, one should never use a closed entity any more. More...
 
static PE_CORE_DECL void Finalize ()
 delete all db managers
 
static PE_CORE_DECL void StaticInit ()
 

Static Protected Attributes

static vector< DBpair > m_DBpool
 all databases
 
static ParaEngine::mutex m_mutex
 this makes all db query thread-safe
 

Friends

class CICMapTrace
 
class CICRoot
 
class CICGenManager
 

Detailed Description

it represents both a database entity and a database manager the static functions are for database manager basically use OpenDBEntity and CloseDBEntity; this class has two alias class ParaEngine::DBEntity and ParaEngine::CDBManager

code sample.
we suppose you already know how to open a database using CICGenManager, and the open operation is done before this sample CICRecordSet rs=new CICRecordSet("SELECT * FROM maptrace"); a new recordset always is BOF and EOF if (rs->IsBOF()) { NextRow go to the next row of the return, here we go to the first row return of NextRow is CICRecordSet::SOK if ok. it is CICRecordSet::SEOF if the next row is beyond the end of the rows rs->NextRow(); the sql string is not executed before the first call to NextRow } if (rs->IsEOF()) { nothing returns from the sql string, or the string is not correct throw; } while(!rs->IsEOF()){ remember to use (*rs)[x] to access the x-th column of the row if rs is (CICRecordSet *) here an auto-datatype-casting is done internally, so you don't need to care about it. int time=(*rs)[0]; double x,y,z; x=(*rs)[1]; y=(*rs)[2]; z=(*rs)[3]; const char id=(*rs)[4]; warning: do not put (*rs)[x] directly into the following function, you should always assign them to a clear type variable before using them because the type-casting function must know which type it is casting. OUTPUT_LOG("time = %d x=%f y=%f z=%f id=%s",time,x,y,z,id); rs->NextRow(); } when end of the recordset, the operation is automatically finalize so sqlite3_finalize is not needed.

Member Function Documentation

§ CloseDBEntity()

bool CICDBManager::CloseDBEntity ( DBEntity pEntity)
static

close the database entity, one should never use a closed entity any more.

Parameters
pEntity

§ GetDB()

DBEntity * CICDBManager::GetDB ( const char16_t *  name)
static

get the database with a name or file path

Parameters
name
Returns

§ OpenDBEntity() [1/2]

DBEntity * CICDBManager::OpenDBEntity ( const char16_t *  dbname)
static

only load if not loaded before.

Parameters
dbnamepath of the database file
Returns
database entity

§ OpenDBEntity() [2/2]

DBEntity * CICDBManager::OpenDBEntity ( const char16_t *  name,
const char16_t *  dbname 
)
static
Parameters
namealias name
dbnamedatabase path
Returns
database entity

The documentation for this class was generated from the following files: