Deepsolver
Public Types | Public Member Functions
Deepsolver::AbstractPkgBackEnd Class Reference

The abstract package back-end interface. More...

Inheritance diagram for Deepsolver::AbstractPkgBackEnd:
Deepsolver::RpmBackEnd

List of all members.

Public Types

enum  { EpochNever, EpochIfNonZero, EpochAlways }
typedef std::shared_ptr
< AbstractPkgBackEnd
Ptr

Public Member Functions

 AbstractPkgBackEnd ()
 The default constructor.
virtual std::string combineNameAndVer (const std::string &name, const std::string &ver) const =0
 Combines the package name and the package version into one string.
virtual
AbstractInstalledPkgIterator::Ptr 
enumInstalledPkg () const =0
 Creates an instance of an iterator over the set of installed packages.
virtual std::string getDesignation (const PkgBase &pkg, int epochMode) const =0
 Constructs the string designation of the provided package.
virtual std::string getDesignation (const NamedPkgRel &rel) const =0
 Constructs the string designation of the package relation.
virtual void initialize ()=0
 Prepares package back-end for any operations.
virtual std::string makeVer (int epoch, const std::string &ver, const std::string &release, int epochMode) const =0
 Constructs a version designating string.
virtual std::string makeVer (const PkgBase &pkg, int epochMode) const =0
 Constructs the string designating the package version.
virtual bool matches (const NamedPkgRel &rel, const Pkg &pkg) const =0
 Checks if the package suits to the relation.
virtual bool matches (const NamedPkgRel &rel, const NamedPkgRel &provide) const =0
 Checks if the provide entry suits to the relation (named form)
virtual bool matches (const IdPkgRel &rel, const IdPkgRel &provide) const =0
 Checks if the provide entry suits to the relation (IDs form)
virtual void readPkgFile (const std::string &fileName, PkgFile &pkgFile) const =0
 Reads header information from package file on disk.
virtual bool theSamePkg (const PkgBase &pkg1, const PkgBase &pkg2) const =0
 Checks if two instances represent the same package.
virtual bool transaction (const StringVector &toInstall, const StringVector &toRemove, const StringToStringMap &toUpgrade, const StringToStringMap &toDowngrade)=0
 Performs install/remove transaction with given packages.
virtual bool validPkgFileName (const std::string &fileName) const =0
 Checks if provided file name is a proper package name.
virtual bool validSourcePkgFileName (const std::string &fileName) const =0
 Checks if provided file name is a proper source package name.
virtual int verCmp (const std::string &ver1, const std::string &ver2) const =0
 Compares two version strings.
virtual bool verEqual (const std::string &ver1, const std::string &ver2) const =0
 Checks the equality of two version values.
virtual bool verGreater (const std::string &ver1, const std::string &ver2) const =0
 Checks if one version is newer than another.
virtual bool verOverlap (const VerSubset &ver1, const VerSubset &ver2) const =0
 Overlaps two version ranges.
virtual ~AbstractPkgBackEnd ()
 The destructor.

Detailed Description

This abstract interface isolates any functions of an particular package library like rpm, dpkg or any other. They can be treated as back-ends for Deepsolver itself. Although all methods has strict declaration they semantics can be not exactly the same due to differences in package libraries behaviour. So every developer and user should be very careful on any attempt to add new library support. The first real implementation of this class was for librpm, so all dependent code has unpremeditated influence of this library.

See also:
RpmBackEnd

Member Function Documentation

virtual std::string Deepsolver::AbstractPkgBackEnd::combineNameAndVer ( const std::string &  name,
const std::string &  ver 
) const [pure virtual]
Parameters:
[in]nameThe package name
[in]verThe package version
Returns:
The combined package string

Implemented in Deepsolver::RpmBackEnd.

virtual AbstractInstalledPkgIterator::Ptr Deepsolver::AbstractPkgBackEnd::enumInstalledPkg ( ) const [pure virtual]
Returns:
The iterator over the set of installed packages

Implemented in Deepsolver::RpmBackEnd.

virtual std::string Deepsolver::AbstractPkgBackEnd::getDesignation ( const PkgBase pkg,
int  epochMode 
) const [pure virtual]
Parameters:
[in]pkgThe package to construct string designation for
[in]Theepoch including mode (can be EpochNever, EpochIfNonZero or EpochAlways)
Returns:
The constructed package designation

Implemented in Deepsolver::RpmBackEnd.

virtual std::string Deepsolver::AbstractPkgBackEnd::getDesignation ( const NamedPkgRel rel) const [pure virtual]
Parameters:
[in]relThe package relation to construct designation for
Returns:
The constructed package relation designation

Implemented in Deepsolver::RpmBackEnd.

virtual void Deepsolver::AbstractPkgBackEnd::initialize ( ) [pure virtual]

This method should be called before performing any operations with particular package library. For safety reasons it is assumed that invocation is needed for every created instance of the back-end but actually it is not always the case. For example, if RpmBackEnd is used, this method may be called only once using any instance.

Implemented in Deepsolver::RpmBackEnd.

