zypp::target::rpm::librpmDb Class Reference

Manage access to librpm database. More...

#include <librpmDb.h>

Inheritance diagram for zypp::target::rpm::librpmDb:

zypp::base::ReferenceCounted NonCopyable List of all members.

Public Types

typedef intrusive_ptr< librpmDbPtr
typedef intrusive_ptr< const
librpmDb
constPtr

Public Member Functions

virtual ~librpmDb ()
 Destructor.
const Pathnameroot () const
const PathnamedbPath () const
shared_ptr< RpmExceptionerror () const
 Return any database error.
bool valid () const
bool empty () const
void * dont_call_it () const
 Dont call it ;) It's for development and testing only.
virtual std::ostream & dumpOn (std::ostream &str) const
 Dump debug info.

Static Public Member Functions

static bool globalInit ()
 Initialize lib librpm (read configfiles etc.
static std::string expand (const std::string &macro_r)
static std::string stringPath (const Pathname &root_r, const Pathname &sub_r)
static const PathnamedefaultRoot ()
static const PathnamedefaultDbPath ()
static void dbAccess (const Pathname &root_r, const Pathname &dbPath_r)
 Adjust access to the given database location, making it the new default location on success.
static void dbAccess (librpmDb::constPtr &ptr_r)
 Same as &ref dbAccess(), but returns the database handle if avaialble, otherwise NULL.
static unsigned dbRelease (bool force_r=false)
 If there are no outstanding references to the database (e.g.
static unsigned blockAccess ()
 Blocks further access to rpmdb.
static void unblockAccess ()
 Allow access to rpmdb e.g.
static bool isBlocked ()
static std::ostream & dumpState (std::ostream &str)
 Dump debug info.

Protected Member Functions

 librpmDb (const Pathname &root_r, const Pathname &dbPath_r, bool readonly_r)
 Private constructor! librpmDb objects are to be created via static interface only.
virtual void unref_to (unsigned refCount_r) const
 Trigger from Rep, after refCount was decreased.

Static Private Member Functions

static void dbAccess (librpmDb::Ptr &ptr_r)
 INTENTIONALLY UNDEFINED<

because of bug in Ptr classes which allows implicit conversion from librpmDb::Ptr to librpmDb::constPtr.

static librpmDbnewLibrpmDb (Pathname root_r, Pathname dbPath_r, bool readonly_r)
 For internal use.
static void dbAccess ()
 Access the database at the current default location.

Private Attributes

D_d

Static Private Attributes

static Pathname _defaultRoot
 Current root directory for all operations.
static Pathname _defaultDbPath
 Current directory (below root) that contains the rpmdb.
static librpmDb::constPtr _defaultDb
 Current rpmdb handle.
static bool _dbBlocked
 Wheter access is blocked (no _defaultDb will be available).

Classes

class  D
 librpmDb internal database handle More...
class  db_const_iterator
 Subclass to retrieve database content. More...
class  DbDirInfo
 Collect info about what kind of rpmdb seems to be present by looking at paths and filenames. More...

Detailed Description

Manage access to librpm database.

Definition at line 35 of file librpmDb.h.


Member Typedef Documentation

typedef intrusive_ptr<librpmDb> zypp::target::rpm::librpmDb::Ptr
 

Definition at line 38 of file librpmDb.h.

typedef intrusive_ptr<const librpmDb> zypp::target::rpm::librpmDb::constPtr
 

Definition at line 39 of file librpmDb.h.


Constructor & Destructor Documentation

zypp::target::rpm::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.

Definition at line 358 of file librpmDb.cc.

Referenced by newLibrpmDb().

zypp::target::rpm::librpmDb::~librpmDb  )  [virtual]
 

Destructor.

Closes rpmdb.

Definition at line 371 of file librpmDb.cc.

References _d.


Member Function Documentation

static void zypp::target::rpm::librpmDb::dbAccess librpmDb::Ptr ptr_r  )  [static, private]
 

INTENTIONALLY UNDEFINED<

because of bug in Ptr classes which allows implicit conversion from librpmDb::Ptr to librpmDb::constPtr.

Currently we don't want to provide non const handles, as the database is opened READONLY.

Exceptions:
RpmException 

librpmDb * zypp::target::rpm::librpmDb::newLibrpmDb Pathname  root_r,
Pathname  dbPath_r,
bool  readonly_r
[static, private]
 

For internal use.

Pointer returned should immediately be wrapped into librpmDb::Ptr.

Exceptions:
RpmException 

Definition at line 176 of file librpmDb.cc.

References zypp::filesystem::Pathname::absolute(), globalInit(), librpmDb(), ZYPP_CAUGHT, ZYPP_RETHROW, and ZYPP_THROW.

Referenced by dbAccess().

void zypp::target::rpm::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.

Exceptions:
RpmException 

Definition at line 239 of file librpmDb.cc.

References _dbBlocked, _defaultDb, _defaultDbPath, _defaultRoot, newLibrpmDb(), and ZYPP_THROW.

Referenced by zypp::target::rpm::librpmDb::db_const_iterator::D::D(), and dbAccess().

bool zypp::target::rpm::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.

Definition at line 123 of file librpmDb.cc.

