Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

librpmDb Class Reference

Manage access to librpm database. More...

#include <librpmDb.h>

Inheritance diagram for librpmDb:

CountedRep Rep List of all members.

Public Types

typedef InstTargetError Error

Public Member Functions

virtual ~librpmDb ()
const Pathnameroot () const
const PathnamedbPath () const
PMError error () const
bool valid () const
bool empty () const
void * dont_call_it () const
virtual std::ostream & dumpOn (std::ostream &str) const

Static Public Member Functions

bool globalInit ()
std::string expand (const std::string &macro_r)
std::string stringPath (const Pathname &root_r, const Pathname &sub_r)
const PathnamedefaultRoot ()
const PathnamedefaultDbPath ()
PMError dbAccess (const Pathname &root_r, const Pathname &dbPath_r)
PMError dbAccess (constlibrpmDbPtr &ptr_r)
unsigned dbRelease (bool force_r=false)
unsigned blockAccess ()
void unblockAccess ()
bool isBlocked ()
std::ostream & dumpState (std::ostream &str)

Protected Member Functions

 librpmDb (const Pathname &root_r, const Pathname &dbPath_r, bool readonly_r)
virtual void unref_to (unsigned refCount_r) const

Private Member Functions

 REP_BODY (librpmDb)

Static Private Member Functions

PMError dbAccess (librpmDbPtr &ptr_r)
librpmDbnewLibrpmDb (Pathname root_r, Pathname dbPath_r, bool readonly_r, PMError &err_r)
PMError dbAccess ()

Private Attributes

D_d

Static Private Attributes

Pathname _defaultRoot
Pathname _defaultDbPath
constlibrpmDbPtr _defaultDb
bool _dbBlocked

Detailed Description

Manage access to librpm database.


Member Typedef Documentation

typedef InstTargetError librpmDb::Error
 

Default error class


Constructor & Destructor Documentation

librpmDb::librpmDb const Pathname root_r,
const Pathname dbPath_r,
bool  readonly_r
[protected]
 

Private constructor! librpmDb objects are to be created via static interface only.

librpmDb::~librpmDb  )  [virtual]
 

Destructor. Closes rpmdb.


Member Function Documentation

unsigned librpmDb::blockAccess  )  [static]
 

Blocks further access to rpmdb. Basically the same as dbRelease( true ), but subsequent calls to dbAccess will fail returning E_RpmDB_access_blocked.

Returns:
The number of outstandig references to the database, 0 if if database was physically closed.

PMError librpmDb::dbAccess constlibrpmDbPtr &  ptr_r  )  [static]
 

Same as &ref dbAccess(), but returns the database handle if avaialble, otherwise NULL. This creates an external reference, thus it should not be used longer than necessary. Be prepared that the handle might become invalid (see dbRelease) later.

Returns:
PMError

PMError librpmDb::dbAccess const Pathname root_r,
const Pathname dbPath_r
[static]
 

Adjust access to the given database location, making it the new default location on success. No relative Pathnames are allowed.

It's not possible to access a database while access is blocked (see blockAccess), but valid Pathnames provided will be stored as new default location.

It's not allowed to switch to another location while a database is accessed. Use dbRelease to force releasing the database first.

Returns:
PMError

PMError librpmDb::dbAccess  )  [static, private]
 

Access the database at the current default location. If necessary (eg. after dbRelease), the database is opened. This just creates the internal handle. Once the handle is passed to e.g. some db_const_iterator, the database will be closed if the last outstanding reference goes out of scope. If no external reference is created, you'll have to explicitly call dbRelease to close the database.

Returns:
PMError

PMError librpmDb::dbAccess librpmDbPtr &  ptr_r  )  [static, private]
 

INTENTIONALLY UNDEFINED<> because of bug in Ptr classes which allows implicit conversion from librpmDbPtr to constlibrpmDbPtr. Currently we don't want to provide non const handles, as the database is opened READONLY.

const Pathname & librpmDb::dbPath  )  const
 

Returns:
This handles directory that contains the rpmdb.

unsigned librpmDb::dbRelease bool  force_r = false  )  [static]
 

If there are no outstanding references to the database (e.g. by db_const_iterator), the database is closed. Subsequent calls to dbAccess may however open the database again.

If forced, the internal reference is dropped and it will look like the database was closed. But physically the database will be closed after all outstanding references are gone.

Returns:
The number of outstandig references to the database, 0 if if database was physically closed.

const Pathname& librpmDb::defaultDbPath  )  [inline, static]
 

Returns:
Current directory (below root) that contains the rpmdb.

const Pathname& librpmDb::defaultRoot  )  [inline, static]
 

Returns:
Current root directory for all operations.

void * librpmDb::dont_call_it  )  const
 

Dont call it ;) It's for development and testing only.

ostream & librpmDb::dumpOn std::ostream &  str  )  const [virtual]
 

Dump debug info.

Reimplemented from CountedRep.

ostream & librpmDb::dumpState std::ostream &  str  )  [static]
 

Dump debug info.

bool librpmDb::empty  )  const
 

Returns:
True if handle is valid and database is empty.

PMError librpmDb::error  )  const
 

Return any database error. Usg. if the database was blocked by calling dbRelease(true) or blockAccess.

std::string librpmDb::expand const std::string &  macro_r  )  [static]
 

Returns:
librpm macro expansion.

bool librpmDb::globalInit  )  [static]
 

Initialize lib librpm (read configfiles etc.). It's called on demand but you may call it anytime.

Returns:
Whether librpm is initialized.

bool librpmDb::isBlocked  )  [inline, static]
 

Returns:
Whether database access is blocked.

librpmDb * librpmDb::newLibrpmDb Pathname  root_r,
Pathname  dbPath_r,
bool  readonly_r,
PMError err_r
[static, private]
 

For internal use. Pointer returned should immediately be wrapped into librpmDbPtr.

librpmDb::REP_BODY librpmDb   )  [private]
 

const Pathname & librpmDb::root  )  const
 

Returns:
This handles root directory for all operations.

std::string librpmDb::stringPath const Pathname root_r,
const Pathname sub_r
[inline, static]
 

Returns:
String '(root_r)sub_r' used in debug output.

void librpmDb::unblockAccess  )  [static]
 

Allow access to rpmdb e.g. after blockAccess. Subsequent calls to dbAccess will perform.

NOTE: Initially we're in blocked mode. So you must call unblockAccess unblockAccess at least once. Othwise nothing will happen.

Returns:
The number of outstandig references to the database, 0 if if database was physically closed.

void librpmDb::unref_to unsigned  refCount_r  )  const [protected, virtual]
 

Trigger from Rep, after refCount was decreased.

Reimplemented from Rep.

bool librpmDb::valid  )  const [inline]
 

Returns:
Whether


Member Data Documentation

D& librpmDb::_d [private]
 

bool librpmDb::_dbBlocked [static, private]
 

Wheter access is blocked (no _defaultDb will be available).

constlibrpmDbPtr librpmDb::_defaultDb [static, private]
 

Current rpmdb handle.

Pathname librpmDb::_defaultDbPath [static, private]
 

Current directory (below root) that contains the rpmdb. (initialy /var/lib/rpm)

Pathname librpmDb::_defaultRoot [static, private]
 

Current root directory for all operations. (initialy /)


The documentation for this class was generated from the following files:
Generated on Fri Nov 9 14:30:32 2007 for yast2-packagemanager by doxygen 1.3.6