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

dependency.h

Go to the documentation of this file.
00001 /*!\file dependency.h
00002         \brief Declerations for the calculations of Dependencies.
00003         Should be included wherever dependencies are used.*/
00004 
00005 #ifndef __DEPENDENCY_H__
00006 #define __DEPENDENCY_H__
00007 
00008 #include "pmstring.h"
00009 #include "packageversion.h"
00010 #include <vector>
00011 
00012 //!Small class used as bitmask for dependency flags.
00013 /*!Used as a bitmask to set various flags about a particular DependentPackage.
00014    Should only really be needed by DependentPackage class.*/
00015 class DependType
00016 {
00017         public:
00018                 DependType();                   //!<Constructor.
00019                 void Reset();                   //!<Reset All the flags to eDisable.
00020         
00021                 long EqualTo : 2;               //!<DependentPackage is equal to a particular version.
00022                 long NewerThan : 2;             //!<DependentPackage has to be newer than this version.
00023                 long OlderThan : 2;             //!<DependentPackage has to be older than this version.
00024                 long Blocker : 2;               //!<DependentPackage is not allowed to be installed.
00025                 long StartsWith : 2;    //!<DependentPackage starts with the version - i.e. 1.2 matches 1.2.2 here.
00026                 long AnyRevision : 2;   //!<Any portage revision of a DependentPackage.
00027 };
00028 
00029 /*!Enum to set the above flags.*/
00030 enum DependencyTypeStatus
00031 {
00032         eDisable = 0,   //!<Disable the flag.
00033         eEnable                 //!<Enable the flag.
00034 };
00035 
00036 /*!Enum to say what kind of dependency a dependency is.*/
00037 enum DependencyStage
00038 {
00039         eCompile = 0,   //!<Needs to be installed before compile.
00040         eRun,                   //!<Needs to be instlled before running.
00041         ePost                   //!<Needs to be installed AFTER the package is installed.
00042 };
00043 
00044 //!Class to encapsulate the smaller dependency atoms.
00045 /*!A dependent package details the string used to describe a package,
00046   and also the flags used to describe the dependency. Used to describe all
00047   the atoms except the || dependency. We have multiple dependent packages
00048   to deal with that.*/
00049 class DependentPackage
00050 {
00051         public:
00052                 DependentPackage(PMString dependency);          //!<Constructor that processes the normal portage syntax.
00053                 
00054                 bool operator== (DependentPackage param);                                                               //!<Checks for equality between DependentPackage.
00055                 bool operator!= (DependentPackage param);                                                               //!<Checks for non-equality between DependentPackage.
00056                 bool AtomExamine(PMString category, PMString name, PMString version);   //!<Checks to see if the strings satisfy a dependency.
00057                 
00058                 PMString package;               //!<The string detailing the package that the dependency involves.
00059                 DependType dependType;  //!<The flags regarding the dependency.
00060 };
00061 
00062 //!A Dependency encapsulates all the depedency atoms.
00063 /*!A Dependency is the class that wraps the traditionally thought of dependency.
00064   Details all of portage's dependencys, including || ( or ) dependencies and
00065   all other forms of dependency. Its worth noting that std::vector<DependentPackage> packages
00066   can only contain multiple DependentPackage's if an || dependency is used.*/
00067 class Dependency
00068 {
00069         public:
00070                 Dependency();                                                                                                   //!<Default Constructor.
00071                 Dependency(DependencyStage passedStage);                                                //!<Constructor to set the stage.
00072                 Dependency(PMString dependency, DependencyStage passedStage);   //!<Create the dependency using the traditional portage string.
00073         
00074                 bool operator== (Dependency param);                                     //!<The equality operator.
00075                 bool operator!= (Dependency param);                                     //!<The non equality operator.
00076                 void AddDependency(PMString dependency);                        //!<Populate the packages with the dependencies detailed in dependency.
00077                 void ClearDependencies();                                                       //!<Clear all DependentPackage's.
00078                 bool SatisfyDependency(PackageVersion version);         //!<Check if the version satisfies the dependency.
00079                 bool SatisfyDependency(PMString packageString);         //!<Check if the package string satisfies the dependency.
00080                 
00081                 std::vector<DependentPackage> packages; //!<Only contains multiple packages for ||.
00082                 DependencyStage stage;                                  //!<The stage the dependency has to be installed by.
00083 };
00084 
00085 //!Encapsulates ALL of the dependencies of a particular PackageVersion.
00086 /*!Encapsulates ALL of the dependencies of a particular PackageVersion. Does
00087    this by having a vector of dependencies. Encapsulates all three types of
00088    dependencies also, compile, run and post time.*/
00089 class PackageVersionDependencies
00090 {
00091         public:
00092                 PackageVersionDependencies(std::vector<PMString> useFlags);                                                                                                     //!<Constructor.
00093                 PackageVersionDependencies(PMString compile, PMString run, PMString post,std::vector<PMString> useFlags);       //!<Construct and Add passed dependencies.
00094                 PackageVersionDependencies(PackageVersion version,std::vector<PMString> useFlags);                                                      //!<Construct and Add version's dependencies.
00095                 ~PackageVersionDependencies();                                                                                                                                                          //!<Destructor.
00096         
00097                 bool DependenciesMet(std::vector<PackageVersion> versions);             //!<Do versions meet the dependencies?.
00098                 void AddDependencies(PMString depends,DependencyStage stage);   //!<Add the dependencies given.
00099                 void SetFlags(std::vector<PMString> useFlags);                                  //!<Set _useFlags.
00100                 void AddFlag(PMString flag);                                                                    //!<Add a useFlag.
00101         
00102                 std::vector<Dependency> dependencies;   //!<The dependencies.
00103         
00104         protected:
00105                 std::vector<PMString> _useFlags;                                        //!<The useFlags.
00106                 void _AddDependency(Dependency depend);                         //!<Add the dependency, dont allow duplicates.
00107                 std::vector<PMString>::iterator _BypassBrackets(std::vector<PMString>::iterator currentLocation,std::vector<PMString>::iterator endLocation);
00108                                                                                                                         //!<Return an iterator to where we have gone out of the selected bracket.
00109 };
00110 
00111 #endif

Generated on Wed May 25 15:29:54 2005 for Package Management System for Gentoo Linux by  doxygen 1.4.1