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

PkgRelation.h

Go to the documentation of this file.
00001 #ifndef _PkgRelation_h
00002 #define _PkgRelation_h
00003 
00004 #include <list>
00005 
00006 #include <y2pm/PkgName.h>
00007 #include <y2pm/PkgEdition.h>
00008 #include <y2pm/PMSolvablePtr.h>
00009 
00010 class PkgRelation {
00011         PkgName    _name;
00012         rel_op     _op;
00013         PkgEdition _edition;
00014         bool       _isprereq;  // whether this is a prerequirement
00015   public:
00016         PkgRelation()
00017         : _op(NONE), _isprereq(false)
00018         {}
00019 
00020         PkgRelation( const PkgName& n )
00021         : _name(n), _op(NONE), _isprereq(false)
00022         {}
00023 
00024         PkgRelation( const PkgName& n, rel_op o, const PkgEdition& e )
00025         : _name(n), _op(o), _edition(e), _isprereq(false)
00026         {}
00027         // default copy constructor and assigment are ok
00028 
00029         const PkgName&    name()    const { return _name; }
00030         rel_op            op()      const { return _op; }
00031         const PkgEdition& edition() const { return _edition; }
00032 
00033         // return true if this relation holds given a package (providing itself)
00034         // or another relation (which is a provides relation)
00035         bool matches( constPMSolvablePtr pkg ) const;
00036         bool matches( const PkgRelation & rel ) const;
00037 
00038         bool operator==( const PkgRelation& r2 ) const {
00039                 return( _name == r2._name && _op == r2._op &&
00040                                 (_op == NONE || _edition == r2._edition) );
00041         }
00042         bool operator!=( const PkgRelation& r2 ) const { return !operator==(r2); }
00043 
00047         std::string asString() const;
00048 
00052         void setPreReq(bool yes) { _isprereq = yes; }
00053 
00057         bool isPreReq() const { return _isprereq; }
00058 
00062         bool isFileRel() const { return( _name->size() && _name->at( 0 ) == '/' ); }
00063 
00067         friend std::ostream& operator<<(std::ostream&, const PkgRelation&);
00068 
00069       public:
00070 
00075         static std::string toString( const PkgRelation & t );
00076 
00081         static PkgRelation fromString( std::string s );
00082 
00086         static std::list<PkgRelation> parseRelations( const std::string & data_tr );
00087 
00088       private:
00089 
00090         static rel_op string2DepCompare( const std::string & str_tr );
00091 };
00092 
00093 #endif  /* _PkgRelation_h */
00094 
00095 
00096 // Local Variables:
00097 // tab-width: 4
00098 // End:

Generated on Mon Sep 12 21:52:13 2005 for yast2-packagemanager by  doxygen 1.4.4