summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Christian <andrew.christian@nokia.com>2012-02-10 15:11:25 -0500
committerChris Craig <ext-chris.craig@nokia.com>2012-02-10 22:41:56 +0100
commit15d0b18379b82154aaf8b255ec0d17cf257d9551 (patch)
treef5c1fb04f821a3b0310b4921936cdc9d59c33357 /src
parent42b700962e58a9224ad47c26cb383e526a52d00d (diff)
Added AbstractMatcher
Change-Id: Iefb838c614fbf5217be9105a4dcbe89c956df00c Reviewed-by: Chris Craig <ext-chris.craig@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/abstractmatcher.cpp69
-rw-r--r--src/core/abstractmatcher.h61
-rw-r--r--src/core/core-lib.pri2
-rw-r--r--src/core/processbackendfactory.cpp46
-rw-r--r--src/core/processbackendfactory.h14
5 files changed, 188 insertions, 4 deletions
diff --git a/src/core/abstractmatcher.cpp b/src/core/abstractmatcher.cpp
new file mode 100644
index 0000000..6dab2a9
--- /dev/null
+++ b/src/core/abstractmatcher.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "abstractmatcher.h"
+
+QT_BEGIN_NAMESPACE_PROCESSMANAGER
+
+/*!
+ \class AbstractMatcher
+ \brief The AbstractMatcher class is a virtual class for matching creation requests.
+
+ You must subclass this class to do anything useful.
+*/
+
+/*!
+ Construct a AbstractMatcher with an optional \a parent.
+*/
+
+AbstractMatcher::AbstractMatcher(QObject *parent)
+ : QObject(parent)
+{
+}
+
+/*!
+ \fn AbstractMatcher::matches(const ProcessInfo& info)
+
+ Return true if the ProcessInfo \a info record matches.
+ You must override this function.
+*/
+
+#include "moc_abstractmatcher.cpp"
+
+QT_END_NAMESPACE_PROCESSMANAGER
diff --git a/src/core/abstractmatcher.h b/src/core/abstractmatcher.h
new file mode 100644
index 0000000..a4011a2
--- /dev/null
+++ b/src/core/abstractmatcher.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PROCESS_ABSTRACTMATCHER_H
+#define PROCESS_ABSTRACTMATCHER_H
+
+#include <QObject>
+
+#include "processmanager-global.h"
+
+QT_BEGIN_NAMESPACE_PROCESSMANAGER
+
+class ProcessInfo;
+
+class Q_ADDON_PROCESSMANAGER_EXPORT AbstractMatcher : public QObject
+{
+ Q_OBJECT
+public:
+ explicit AbstractMatcher(QObject *parent = 0);
+ virtual bool matches(const ProcessInfo& info) = 0;
+};
+
+QT_END_NAMESPACE_PROCESSMANAGER
+
+#endif // PROCESS_ABSTRACTMATCHER_H
diff --git a/src/core/core-lib.pri b/src/core/core-lib.pri
index 5144882..fee62dd 100644
--- a/src/core/core-lib.pri
+++ b/src/core/core-lib.pri
@@ -8,6 +8,7 @@ PUBLIC_HEADERS += \
$$PWD/processbackend.h \
$$PWD/processbackendfactory.h \
$$PWD/processbackendmanager.h \
+ $$PWD/abstractmatcher.h \
$$PWD/processinfo.h \
$$PWD/processmanager.h \
$$PWD/gdbprocessbackendfactory.h \
@@ -37,6 +38,7 @@ SOURCES += \
$$PWD/processbackend.cpp \
$$PWD/processbackendfactory.cpp \
$$PWD/processbackendmanager.cpp \
+ $$PWD/abstractmatcher.cpp \
$$PWD/processinfo.cpp \
$$PWD/processmanager.cpp \
$$PWD/unixprocessbackend.cpp \
diff --git a/src/core/processbackendfactory.cpp b/src/core/processbackendfactory.cpp
index 3fcf710..05ad79d 100644
--- a/src/core/processbackendfactory.cpp
+++ b/src/core/processbackendfactory.cpp
@@ -38,6 +38,7 @@
****************************************************************************/
#include "processbackendfactory.h"
+#include "abstractmatcher.h"
QT_BEGIN_NAMESPACE_PROCESSMANAGER
@@ -54,6 +55,7 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER
ProcessBackendFactory::ProcessBackendFactory(QObject *parent)
: QObject(parent)
+ , m_matcher(NULL)
, m_memoryRestricted(false)
{
}
@@ -99,12 +101,52 @@ void ProcessBackendFactory::handleMemoryRestrictionChange()
}
/*!
+ Return the current AbstractMatcher object
+ */
+
+AbstractMatcher *ProcessBackendFactory::matcher() const
+{
+ return m_matcher;
+}
+
+/*!
+ Set a new process AbstractMatcher object \a matcher.
+ The ProcessBackendFactory takes over parentage of the AbstractMatcher.
+ */
+
+void ProcessBackendFactory::setMatcher(AbstractMatcher *matcher)
+{
+ if (matcher != m_matcher) {
+ if (m_matcher)
+ delete m_matcher;
+ m_matcher = matcher;
+ m_matcher->setParent(this);
+ emit matcherChanged();
+ }
+}
+
+/*!
\fn bool ProcessBackendFactory::canCreate(const ProcessInfo& info) const
Return true if this ProcessBackendFactory matches the ProcessInfo \a info
- process binding and can create an appropriate process.
+ process binding and can create an appropriate process. The default implementation
+ delegates the decision to the AbstractMatcher object. If no AbstractMatcher
+ has been installed, the default implementation returns true.
+
+ This virtual function may be overridden.
+*/
+
+bool ProcessBackendFactory::canCreate(const ProcessInfo& info) const
+{
+ if (m_matcher)
+ return m_matcher->matches(info);
+ return true;
+}
+
+/*!
+ \fn void ProcessBackendFactory::matcherChanged()
- This virtual function must be overridden.
+ Signal emitted whenever the AbstractMatcher is changed.
*/
/*!
diff --git a/src/core/processbackendfactory.h b/src/core/processbackendfactory.h
index a6b31b8..2a109ad 100644
--- a/src/core/processbackendfactory.h
+++ b/src/core/processbackendfactory.h
@@ -49,24 +49,34 @@ QT_BEGIN_NAMESPACE_PROCESSMANAGER
class ProcessBackend;
class ProcessInfo;
+class AbstractMatcher;
class Q_ADDON_PROCESSMANAGER_EXPORT ProcessBackendFactory : public QObject
{
Q_OBJECT
+ Q_PROPERTY(AbstractMatcher* matcher READ matcher WRITE setMatcher NOTIFY matcherChanged);
+
public:
ProcessBackendFactory(QObject *parent = 0);
virtual ~ProcessBackendFactory();
- virtual bool canCreate(const ProcessInfo& info) const = 0;
+ virtual bool canCreate(const ProcessInfo& info) const;
virtual ProcessBackend *create(const ProcessInfo& info, QObject *parent) = 0;
void setMemoryRestricted(bool);
virtual QList<Q_PID> internalProcesses();
+ AbstractMatcher * matcher() const;
+ void setMatcher(AbstractMatcher *);
+
+signals:
+ void matcherChanged();
+
protected:
virtual void handleMemoryRestrictionChange();
protected:
- bool m_memoryRestricted;
+ AbstractMatcher *m_matcher;
+ bool m_memoryRestricted;
};
QT_END_NAMESPACE_PROCESSMANAGER