CapMatch.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_CAPMATCH_H
00013 #define ZYPP_CAPMATCH_H
00014 
00015 #include <iosfwd>
00016 
00018 namespace zypp
00019 { 
00020 
00022   //
00023   //    CLASS NAME : CapMatch
00024   //
00035   class CapMatch
00036   {
00037     enum Result { NOMATCH, MATCH, IRRELEVANT };
00038 
00039   public:
00040 
00041     CapMatch( bool val_r )
00042     : _result( val_r ? MATCH : NOMATCH )
00043     {}
00044 
00045     static const CapMatch yes;
00046     static const CapMatch no;
00047     static const CapMatch irrelevant;
00048 
00049     friend bool operator==( const CapMatch & lhs, const CapMatch & rhs )
00050     { return lhs._result == rhs._result; }
00051 
00052     friend bool operator!=( const CapMatch & lhs, const CapMatch & rhs )
00053     { return lhs._result != rhs._result; }
00054 
00055     friend CapMatch operator!( const CapMatch & lhs )
00056     {
00057       if ( lhs._result == CapMatch::IRRELEVANT )
00058         return lhs;
00059       return !(lhs._result == CapMatch::MATCH);
00060     }
00061 
00062     friend CapMatch operator&&( const CapMatch & lhs, const CapMatch & rhs )
00063     {
00064       if ( lhs._result == CapMatch::IRRELEVANT )
00065         return rhs;
00066       if ( rhs._result == CapMatch::IRRELEVANT )
00067         return lhs;
00068       return    (lhs._result == CapMatch::MATCH)
00069              && (rhs._result == CapMatch::MATCH);
00070     }
00071 
00072     friend CapMatch operator||( const CapMatch & lhs, const CapMatch & rhs )
00073     {
00074       if ( lhs._result == CapMatch::IRRELEVANT )
00075         return rhs;
00076       if ( rhs._result == CapMatch::IRRELEVANT )
00077         return lhs;
00078       return    (lhs._result == CapMatch::MATCH)
00079              || (rhs._result == CapMatch::MATCH);
00080     }
00081 
00082     friend std::ostream & operator<<( std::ostream & str, const CapMatch & obj );
00083 
00084   private:
00085     CapMatch()
00086     : _result( IRRELEVANT )
00087     {}
00088 
00089     Result _result;
00090   };
00092 
00094   std::ostream & operator<<( std::ostream & str, const CapMatch & obj );
00095 
00097 } // namespace zypp
00099 #endif // ZYPP_CAPMATCH_H

Generated on Thu Jul 6 00:07:20 2006 for zypp by  doxygen 1.4.6