#include <storage/SDatabase.h>
SDatabase
is a local-only (non-Binder) convenience class that helps applications manage one or more references to a single open database. The underlying open database is a per-process singleton. Multiple instances of SDatabase
in the same process which refer to the same open database will increment a reference count on that database. When the last SDatabase
instance referring to a particular database is freed, that database is closed again.
DmOpenRef
with which standard Data Manager routines may be used.dmModeReadWrite
if you wish; however, no reader-writer locking of any kind is provided by SDatabase
, so you'll need to control concurrent access yourself. SDatabase
is purely a resource-management tool.SConcurrentDatabase
, which can perform reader-writer locking.
Public Member Functions | |
Database Access | |
Retrieve the database that was opened. | |
DatabaseID | DbID () const |
Get the database id for it. | |
DmOpenRef | GetOpenRef () const |
Retrieve the DmOpenRef for the open database. | |
Bookkeeping | |
Creation, destruction, etc. The non-trivial constructors will open the database requested, leaving it open until all SDatabase instances referring to it are destroyed.
Note that there is no default mode for DatabaseID database access, to prevent ambiguity with the type/creator constructor signature | |
bool | IsValid () const |
Equivalent to (StatusCheck()==errNone) . | |
SDatabase & | operator= (const SDatabase &o) |
Copy another SDatabase into this one. | |
SDatabase (const SDatabase &orig) | |
Increments the refcount on the database. | |
SDatabase (type_code dbType, type_code dbCreator, DmOpenModeType mode, DbShareModeType share) | |
Open a database by type and creator. | |
SDatabase (const char *dbName, type_code dbCreator, DmOpenModeType mode, DbShareModeType share) | |
Open a database by name and creator. | |
SDatabase (DatabaseID dbID, DmOpenModeType mode, DbShareModeType share) | |
Open a database by DatabaseID. | |
SDatabase () | |
Equivalent to (StatusCheck()==errNone) . | |
status_t | Status () const |
status_t | StatusCheck () const |
Data Mgr error, if any, associated with opening the database. | |
~SDatabase () | |
Equivalent to (StatusCheck()==errNone) . | |
Classes | |
class | PrvOpenDbAtom |
|
Equivalent to
|
|
Open a database by DatabaseID.
|
|
Open a database by name and creator.
|
|
Open a database by type and creator.
|
|
Increments the refcount on the database.
|
|
Equivalent to
|
|
Get the database id for it.
|
|
Retrieve the
|
|
Equivalent to
|
|
Copy another SDatabase into this one.
|
|
|
|
Data Mgr error, if any, associated with opening the database.
|