[solang] Change the Engine::exportQueue_ to be a std::set



commit e7bd71227391e15a7f569eb4f2937d95a1a8ebe1
Author: Debarshi Ray <rishi gnu org>
Date:   Thu Mar 11 03:22:29 2010 +0200

    Change the Engine::exportQueue_ to be a std::set

 src/application/engine.cpp             |    2 +-
 src/application/engine.h               |    4 ++--
 src/common/export-queue-operations.cpp |   10 +++++++---
 src/common/i-photo-destination.h       |    2 +-
 src/common/types.h                     |    2 ++
 src/exporter/brasero-destination.cpp   |    4 ++--
 src/exporter/brasero-destination.h     |    2 +-
 src/exporter/directory-destination.cpp |    9 ++++++---
 src/exporter/directory-destination.h   |    2 +-
 src/exporter/exporter.cpp              |    4 ++--
 10 files changed, 25 insertions(+), 16 deletions(-)
---
diff --git a/src/application/engine.cpp b/src/application/engine.cpp
index acf20d0..d334423 100644
--- a/src/application/engine.cpp
+++ b/src/application/engine.cpp
@@ -162,7 +162,7 @@ Engine::signal_criteria_changed() throw()
     return criteriaChanged_;
 }
 
-PhotoList &
+PhotoSet &
 Engine::get_export_queue() throw()
 {
     return exportQueue_;
diff --git a/src/application/engine.h b/src/application/engine.h
index 6ed5414..9f113d7 100644
--- a/src/application/engine.h
+++ b/src/application/engine.h
@@ -110,7 +110,7 @@ class Engine :
             return DatabasePtr(&database_);
         }
 
-        PhotoList &
+        PhotoSet &
         get_export_queue() throw();
 
         inline SearchCriterionRepo &
@@ -139,7 +139,7 @@ class Engine :
 
         Glib::Mutex mutex_;
 
-        PhotoList exportQueue_;
+        PhotoSet exportQueue_;
 
         //The following are populated 
         //from gconf
diff --git a/src/common/export-queue-operations.cpp b/src/common/export-queue-operations.cpp
index 4d9777b..f0d265d 100644
--- a/src/common/export-queue-operations.cpp
+++ b/src/common/export-queue-operations.cpp
@@ -20,6 +20,9 @@
 #include "config.h"
 #endif // HAVE_CONFIG_H
 
+#include <algorithm>
+#include <iterator>
+
 #include "application.h"
 #include "export-queue-operations.h"
 
@@ -60,7 +63,7 @@ void
 ExportQueueCleaner::operator()(void) throw()
 {
     Engine & engine = application_->get_engine();
-    PhotoList & queue = engine.get_export_queue();
+    PhotoSet & queue = engine.get_export_queue();
     queue.clear();
 }
 
@@ -99,13 +102,14 @@ void
 ExportQueueInserter::operator()(void) throw()
 {
     Engine & engine = application_->get_engine();
-    PhotoList & queue = engine.get_export_queue();
+    PhotoSet & queue = engine.get_export_queue();
     RendererRegistry & renderer_registry
                            = application_->get_renderer_registry();
     const IRendererPtr renderer = renderer_registry.get_current();
     const PhotoList & photos = renderer->get_current_selection();
 
-    queue.insert(queue.end(), photos.begin(), photos.end());
+    std::copy(photos.begin(), photos.end(),
+              std::inserter(queue, queue.begin()));
 }
 
 } // namespace Solang
diff --git a/src/common/i-photo-destination.h b/src/common/i-photo-destination.h
index 895a92c..82f80dc 100644
--- a/src/common/i-photo-destination.h
+++ b/src/common/i-photo-destination.h
@@ -46,7 +46,7 @@ class IPhotoDestination :
         final(Application & application) throw() = 0;
 
         virtual void
