libzypp  10.5.0
SelFilters.h
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_UI_SELFILTERS_H
00013 #define ZYPP_UI_SELFILTERS_H
00014 
00015 #include <string>
00016 
00017 #include "zypp/base/Functional.h"
00018 #include "zypp/ui/Selectable.h"
00019 
00021 namespace zypp
00022 { 
00023 
00024   namespace ui
00025   { 
00026 
00027     namespace selfilter
00028     { 
00029 
00030       typedef std::unary_function<Selectable::constPtr,bool> SelectableFilterFunctor;
00031 
00033       struct ByKind : public SelectableFilterFunctor
00034       {
00035         ByKind( const ResObject::Kind & kind_r )
00036         : _kind( kind_r )
00037         {}
00038 
00039         bool operator()( const Selectable::constPtr & obj ) const
00040         {
00041           return obj && obj->kind() == _kind;
00042         }
00043 
00044         ResObject::Kind _kind;
00045       };
00046 
00048       struct ByName : public SelectableFilterFunctor
00049       {
00050         ByName( const std::string & name_r )
00051         : _name( name_r )
00052         {}
00053 
00054         bool operator()( const ui::Selectable::constPtr & obj ) const
00055         { return obj && obj->name() == _name; }
00056 
00057         std::string _name;
00058       };
00059 
00061       struct ByHasInstalledObj : public SelectableFilterFunctor
00062       {
00063         bool operator()( const ui::Selectable::constPtr & obj ) const
00064         { return obj && !obj->installedEmpty(); }
00065       };
00066 
00068       struct ByHasCandidateObj : public SelectableFilterFunctor
00069       {
00070         bool operator()( const ui::Selectable::constPtr & obj ) const
00071         { return obj && obj->hasCandidateObj(); }
00072       };
00073 
00074       struct ByStatus : public SelectableFilterFunctor
00076       {
00077         ByStatus( Status status_r )
00078         : _status( status_r )
00079         {}
00080 
00081         bool operator()( const ui::Selectable::constPtr & obj ) const
00082         { return obj && obj->status() == _status; }
00083 
00084         Status _status;
00085       };
00086 
00088     } // namespace selfilter
00091   } // namespace ui
00094 } // namespace zypp
00096 #endif // ZYPP_UI_SELFILTERS_H