summaryrefslogtreecommitdiff
path: root/TelepathyQt4
diff options
context:
space:
mode:
authorAndre Moreira Magalhaes (andrunko) <andre.magalhaes@collabora.co.uk>2010-11-16 12:19:14 -0200
committerAndre Moreira Magalhaes (andrunko) <andre.magalhaes@collabora.co.uk>2010-12-09 11:09:35 -0200
commitde0ab074ea7a1906863d91e60bcb5162e1a12a35 (patch)
tree79dc3793b8f0de41c79a3d75b8ccd77e46a7b8cc /TelepathyQt4
parented2de858b363caa5ef5e646ec200e480bdbfc52f (diff)
Added NotFilter class.
Diffstat (limited to 'TelepathyQt4')
-rw-r--r--TelepathyQt4/CMakeLists.txt2
-rw-r--r--TelepathyQt4/NotFilter13
-rw-r--r--TelepathyQt4/not-filter.h72
3 files changed, 87 insertions, 0 deletions
diff --git a/TelepathyQt4/CMakeLists.txt b/TelepathyQt4/CMakeLists.txt
index 8ff4679c..6d64debe 100644
--- a/TelepathyQt4/CMakeLists.txt
+++ b/TelepathyQt4/CMakeLists.txt
@@ -254,6 +254,8 @@ set(telepathy_qt4_HEADERS
message.h
MethodInvocationContext
method-invocation-context.h
+ NotFilter
+ not-filter.h
Object
object.h
OptionalInterfaceFactory
diff --git a/TelepathyQt4/NotFilter b/TelepathyQt4/NotFilter
new file mode 100644
index 00000000..2019f179
--- /dev/null
+++ b/TelepathyQt4/NotFilter
@@ -0,0 +1,13 @@
+#ifndef _TelepathyQt4_NotFilter_HEADER_GUARD_
+#define _TelepathyQt4_NotFilter_HEADER_GUARD_
+
+#ifndef IN_TELEPATHY_QT4_HEADER
+#define IN_TELEPATHY_QT4_HEADER
+#endif
+
+#include <TelepathyQt4/not-filter.h>
+
+#undef IN_TELEPATHY_QT4_HEADER
+
+#endif
+// vim:set ft=cpp:
diff --git a/TelepathyQt4/not-filter.h b/TelepathyQt4/not-filter.h
new file mode 100644
index 00000000..f1b75a66
--- /dev/null
+++ b/TelepathyQt4/not-filter.h
@@ -0,0 +1,72 @@
+/*
+ * This file is part of TelepathyQt4
+ *
+ * Copyright (C) 2010 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2010 Nokia Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef _TelepathyQt4_not_filter_h_HEADER_GUARD_
+#define _TelepathyQt4_not_filter_h_HEADER_GUARD_
+
+#ifndef IN_TELEPATHY_QT4_HEADER
+#error IN_TELEPATHY_QT4_HEADER
+#endif
+
+#include <TelepathyQt4/Filter>
+#include <TelepathyQt4/Types>
+
+namespace Tp
+{
+
+template <class T>
+class NotFilter : public Filter<T>
+{
+public:
+ static SharedPtr<NotFilter<T> > create(
+ const SharedPtr<const Filter<T> > &filter = SharedPtr<const Filter<T> >())
+ {
+ return SharedPtr<NotFilter<T> >(new NotFilter<T>(filter));
+ }
+
+ inline virtual ~NotFilter() { }
+
+ inline virtual bool isValid() const
+ {
+ return mFilter && mFilter->isValid();
+ }
+
+ inline virtual bool matches(const SharedPtr<T> &t) const
+ {
+ if (!isValid()) {
+ return false;
+ }
+
+ return !mFilter->matches(t);
+ }
+
+ inline SharedPtr<const Filter<T> > filter() const { return mFilter; }
+
+private:
+ NotFilter(const SharedPtr<const Filter<T> > &filter)
+ : Filter<T>(), mFilter(filter) { }
+
+ SharedPtr<const Filter<T> > mFilter;
+};
+
+} // Tp
+
+#endif