virtual std::string Deepsolver::AbstractPkgBackEnd::makeVer ( int  epoch,
const std::string &  ver,
const std::string &  release,
int  epochMode 
) const [pure virtual]
Parameters:
[in]epochThe version epoch
[inver The package version
[in]The package release
[in]Theepoch including mode (can be EpochNever, EpochIfNonZero or EpochAlways)
Returns:
The constructed version string

Implemented in Deepsolver::RpmBackEnd.

virtual std::string Deepsolver::AbstractPkgBackEnd::makeVer ( const PkgBase pkg,
int  epochMode 
) const [pure virtual]
Parameters:
[in]pkgThe package to construct version string for
[in]Theepoch including mode (can be EpochNever, EpochIfNonZero or EpochAlways)
Returns:
The version string for the provided package

Implemented in Deepsolver::RpmBackEnd.

virtual bool Deepsolver::AbstractPkgBackEnd::matches ( const NamedPkgRel rel,
const Pkg pkg 
) const [pure virtual]
Parameters:
[in]relThe relation
[in]pkgThe package to check for
Returns:
Non-zero if the package matches the relation and zero otherwise

Implemented in Deepsolver::RpmBackEnd.

virtual bool Deepsolver::AbstractPkgBackEnd::matches ( const NamedPkgRel rel,
const NamedPkgRel provide 
) const [pure virtual]
Parameters:
[in]relThe relation to check with
[in]provideThe provide entry to check
Returns:
Non-zero if the provide entry matches the relation

Implemented in Deepsolver::RpmBackEnd.

virtual bool Deepsolver::AbstractPkgBackEnd::matches ( const IdPkgRel rel,
const IdPkgRel provide 
) const [pure virtual]
Parameters:
[in]relThe relation to check with
[in]provideThe provide entry to check
Returns:
Non-zero if the provide entry matches the relation

Implemented in Deepsolver::RpmBackEnd.

virtual void Deepsolver::AbstractPkgBackEnd::readPkgFile ( const std::string &  fileName,
PkgFile pkgFile 
) const [pure virtual]
Parameters:
[in]fileNameThe name of the file to read data from
[out]pkgFileThe object to save retrieved data to

Implemented in Deepsolver::RpmBackEnd.

virtual bool Deepsolver::AbstractPkgBackEnd::theSamePkg ( const PkgBase pkg1,
const PkgBase pkg2 
) const [pure virtual]
Parameters:
[in]pkg1The first package to compare
[in]pkg2The second package to compare
Returns:
Non-zero if they represent the same package or zero otherwise

Implemented in Deepsolver::RpmBackEnd.

virtual bool Deepsolver::AbstractPkgBackEnd::transaction ( const StringVector &  toInstall,
const StringVector &  toRemove,
const StringToStringMap &  toUpgrade,
const StringToStringMap &  toDowngrade 
) [pure virtual]

This method gives a way to make desired changes in operating system state. With it everybody can perform a transaction containing any installation, removing, upgrading and downgrading tasks. The main restriction is a requirement that all package dependencies and conflicts must be satisfied. The package to install must be provided with their file names, packages to remove by their names (without a version or any other additional information), packages to upgrade and downgrade must be specified by a string-to-string map from package names to file names.

If a transaction fails this method returns zero. The state of OS after failed transaction is unspecified and package back-end dependent.

Parameters:
[in]toInstallThe file names vector with packages to install
[in]toRemoveThe file names vector with packages to remove
[in]toUpgradeThe map from package names to file names with packages to upgrade
[in]toDowngradeThe map from package names to file names with packages to downgrade
Returns:
Non-zero if a transaction is completed successfully or zero otherwise
Exceptions:
PackageBackEndException

Implemented in Deepsolver::RpmBackEnd.

virtual bool Deepsolver::AbstractPkgBackEnd::validPkgFileName ( const std::string &  fileName) const [pure virtual]
Parameters:
[in]fileNameThe file name to check
Returns:
Non-zero if provided file name is a valid package name and zero otherwise

Implemented in Deepsolver::RpmBackEnd.

virtual bool Deepsolver::AbstractPkgBackEnd::validSourcePkgFileName ( const std::string &  fileName) const [pure virtual]
Parameters:
[in]fileNameThe file name to check
Returns:
Non-zero if provided file name is a valid source package name and zero otherwise

Implemented in Deepsolver::RpmBackEnd.

virtual int Deepsolver::AbstractPkgBackEnd::verCmp ( const std::string &  ver1,
const std::string &  ver2 
) const [pure virtual]
Parameters:
[in]ver1The first version value to compare
[in]ver2The second version value to compare
Returns:
The integer value less than zero if ver1 less than ver2, greater than zero if ver1 greater than ver2 and zero otherwise

Implemented in Deepsolver::RpmBackEnd.

virtual bool Deepsolver::AbstractPkgBackEnd::verEqual ( const std::string &  ver1,
const std::string &  ver2 
) const [pure virtual]
Parameters:
[in]ver1The first string to compare
[in]ver2The second string to compare
Returns:
Non-zero if two strings designate the same value or zero otherwise

Implemented in Deepsolver::RpmBackEnd.

virtual bool Deepsolver::AbstractPkgBackEnd::verGreater ( const std::string &  ver1,
const std::string &  ver2 
) const [pure virtual]
Parameters:
[in]ver1The first string to compare
[in]ver2The second string to compare
Returns:
Non-zero if ver1 is greater than ver2 or zero if ver1 is less or equal ver2

Implemented in Deepsolver::RpmBackEnd.

virtual bool Deepsolver::AbstractPkgBackEnd::verOverlap ( const VerSubset ver1,
const VerSubset ver2 
) const [pure virtual]

This method is not symmetric. If second version range has no epoch indication it assumes the first one may have any. So if this method is used for requires processing, the require entry can go only as second argument.

Parameters:
[in]ver1The first version range to intersect
[in]ver2The second version range to intersect
Returns:
Non-zero if intersection is not empty and zero otherwise

Implemented in Deepsolver::RpmBackEnd.