[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [digikam] core/utilities/facemanagement: move parallelpipes class to a dedicated .h/.cpp
From:       Gilles Caulier <null () kde ! org>
Date:       2018-09-19 15:34:43
Message-ID: E1g2eV1-0006Nv-Fi () code ! kde ! org
[Download RAW message or body]

Git commit 7f6674d81ec1b93af17cac38649307efb3dc00df by Gilles Caulier.
Committed on 19/09/2018 at 15:34.
Pushed by cgilles into branch 'master'.

move parallelpipes class to a dedicated .h/.cpp

M  +1    -0    core/utilities/facemanagement/CMakeLists.txt
M  +1    -0    core/utilities/facemanagement/facepipeline.cpp
M  +1    -79   core/utilities/facemanagement/facepipeline_p.cpp
M  +1    -36   core/utilities/facemanagement/facepipeline_p.h
A  +128  -0    core/utilities/facemanagement/parallelpipes.cpp     [License: GPL \
(v2+)] A  +83   -0    core/utilities/facemanagement/parallelpipes.h     [License: GPL \
(v2+)]

https://commits.kde.org/digikam/7f6674d81ec1b93af17cac38649307efb3dc00df

diff --git a/core/utilities/facemanagement/CMakeLists.txt \
b/core/utilities/facemanagement/CMakeLists.txt index c04540f316..f7fbf5b5bb 100644
--- a/core/utilities/facemanagement/CMakeLists.txt
+++ b/core/utilities/facemanagement/CMakeLists.txt
@@ -19,6 +19,7 @@ set(libfacemanagement_SRCS
     faceimageretriever.cpp
     facescandialog.cpp
     assignnamewidget.cpp
+    parallelpipes.cpp
 )
 
 include_directories($<TARGET_PROPERTY:Qt5::Sql,INTERFACE_INCLUDE_DIRECTORIES>
diff --git a/core/utilities/facemanagement/facepipeline.cpp \
b/core/utilities/facemanagement/facepipeline.cpp index 834c7905be..d258771d53 100644
--- a/core/utilities/facemanagement/facepipeline.cpp
+++ b/core/utilities/facemanagement/facepipeline.cpp
@@ -45,6 +45,7 @@
 #include "facebenchmarkers.h"
 #include "faceworkers.h"
 #include "faceimageretriever.h"
+#include "parallelpipes.h"
 
 namespace Digikam
 {
diff --git a/core/utilities/facemanagement/facepipeline_p.cpp \
b/core/utilities/facemanagement/facepipeline_p.cpp index b369a0a24e..84be118408 \
                100644
--- a/core/utilities/facemanagement/facepipeline_p.cpp
+++ b/core/utilities/facemanagement/facepipeline_p.cpp
@@ -45,6 +45,7 @@
 #include "facebenchmarkers.h"
 #include "faceworkers.h"
 #include "faceimageretriever.h"
+#include "parallelpipes.h"
 
 namespace Digikam
 {
@@ -69,85 +70,6 @@ FacePipelineExtendedPackage::Ptr \
PackageLoadingDescriptionList::take(const Loadi  
 // ----------------------------------------------------------------------------------------
  
-ParallelPipes::ParallelPipes()
-    : m_currentIndex(0)
-{
-}
-
-ParallelPipes::~ParallelPipes()
-{
-    foreach (WorkerObject* const object, m_workers)
-    {
-        delete object;
-    }
-}
-
-void ParallelPipes::schedule()
-{
-    foreach (WorkerObject* const object, m_workers)
-    {
-        object->schedule();
-    }
-}
-
-void ParallelPipes::deactivate(WorkerObject::DeactivatingMode mode)
-{
-    foreach (WorkerObject* const object, m_workers)
-    {
-        object->deactivate(mode);
-    }
-}
-
-void ParallelPipes::wait()
-{
-    foreach (WorkerObject* const object, m_workers)
-    {
-        object->wait();
-    }
-}
-
-void ParallelPipes::setPriority(QThread::Priority priority)
-{
-    foreach (WorkerObject* const object, m_workers)
-    {
-        object->setPriority(priority);
-    }
-}
-
-void ParallelPipes::add(WorkerObject* const worker)
-{
-    QByteArray normalizedSignature = \
                QMetaObject::normalizedSignature("process(FacePipelineExtendedPackage::Ptr)");
                
-    int methodIndex                = \
                worker->metaObject()->indexOfMethod(normalizedSignature.constData());
-
-    if (methodIndex == -1)
-    {
-        qCDebug(DIGIKAM_GENERAL_LOG) << "Object" << worker << "does not have a slot"
-                                     << normalizedSignature << " - cannot use for \
                processing.";
-        return;
-    }
-
-    m_workers << worker;
-    m_methods << worker->metaObject()->method(methodIndex);
-
-    // collect the worker's signals and bundle them to our single signal, which is \
                further connected
-    connect(worker, SIGNAL(processed(FacePipelineExtendedPackage::Ptr)),
-            this, SIGNAL(processed(FacePipelineExtendedPackage::Ptr)));
-}
-
-void ParallelPipes::process(FacePipelineExtendedPackage::Ptr package)
-{
-    // Here, we send the package to one of the workers, in turn
-    m_methods.at(m_currentIndex).invoke(m_workers.at(m_currentIndex), \
                Qt::QueuedConnection,
-                                        Q_ARG(FacePipelineExtendedPackage::Ptr, \
                package));
-
-    if (++m_currentIndex == m_workers.size())
-    {
-        m_currentIndex = 0;
-    }
-}
-
-// ----------------------------------------------------------------------------------------
                
-
 ScanStateFilter::ScanStateFilter(FacePipeline::FilterMode mode, \
FacePipeline::Private* const d)  : d(d),
       mode(mode)
diff --git a/core/utilities/facemanagement/facepipeline_p.h \
b/core/utilities/facemanagement/facepipeline_p.h index 5a3e8eec29..22d51b82e4 100644
--- a/core/utilities/facemanagement/facepipeline_p.h
+++ b/core/utilities/facemanagement/facepipeline_p.h
@@ -53,6 +53,7 @@ class Trainer;
 class DatabaseWriter;
 class PreviewLoader;
 class FaceImageRetriever;
+class ParallelPipes;
 
 class Q_DECL_HIDDEN FacePipelineExtendedPackage : public FacePipelinePackage,
                                                   public QSharedData
@@ -86,42 +87,6 @@ public:
 
 // ----------------------------------------------------------------------------------------
  
-class Q_DECL_HIDDEN ParallelPipes : public QObject
-{
-    Q_OBJECT
-
-public:
-
-    explicit ParallelPipes();
-    ~ParallelPipes();
-
-    void schedule();
-    void deactivate(WorkerObject::DeactivatingMode mode = \
                WorkerObject::FlushSignals);
-    void wait();
-
-    void add(WorkerObject* const worker);
-    void setPriority(QThread::Priority priority);
-
-public:
-
-    QList<WorkerObject*> m_workers;
-
-public Q_SLOTS:
-
-    void process(FacePipelineExtendedPackage::Ptr package);
-
-Q_SIGNALS:
-
-    void processed(FacePipelineExtendedPackage::Ptr package);
-
-protected:
-
-    QList<QMetaMethod> m_methods;
-    int                m_currentIndex;
-};
-
-// ----------------------------------------------------------------------------------------
                
-
 class Q_DECL_HIDDEN ScanStateFilter : public DynamicThread
 {
     Q_OBJECT
diff --git a/core/utilities/facemanagement/parallelpipes.cpp \
b/core/utilities/facemanagement/parallelpipes.cpp new file mode 100644
index 0000000000..151f478c56
--- /dev/null
+++ b/core/utilities/facemanagement/parallelpipes.cpp
@@ -0,0 +1,128 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date        : 2010-09-03
+ * Description : Integrated, multithread face detection / recognition
+ *
+ * Copyright (C) 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * ============================================================ */
+
+#include "parallelpipes.h"
+
+// Qt includes
+
+#include <QMetaObject>
+#include <QMutexLocker>
+
+// KDE includes
+
+#include <klocalizedstring.h>
+#include <ksharedconfig.h>
+#include <kconfiggroup.h>
+
+// Local includes
+
+#include "digikam_debug.h"
+#include "loadingdescription.h"
+#include "metadatasettings.h"
+#include "tagscache.h"
+#include "threadmanager.h"
+#include "facebenchmarkers.h"
+#include "faceworkers.h"
+#include "faceimageretriever.h"
+
+namespace Digikam
+{
+
+ParallelPipes::ParallelPipes()
+    : m_currentIndex(0)
+{
+}
+
+ParallelPipes::~ParallelPipes()
+{
+    foreach (WorkerObject* const object, m_workers)
+    {
+        delete object;
+    }
+}
+
+void ParallelPipes::schedule()
+{
+    foreach (WorkerObject* const object, m_workers)
+    {
+        object->schedule();
+    }
+}
+
+void ParallelPipes::deactivate(WorkerObject::DeactivatingMode mode)
+{
+    foreach (WorkerObject* const object, m_workers)
+    {
+        object->deactivate(mode);
+    }
+}
+
+void ParallelPipes::wait()
+{
+    foreach (WorkerObject* const object, m_workers)
+    {
+        object->wait();
+    }
+}
+
+void ParallelPipes::setPriority(QThread::Priority priority)
+{
+    foreach (WorkerObject* const object, m_workers)
+    {
+        object->setPriority(priority);
+    }
+}
+
+void ParallelPipes::add(WorkerObject* const worker)
+{
+    QByteArray normalizedSignature = \
QMetaObject::normalizedSignature("process(FacePipelineExtendedPackage::Ptr)"); +    \
int methodIndex                = \
worker->metaObject()->indexOfMethod(normalizedSignature.constData()); +
+    if (methodIndex == -1)
+    {
+        qCDebug(DIGIKAM_GENERAL_LOG) << "Object" << worker << "does not have a slot"
+                                     << normalizedSignature << " - cannot use for \
processing."; +        return;
+    }
+
+    m_workers << worker;
+    m_methods << worker->metaObject()->method(methodIndex);
+
+    // collect the worker's signals and bundle them to our single signal, which is \
further connected +    connect(worker, \
SIGNAL(processed(FacePipelineExtendedPackage::Ptr)), +            this, \
SIGNAL(processed(FacePipelineExtendedPackage::Ptr))); +}
+
+void ParallelPipes::process(FacePipelineExtendedPackage::Ptr package)
+{
+    // Here, we send the package to one of the workers, in turn
+    m_methods.at(m_currentIndex).invoke(m_workers.at(m_currentIndex), \
Qt::QueuedConnection, +                                        \
Q_ARG(FacePipelineExtendedPackage::Ptr, package)); +
+    if (++m_currentIndex == m_workers.size())
+    {
+        m_currentIndex = 0;
+    }
+}
+
+} // namespace Digikam
diff --git a/core/utilities/facemanagement/parallelpipes.h \
b/core/utilities/facemanagement/parallelpipes.h new file mode 100644
index 0000000000..f831f4b3cf
--- /dev/null
+++ b/core/utilities/facemanagement/parallelpipes.h
@@ -0,0 +1,83 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date        : 2010-09-03
+ * Description : Integrated, multithread face detection / recognition
+ *
+ * Copyright (C) 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef DIGIKAM_PARALLEL_PIPES_H
+#define DIGIKAM_PARALLEL_PIPES_H
+
+// Qt includes
+
+#include <QExplicitlySharedDataPointer>
+#include <QMetaMethod>
+#include <QMutex>
+#include <QSharedData>
+#include <QWaitCondition>
+
+// Local includes
+
+#include "facepipeline_p.h"
+#include "facedetector.h"
+#include "faceutils.h"
+#include "previewloadthread.h"
+#include "thumbnailloadthread.h"
+#include "workerobject.h"
+
+namespace Digikam
+{
+
+class Q_DECL_HIDDEN ParallelPipes : public QObject
+{
+    Q_OBJECT
+
+public:
+
+    explicit ParallelPipes();
+    ~ParallelPipes();
+
+    void schedule();
+    void deactivate(WorkerObject::DeactivatingMode mode = \
WorkerObject::FlushSignals); +    void wait();
+
+    void add(WorkerObject* const worker);
+    void setPriority(QThread::Priority priority);
+
+public:
+
+    QList<WorkerObject*> m_workers;
+
+public Q_SLOTS:
+
+    void process(FacePipelineExtendedPackage::Ptr package);
+
+Q_SIGNALS:
+
+    void processed(FacePipelineExtendedPackage::Ptr package);
+
+protected:
+
+    QList<QMetaMethod> m_methods;
+    int                m_currentIndex;
+};
+
+} // namespace Digikam
+
+#endif // DIGIKAM_PARALLEL_PIPES_H


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic