| Home · All Classes · All Namespaces · Modules · Functions · Files

or-filter.h
1
23 #ifndef _TelepathyQt_or_filter_h_HEADER_GUARD_
24 #define _TelepathyQt_or_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 OrFilter : public Filter<T>
38 {
39 public:
40 static SharedPtr<OrFilter<T> > create(
41 const QList<SharedPtr<const Filter<T> > > &filters = QList<SharedPtr<const Filter<T> > >())
42 {
43 return SharedPtr<OrFilter<T> >(new OrFilter<T>(filters));
44 }
45
46 inline virtual ~OrFilter() { }
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 true;
67 }
68 }
69 return false;
70 }
71
72 inline QList<SharedPtr<const Filter<T> > > filters() const { return mFilters; }
73
74 private:
75 OrFilter(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
Tp::SharedPtr
The SharedPtr class is a pointer to an explicitly shared object.
Definition: shared-ptr.h:39
Tp::OrFilter::matches
virtual bool matches(const SharedPtr< T > &t) const
Definition: or-filter.h:58
Tp::OrFilter::isValid
virtual bool isValid() const
Definition: or-filter.h:48
QList
Tp::OrFilter::filters
QList< SharedPtr< const Filter< T > > > filters() const
Definition: or-filter.h:72
Tp::Filter
The Filter class provides a base class to be used by specialized filters such as GenericCapabilityFil...
Definition: filter.h:37
Tp::OrFilter::~OrFilter
virtual ~OrFilter()
Definition: or-filter.h:46
Tp::OrFilter::create
static SharedPtr< OrFilter< T > > create(const QList< SharedPtr< const Filter< T > > > &filters=QList< SharedPtr< const Filter< T > > >())
Definition: or-filter.h:40
Tp::OrFilter
The OrFilter class provides a generic filter object to be used in conjunction of other filters...
Definition: or-filter.h:37
Tp
Definition: abstract-adaptor.cpp:31