From 5ffd5dc387160b536b191eceeda4bdfe6e8d9633 Mon Sep 17 00:00:00 2001 From: Charles Otto Date: Wed, 28 May 2014 15:50:50 -0400 Subject: [PATCH] Rename emptyRead FileList::fromGallery, default caching to off. --- openbr/core/core.cpp | 4 ++-- openbr/openbr_plugin.h | 2 ++ openbr/plugins/gallery.cpp | 8 +++++--- openbr/plugins/misc.cpp | 6 ++---- openbr/plugins/openbr_internal.h | 5 ----- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/openbr/core/core.cpp b/openbr/core/core.cpp index 9f81649..94b9263 100644 --- a/openbr/core/core.cpp +++ b/openbr/core/core.cpp @@ -350,8 +350,8 @@ struct AlgorithmCore FileList queryMetadata; // Emptyread reads a gallery, and discards any matrices present, keeping only the metadata. - emptyRead(targetGallery, targetMetadata); - emptyRead(queryGallery, queryMetadata); + targetMetadata = FileList::fromGallery(targetGallery, true); + queryMetadata = FileList::fromGallery(queryGallery, true); // Is the target or query set larger? We will use the larger as the rows of our comparison matrix (and transpose the output if necessary) diff --git a/openbr/openbr_plugin.h b/openbr/openbr_plugin.h index e17a70c..dabbc80 100644 --- a/openbr/openbr_plugin.h +++ b/openbr/openbr_plugin.h @@ -369,6 +369,8 @@ struct BR_EXPORT FileList : public QList QList crossValidationPartitions() const; /*!< \brief Returns the cross-validation partition (default=0) for each file in the list. */ int failures() const; /*!< \brief Returns the number of files with br::File::failed(). */ + + static FileList fromGallery(const File &gallery, bool cache = false); /*!< \brief Create a file list from a br::Gallery. */ }; /*! diff --git a/openbr/plugins/gallery.cpp b/openbr/plugins/gallery.cpp index d427e8e..5b0c2a6 100644 --- a/openbr/plugins/gallery.cpp +++ b/openbr/plugins/gallery.cpp @@ -393,16 +393,17 @@ class memGallery : public Gallery BR_REGISTER(Gallery, memGallery) -void emptyRead(const File & file, FileList & fileData, bool cache) +FileList FileList::fromGallery(const File & file, bool cache) { File targetMeta = file; targetMeta.name = targetMeta.path() + targetMeta.baseName() + "_meta" + targetMeta.hash() + ".mem"; + FileList fileData; + // Did we already read the data? if (MemoryGalleries::galleries.contains(targetMeta)) { - fileData = MemoryGalleries::galleries[targetMeta].files(); - return; + return MemoryGalleries::galleries[targetMeta].files(); } TemplateList templates; @@ -434,6 +435,7 @@ void emptyRead(const File & file, FileList & fileData, bool cache) memOutput->writeBlock(templates); } fileData = templates.files(); + return fileData; } /*! diff --git a/openbr/plugins/misc.cpp b/openbr/plugins/misc.cpp index 547e453..72cb01a 100644 --- a/openbr/plugins/misc.cpp +++ b/openbr/plugins/misc.cpp @@ -636,10 +636,8 @@ class OutputTransform : public TimeVaryingTransform if (targetName.isEmpty() || queryName.isEmpty() || outputString.isEmpty()) return; - FileList targetFiles; - FileList queryFiles; - emptyRead(targetName, targetFiles, false); - emptyRead(queryName, queryFiles, false); + FileList targetFiles = FileList::fromGallery(targetName); + FileList queryFiles = FileList::fromGallery(queryName); currentBlockRow = 0; currentBlockCol = 0; diff --git a/openbr/plugins/openbr_internal.h b/openbr/plugins/openbr_internal.h index ad80050..98fab50 100644 --- a/openbr/plugins/openbr_internal.h +++ b/openbr/plugins/openbr_internal.h @@ -314,11 +314,6 @@ struct WorkerProcess void mainLoop(); }; - -// Read metadata for all templates stored in the specified gallery, return the read -// TeamplateList. If the gallery contains matrices, they are dropped. -void emptyRead(const File & file, FileList & templates, bool cache = true); - } #endif // OPENBR_INTERNAL_H -- libgit2 0.21.4