-        export_photos_async(const PhotoList & photos,
+        export_photos_async(const PhotoSet & photos,
                             const ProgressObserverPtr & observer)
                             throw() = 0;
 
diff --git a/src/common/types.h b/src/common/types.h
index d0138be..5674f3b 100644
--- a/src/common/types.h
+++ b/src/common/types.h
@@ -21,6 +21,7 @@
 #define SOLANG_TYPES_H
 
 #include <map>
+#include <set>
 #include <vector>
 #include <tr1/memory>
 
@@ -216,6 +217,7 @@ class Photo;
 typedef std::tr1::shared_ptr<const Photo> ConstPhotoPtr;
 typedef std::tr1::shared_ptr<Photo> PhotoPtr;
 typedef Photo * UnrefPhotoPtr;
+typedef std::set<PhotoPtr> PhotoSet;
 typedef std::vector<PhotoPtr> PhotoList;
 typedef std::tr1::shared_ptr<PhotoList> PhotoListPtr;
 
diff --git a/src/exporter/brasero-destination.cpp b/src/exporter/brasero-destination.cpp
index ddcd9a9..5dce932 100644
--- a/src/exporter/brasero-destination.cpp
+++ b/src/exporter/brasero-destination.cpp
@@ -71,7 +71,7 @@ BraseroDestination::export_photo_async(
 
 void
 BraseroDestination::export_photos_async(
-                          const PhotoList & photos,
+                          const PhotoSet & photos,
                           const ProgressObserverPtr & observer)
                           throw()
 {
@@ -92,7 +92,7 @@ BraseroDestination::export_photos_async(
         BRASERO_TRACK(braseroTrackDataCfg_),
         NULL);
 
-    PhotoList::const_iterator it;
+    PhotoSet::const_iterator it;
 
     for (it = photos.begin(); photos.end() != it; it++)
     {
diff --git a/src/exporter/brasero-destination.h b/src/exporter/brasero-destination.h
index 5eff35c..7e5001f 100644
--- a/src/exporter/brasero-destination.h
+++ b/src/exporter/brasero-destination.h
@@ -46,7 +46,7 @@ class BraseroDestination :
         final(Application & application) throw();
 
         virtual void
-        export_photos_async(const PhotoList & photos,
+        export_photos_async(const PhotoSet & photos,
                             const ProgressObserverPtr & observer)
                             throw();
 
diff --git a/src/exporter/directory-destination.cpp b/src/exporter/directory-destination.cpp
index fcf017c..0cf76e4 100644
--- a/src/exporter/directory-destination.cpp
+++ b/src/exporter/directory-destination.cpp
@@ -21,6 +21,8 @@
 #include "config.h"
 #endif // HAVE_CONFIG_H
 
+#include <algorithm>
+#include <iterator>
 #include <string>
 
 #include <giomm.h>
@@ -87,7 +89,7 @@ DirectoryDestination::export_photo_async(
 
 void
 DirectoryDestination::export_photos_async(
-                          const PhotoList & photos,
+                          const PhotoSet & photos,
                           const ProgressObserverPtr & observer)
                           throw()
 {
@@ -97,8 +99,9 @@ DirectoryDestination::export_photos_async(
         observer->set_total(photos.size());
     }
 
-    const PhotoListPtr pending(new PhotoList(photos.begin(),
-                                             photos.end()));
+    const PhotoListPtr pending(new PhotoList());
+    std::copy(photos.begin(), photos.end(),
+              std::inserter(*pending, pending->begin()));
 
     if (true == createArchive_)
     {
diff --git a/src/exporter/directory-destination.h b/src/exporter/directory-destination.h
index 15d1ea6..df70944 100644
--- a/src/exporter/directory-destination.h
+++ b/src/exporter/directory-destination.h
@@ -43,7 +43,7 @@ class DirectoryDestination :
         final(Application & application) throw();
 
         virtual void
-        export_photos_async(const PhotoList & photos,
+        export_photos_async(const PhotoSet & photos,
                             const ProgressObserverPtr & observer)
                             throw();
 
diff --git a/src/exporter/exporter.cpp b/src/exporter/exporter.cpp
index b1470aa..acbf842 100644
--- a/src/exporter/exporter.cpp
+++ b/src/exporter/exporter.cpp
@@ -212,8 +212,8 @@ Exporter::on_exporter_dialog_response(
             photoDestination_->set_create_archive(create_archive);
 
             Engine & engine = application_->get_engine();
-            const PhotoList & export_queue
-                                  = engine.get_export_queue();
+            const PhotoSet & export_queue
+                                 = engine.get_export_queue();
 
             const ProgressObserverPtr observer
                 = ProgressObserver<sigc::signal<void> >::create(



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]