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

BasicPackageMatcher.h

Go to the documentation of this file.
00001 #ifndef DEBTAGS_BASIC_PACKAGE_FILTER_H
00002 #define DEBTAGS_BASIC_PACKAGE_FILTER_H
00003 
00004 #pragma interface
00005 
00006 #include <string>
00007 #include <tagcoll/Tag.h>
00008 #include <tagcoll/TagSet.h>
00009 #include <debtags/Consumer.h>
00010 
00011 namespace Debtags
00012 {
00013 
00014 using namespace Tagcoll;
00015 
00016 class Package;
00017 class Regexp;
00018 
00019 class BasicPackageMatcher : public PackageMatcher
00020 {
00021 public:
00022     typedef enum { YES, NO, ANY } InstalledStatus;
00023 protected:
00024     std::string maint;
00025     Regexp* name;
00026     Regexp* str;
00027     InstalledStatus installed;
00028     TagSet tags;
00029 
00030 public:
00031     BasicPackageMatcher() throw ()
00032         : name(0), str(0), installed(ANY) {}
00033     virtual ~BasicPackageMatcher() throw ();
00034 
00035     void setName(const std::string _name) throw ();
00036     void setMaintainer(const std::string _maint) throw () { maint = _maint; }
00037     void setString(const std::string _str) throw ();
00038     void setInstalled(InstalledStatus val) throw ()
00039     {
00040         installed = val;
00041     }
00042     void setDebtags(const TagSet& ptags) throw ()
00043     {
00044         tags = ptags;
00045     }
00046 
00047     bool hasName() const throw () { return name != 0; }
00048     bool hasMaintainer() const throw () { return !maint.empty(); }
00049     bool hasString() const throw () { return str != 0; }
00050     bool hasInstalled() const throw () { return installed != ANY; }
00051     bool hasDebtags() const throw () { return !tags.empty(); }
00052 
00053     // Compute values useful in deciding search strategies
00054     bool hasOnlyName() const throw () { return name != 0 && str == 0 && maint.empty() && installed == ANY && tags.empty(); }
00055     bool hasOnlyMaintainer() const throw () { return name == 0 && str == 0 && !maint.empty() && installed == ANY && tags.empty(); }
00056     bool isMaintainerSignificant() const throw () { return maint.size() > 1; }
00057     bool hasOnlyDebtags() const throw () { return name == 0 && str == 0 && maint.empty() && installed == ANY && !tags.empty(); }
00058     bool hasNonDebtags() const throw () { return name != 0 || str != 0 || !maint.empty() || installed != ANY; }
00059 
00060     bool matchName(const std::string& text) const throw ();
00061     bool matchMaintainer(const std::string& text) const throw ();
00062     bool matchString(const std::string& text) const throw ();
00063     bool matchInstalled(int status) const throw ();
00064     bool matchDebtags(const TagSet& ptags) const throw ();
00065     const TagSet& debtagsTagset() const throw () { return tags; }
00066 
00067     bool match(const Package& pkg) const throw ();
00068 };
00069 
00070 };
00071 
00072 // vim:set ts=3 sw=3:
00073 #endif

Generated on Wed Jul 13 19:19:40 2005 for libdebtags by  doxygen 1.4.3-20050530