Home · All Classes · All Namespaces · Modules · Functions · Files
and-filter.h
1 
23 #ifndef _TelepathyQt_and_filter_h_HEADER_GUARD_
24 #define _TelepathyQt_and_filter_h_HEADER_GUARD_
25 
26 #ifndef IN_TP_QT_HEADER
27 #error IN_TP_QT_HEADER
28 #endif
29 
30 #include <TelepathyQt/Filter>
31 #include <TelepathyQt/Types>
32 
33 namespace Tp
34 {
35 
36 template <class T>
37 class AndFilter : public Filter<T>
38 {
39 public:
41  const QList<SharedPtr<const Filter<T> > > &filters = QList<SharedPtr<const Filter<T> > >())
42  {
44  }
45 
46  inline virtual ~AndFilter() { }
47 
48  inline virtual bool isValid() const
49  {
50  Q_FOREACH (const SharedPtr<const Filter<T> > &filter, mFilters) {
51  if (!filter || !filter->isValid()) {
52  return false;
53  }
54  }
55  return true;
56  }
57 
58  inline virtual bool matches(const SharedPtr<T> &t) const
59  {
60  if (!isValid()) {
61  return false;
62  }
63 
64  Q_FOREACH (const SharedPtr<const Filter<T> > &filter, mFilters) {
65  if (!filter->matches(t)) {
66  return false;
67  }
68  }
69  return true;
70  }
71 
72  inline QList<SharedPtr<const Filter<T> > > filters() const { return mFilters; }
73 
74 private:
75  AndFilter(const QList<SharedPtr<const Filter<T> > > &filters)
76  : Filter<T>(), mFilters(filters) { }
77 
78  QList<SharedPtr<const Filter<T> > > mFilters;
79 };
80 
81 } // Tp
82 
83 #endif
QList< SharedPtr< const Filter< T > > > filters() const
Definition: and-filter.h:72
static SharedPtr< AndFilter< T > > create(const QList< SharedPtr< const Filter< T > > > &filters=QList< SharedPtr< const Filter< T > > >())
Definition: and-filter.h:40
The Filter class provides a base class to be used by specialized filters such as GenericCapabilityFil...
Definition: filter.h:37
virtual ~AndFilter()
Definition: and-filter.h:46
virtual bool matches(const SharedPtr< T > &t) const
Definition: and-filter.h:58
The SharedPtr class is a pointer to an explicitly shared object.
Definition: shared-ptr.h:39
virtual bool isValid() const
Definition: and-filter.h:48
The AndFilter class provides a generic filter object to be used in conjunction of other filters...
Definition: and-filter.h:37


Copyright © 2008-2011 Collabora Ltd. and Nokia Corporation
Telepathy-Qt 0.9.5