References ERR, MIL, and OUTVAL.

Referenced by expand(), and newLibrpmDb().

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

Returns:
librpm macro expansion.

Definition at line 156 of file librpmDb.cc.

References globalInit().

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

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

Definition at line 124 of file librpmDb.h.

References zypp::filesystem::Pathname::asString().

Referenced by dbAccess().

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

Returns:
Current root directory for all operations.

Definition at line 133 of file librpmDb.h.

References _defaultRoot.

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

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

Definition at line 138 of file librpmDb.h.

References _defaultDbPath.

void zypp::target::rpm::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.

Exceptions:
RpmException 

Definition at line 209 of file librpmDb.cc.

References _defaultDb, _defaultDbPath, _defaultRoot, zypp::filesystem::Pathname::absolute(), dbAccess(), MIL, stringPath(), and ZYPP_THROW.

void zypp::target::rpm::librpmDb::dbAccess librpmDb::constPtr 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.

Exceptions:
RpmException 

Definition at line 257 of file librpmDb.cc.

References _defaultDb, dbAccess(), ZYPP_CAUGHT, and ZYPP_RETHROW.

unsigned zypp::target::rpm::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.

Definition at line 277 of file librpmDb.cc.

References _defaultDb, and DBG.

Referenced by blockAccess(), zypp::target::rpm::RpmDb::initDatabase(), zypp::target::rpm::RpmDb::run_rpm(), and unref_to().

unsigned zypp::target::rpm::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.

Definition at line 311 of file librpmDb.cc.

References _dbBlocked, dbRelease(), and MIL.

Referenced by zypp::target::rpm::RpmDb::closeDatabase(), and zypp::target::rpm::RpmDb::initDatabase().

void zypp::target::rpm::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.

Definition at line 324 of file librpmDb.cc.

References _dbBlocked, and MIL.

Referenced by zypp::target::rpm::RpmDb::initDatabase().

static bool zypp::target::rpm::librpmDb::isBlocked  )  [inline, static]
 

Returns:
Whether database access is blocked.

Definition at line 205 of file librpmDb.h.

References _dbBlocked.

static std::ostream& zypp::target::rpm::librpmDb::dumpState std::ostream &  str  )  [static]
 

Dump debug info.

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

Trigger from Rep, after refCount was decreased.

Reimplemented from zypp::base::ReferenceCounted.

Definition at line 382 of file librpmDb.cc.

References dbRelease().

const Pathname & zypp::target::rpm::librpmDb::root  )  const
 

Returns:
This handles root directory for all operations.

Definition at line 395 of file librpmDb.cc.

References _d, and zypp::target::rpm::librpmDb::D::_root.

Referenced by zypp::target::rpm::librpmDb::D::D().

const Pathname & zypp::target::rpm::librpmDb::dbPath  )  const
 

Returns:
This handles directory that contains the rpmdb.

Definition at line 406 of file librpmDb.cc.

References _d, and zypp::target::rpm::librpmDb::D::_dbPath.

shared_ptr< RpmException > zypp::target::rpm::librpmDb::error  )  const
 

Return any database error.

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

Definition at line 417 of file librpmDb.cc.

References _d, and zypp::target::rpm::librpmDb::D::_error.

Referenced by valid().

bool zypp::target::rpm::librpmDb::valid  )  const [inline]
 

Returns:
Whether

Definition at line 277 of file librpmDb.h.

References error().

Referenced by empty().

bool zypp::target::rpm::librpmDb::empty  )  const
 

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

Definition at line 428 of file librpmDb.cc.

References valid().

void * zypp::target::rpm::librpmDb::dont_call_it  )  const
 

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

Definition at line 439 of file librpmDb.cc.

References _d, and zypp::target::rpm::librpmDb::D::_db.

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

Dump debug info.

Reimplemented from zypp::base::ReferenceCounted.


Member Data Documentation

Pathname zypp::target::rpm::librpmDb::_defaultRoot [static, private]
 

Current root directory for all operations.

(initialy /)

Definition at line 65 of file librpmDb.h.

Referenced by dbAccess(), and defaultRoot().

Pathname zypp::target::rpm::librpmDb::_defaultDbPath [static, private]
 

Current directory (below root) that contains the rpmdb.

(initialy /var/lib/rpm)

Definition at line 71 of file librpmDb.h.

Referenced by dbAccess(), and defaultDbPath().

librpmDb::constPtr zypp::target::rpm::librpmDb::_defaultDb [static, private]
 

Current rpmdb handle.

Definition at line 76 of file librpmDb.h.

Referenced by dbAccess(), and dbRelease().

bool zypp::target::rpm::librpmDb::_dbBlocked [static, private]
 

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

Definition at line 81 of file librpmDb.h.

Referenced by blockAccess(), dbAccess(), isBlocked(), and unblockAccess().

D& zypp::target::rpm::librpmDb::_d [private]
 

Definition at line 235 of file librpmDb.h.

Referenced by dbPath(), dont_call_it(), error(), root(), and ~librpmDb().


The documentation for this class was generated from the following files:
Generated on Thu Jul 6 00:07:35 2006 for zypp by  doxygen 1.4.6