SDatabase Class Reference

#include <storage/SDatabase.h>

List of all members.


Detailed Description

Convenience class for opening and managing reference on a Data Manager database.

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.

Use GetOpenRef() to recover a DmOpenRef with which standard Data Manager routines may be used.
Note:
You may open a database dmModeWrite or 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.
See also:
DataMgr.h (for Data Manager routines), BDatabaseStore (a slightly more complex database wrapper for reading resources).
Todo:
Develop a concurrent version, 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).
SDatabaseoperator= (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


Constructor & Destructor Documentation

SDatabase  ) 
 

Equivalent to (StatusCheck()==errNone).

SDatabase DatabaseID  dbID,
DmOpenModeType  mode,
DbShareModeType  share
 

Open a database by DatabaseID.

SDatabase const char *  dbName,
type_code  dbCreator,
DmOpenModeType  mode,
DbShareModeType  share
 

Open a database by name and creator.

See also:
DmFindDatabase()

SDatabase type_code  dbType,
type_code  dbCreator,
DmOpenModeType  mode,
DbShareModeType  share
 

Open a database by type and creator.

SDatabase const SDatabase orig  ) 
 

Increments the refcount on the database.

~SDatabase  ) 
 

Equivalent to (StatusCheck()==errNone).


Member Function Documentation

DatabaseID DbID  )  const
 

Get the database id for it.

DmOpenRef GetOpenRef  )  const
 

Retrieve the DmOpenRef for the open database.

bool IsValid  )  const
 

Equivalent to (StatusCheck()==errNone).

SDatabase & operator= const SDatabase o  ) 
 

Copy another SDatabase into this one.

status_t Status  )  const
 

Deprecated:
Use StatusCheck() instead.

status_t StatusCheck  )  const
 

Data Mgr error, if any, associated with opening the database.


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