Brandon Creighton's patch: A lot of refactoring, but separates global object creation from initialization. Allows for logging of database initialization failures.

git-svn-id: http://wush.net/svn/range/software/public/openbts/trunk@3165 19bc5d8c-e614-43d4-8b26-e1612bc8e597
This commit is contained in:
kurtis.heimerl
2012-02-10 01:45:41 +00:00
parent 8903e165b4
commit 8ee3d8cc72
13 changed files with 53 additions and 26 deletions

View File

@@ -63,18 +63,20 @@ static const char* createTMSITable = {
TMSITable::TMSITable(const char* wPath)
int TMSITable::open(const char* wPath)
{
int rc = sqlite3_open(wPath,&mDB);
if (rc) {
LOG(EMERG) << "Cannot open TMSITable database at " << wPath << ": " << sqlite3_errmsg(mDB);
sqlite3_close(mDB);
mDB = NULL;
return;
return 1;
}
if (!sqlite3_command(mDB,createTMSITable)) {
LOG(EMERG) << "Cannot create TMSI table";
return 1;
}
return 0;
}

View File

@@ -53,7 +53,12 @@ class TMSITable {
public:
TMSITable(const char*wPath);
/**
Open the database connection.
@param wPath Path to sqlite3 database file.
@return 0 if the database was successfully opened and initialized; 1 otherwise
*/
int open(const char* wPath);
~TMSITable();

View File

@@ -550,10 +550,10 @@ bool TransactionEntry::terminationRequested()
TransactionTable::TransactionTable()
void TransactionTable::init()
// This assumes the main application uses sdevrandom.
:mIDCounter(random())
{
mIDCounter = random();
}

View File

@@ -305,10 +305,9 @@ class TransactionTable {
public:
/**
Create a transaction table.
@param path Path fto sqlite3 database file.
Initialize thetransaction table with a random mIDCounter value.
*/
TransactionTable();
void init();
~TransactionTable();