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

PkgIdent.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |
00003 |                      __   __    ____ _____ ____                      |
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |
00005 |                       \ V / _` \___ \ | |   __) |                    |
00006 |                        | | (_| |___) || |  / __/                     |
00007 |                        |_|\__,_|____/ |_| |_____|                    |
00008 |                                                                      |
00009 |                               core system                            |
00010 |                                                        (C) SuSE GmbH |
00011 \----------------------------------------------------------------------/
00012 
00013   File:       PkgIdent.h
00014 
00015   Author:     Michael Andres <ma@suse.de>
00016   Maintainer: Michael Andres <ma@suse.de>
00017 
00018   Purpose:
00019 
00020 /-*/
00021 #ifndef PkgIdent_h
00022 #define PkgIdent_h
00023 
00024 #include <iosfwd>
00025 #include <string>
00026 #include <functional>
00027 
00028 #include <y2pm/PkgName.h>
00029 #include <y2pm/PkgEdition.h>
00030 #include <y2pm/PkgArch.h>
00031 #include <y2pm/PMSolvablePtr.h>
00032 
00034 //
00035 //      CLASS NAME : PkgIdent
00039 class PkgIdent {
00040 
00041   friend std::ostream & operator<<( std::ostream & str, const PkgIdent & obj );
00042 
00043   private:
00044 
00045     PkgName    _name;
00046     PkgEdition _edition;
00047     PkgArch    _arch;
00048 
00049   public:
00050 
00051     PkgIdent() {}
00052 
00053     PkgIdent( constPMSolvablePtr slv_r );
00054 
00055     PkgIdent( const PkgName & name_r, const PkgEdition & edition_r, const PkgArch & arch_r )
00056       : _name( name_r )
00057       , _edition( edition_r )
00058       , _arch( arch_r )
00059     {}
00060 
00061     virtual ~PkgIdent() {}
00062 
00063   public:
00064 
00065     const PkgName &     name()    const { return _name; }
00066     const PkgEdition &  edition() const { return _edition; }
00067     const std::string & version() const { return _edition.version(); }
00068     const std::string & release() const { return _edition.release(); }
00069     const PkgArch &     arch()    const { return _arch; }
00070 
00074     std::string nameEd() const { return _name.asString() + '-' + _edition.asString(); }
00075 
00079     std::string nameEdArch() const { return nameEd() + '.' + _arch.asString(); }
00080 };
00081 
00083 //
00084 //
00085 //      METHOD NAME : std::less<PkgIdent>::operator()
00086 //      METHOD TYPE : bool
00087 //
00088 //      Order to be used by associative std::container (set/map):
00089 //      Lexicographic by _name, _edition then _arch.
00090 //
00091 template<>
00092 inline bool std::less<PkgIdent>::operator()( const PkgIdent & lhs, const PkgIdent & rhs ) const
00093 {
00094   int r = lhs.name()->compare( rhs.name() );
00095   if ( r != 0 )
00096     return( r < 0 );
00097   r = lhs.version().compare( rhs.version() );
00098   if ( r != 0 )
00099     return( r < 0 );
00100   r = lhs.release().compare( rhs.release() );
00101   if ( r != 0 )
00102     return( r < 0 );
00103   return( lhs.arch()->compare( rhs.arch() ) < 0 );
00104 
00105 }
00106 
00108 
00109 #endif // PkgIdent_h

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