From fc3814061055d46f8d158dd56430c5d04026aa4d Mon Sep 17 00:00:00 2001
From: William F Godoy <williamfgc@yahoo.com>
Date: Wed, 8 Apr 2020 16:27:28 -0400
Subject: [PATCH] Addressing PR reviews and CI issues

---
 .../inc/MantidDataHandling/LoadEventNexus.h   | 28 +++++++++----------
 Framework/DataHandling/src/LoadEventNexus.cpp | 11 ++++----
 Framework/DataHandling/src/LoadNexusLogs.cpp  | 15 ++--------
 Framework/Kernel/src/NexusHDF5Descriptor.cpp  |  2 +-
 4 files changed, 22 insertions(+), 34 deletions(-)

diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h b/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h
index 53ec17abe74..a6c93a95321 100644
--- a/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h
+++ b/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h
@@ -113,11 +113,10 @@ public:
   /// Load instrument from Nexus file if possible, else from IDF spacified by
   /// Nexus file
   template <typename T>
-  static bool loadInstrument(
-      const std::string &nexusfilename, T localWorkspace,
-      const std::string &top_entry_name, Algorithm *alg,
-      const std::shared_ptr<Kernel::NexusHDF5Descriptor> &descriptor =
-          std::shared_ptr<Kernel::NexusHDF5Descriptor>());
+  static bool
+  loadInstrument(const std::string &nexusfilename, T localWorkspace,
+                 const std::string &top_entry_name, Algorithm *alg,
+                 const Kernel::NexusHDF5Descriptor *descriptor = nullptr);
 
   /// Load instrument for Nexus file
   template <typename T>
@@ -127,11 +126,10 @@ public:
 
   /// Load instrument from IDF file specified by Nexus file
   template <typename T>
-  static bool runLoadInstrument(
-      const std::string &nexusfilename, T localWorkspace,
-      const std::string &top_entry_name, Algorithm *alg,
-      const std::shared_ptr<Kernel::NexusHDF5Descriptor> &descriptor =
-          std::shared_ptr<Kernel::NexusHDF5Descriptor>());
+  static bool
+  runLoadInstrument(const std::string &nexusfilename, T localWorkspace,
+                    const std::string &top_entry_name, Algorithm *alg,
+                    const Kernel::NexusHDF5Descriptor *descriptor = nullptr);
 
   static void loadSampleDataISIScompatibility(::NeXus::File &file,
                                               EventWorkspaceCollection &WS);
@@ -487,14 +485,14 @@ template <typename T>
 bool LoadEventNexus::runLoadInstrument(
     const std::string &nexusfilename, T localWorkspace,
     const std::string &top_entry_name, Algorithm *alg,
-    const std::shared_ptr<Kernel::NexusHDF5Descriptor> &descriptor) {
+    const Kernel::NexusHDF5Descriptor *descriptor) {
   std::string instrument;
   std::string instFilename;
 
   const bool isNexus =
-      descriptor
-          ? LoadGeometry::isNexus(nexusfilename, descriptor->getAllEntries())
-          : LoadGeometry::isNexus(nexusfilename);
+      (descriptor == nullptr)
+          ? LoadGeometry::isNexus(nexusfilename)
+          : LoadGeometry::isNexus(nexusfilename, descriptor->getAllEntries());
 
   // Check if the geometry can be loaded directly from the Nexus file
   if (isNexus) {
@@ -753,7 +751,7 @@ template <typename T>
 bool LoadEventNexus::loadInstrument(
     const std::string &nexusfilename, T localWorkspace,
     const std::string &top_entry_name, Algorithm *alg,
-    const std::shared_ptr<Kernel::NexusHDF5Descriptor> &descriptor) {
+    const Kernel::NexusHDF5Descriptor *descriptor) {
 
   bool loadNexusInstrumentXML = true;
   if (alg->existsProperty("LoadNexusInstrumentXML"))
diff --git a/Framework/DataHandling/src/LoadEventNexus.cpp b/Framework/DataHandling/src/LoadEventNexus.cpp
index b55fb9ccc44..90b3d2640ec 100644
--- a/Framework/DataHandling/src/LoadEventNexus.cpp
+++ b/Framework/DataHandling/src/LoadEventNexus.cpp
@@ -816,8 +816,8 @@ void LoadEventNexus::loadEvents(API::Progress *const prog,
     // This may not be needed in the future if both LoadEventNexus and
     // LoadInstrument are made to use the same Nexus/HDF5 library
     m_file->close();
-    m_instrument_loaded_correctly =
-        loadInstrument(m_filename, m_ws, m_top_entry_name, this, descriptor);
+    m_instrument_loaded_correctly = loadInstrument(
+        m_filename, m_ws, m_top_entry_name, this, descriptor.get());
 
     if (!m_instrument_loaded_correctly)
       throw std::runtime_error("Instrument was not initialized correctly! "
@@ -867,8 +867,9 @@ void LoadEventNexus::loadEvents(API::Progress *const prog,
         }
         // get the number of events
         const std::string prefix = "/" + m_top_entry_name + "/" + entry_name;
-        std::size_t num =
-            numEvents(*m_file, true, oldNeXusFileNames, prefix, *descriptor);
+        bool hasTotalCounts = true;
+        std::size_t num = numEvents(*m_file, hasTotalCounts, oldNeXusFileNames,
+                                    prefix, *descriptor);
         bankNames.emplace_back(entry_name);
         bankNumEvents.emplace_back(num);
 
@@ -1183,7 +1184,7 @@ bool LoadEventNexus::runLoadInstrument<EventWorkspaceCollection_sptr>(
     const std::string &nexusfilename,
     EventWorkspaceCollection_sptr localWorkspace,
     const std::string &top_entry_name, Algorithm *alg,
-    const std::shared_ptr<NexusHDF5Descriptor> &descriptor) {
+    const Kernel::NexusHDF5Descriptor *descriptor) {
   auto ws = localWorkspace->getSingleHeldWorkspace();
   auto hasLoaded = runLoadInstrument<MatrixWorkspace_sptr>(
       nexusfilename, ws, top_entry_name, alg, descriptor);
diff --git a/Framework/DataHandling/src/LoadNexusLogs.cpp b/Framework/DataHandling/src/LoadNexusLogs.cpp
index faf5bb4567e..983c1941724 100644
--- a/Framework/DataHandling/src/LoadNexusLogs.cpp
+++ b/Framework/DataHandling/src/LoadNexusLogs.cpp
@@ -729,16 +729,10 @@ void LoadNexusLogs::loadLogs(
 void LoadNexusLogs::loadNXLog(
     ::NeXus::File &file, const std::string &absolute_entry_name,
     const std::string &entry_class,
-<<<<<<< HEAD
     const std::shared_ptr<API::MatrixWorkspace> &workspace) const {
-  g_log.debug() << "processing " << entry_name << ":" << entry_class << "\n";
-=======
-    const boost::shared_ptr<API::MatrixWorkspace> &workspace) const {
->>>>>>> Refactored LoadNexusLogs
 
   const std::string entry_name =
       absolute_entry_name.substr(absolute_entry_name.find_last_of("/") + 1);
-
   g_log.debug() << "processing " << entry_name << ":" << entry_class << "\n";
   file.openGroup(entry_name, entry_class);
   // Validate the NX log class.
@@ -795,17 +789,12 @@ void LoadNexusLogs::loadNXLog(
  * @param workspace :: A pointer to the workspace to store the logs
  */
 void LoadNexusLogs::loadSELog(
-<<<<<<< HEAD
-    ::NeXus::File &file, const std::string &entry_name,
+    ::NeXus::File &file, const std::string &absolute_entry_name,
     const std::shared_ptr<API::MatrixWorkspace> &workspace) const {
   // Open the entry
-=======
-    ::NeXus::File &file, const std::string &absolute_entry_name,
-    const boost::shared_ptr<API::MatrixWorkspace> &workspace) const {
-
   const std::string entry_name =
       absolute_entry_name.substr(absolute_entry_name.find_last_of("/") + 1);
->>>>>>> Refactored LoadNexusLogs
+
   file.openGroup(entry_name, "IXseblock");
   std::string propName = entry_name;
   if (workspace->run().hasProperty(propName)) {
diff --git a/Framework/Kernel/src/NexusHDF5Descriptor.cpp b/Framework/Kernel/src/NexusHDF5Descriptor.cpp
index 696f886aa28..aed0a895af3 100644
--- a/Framework/Kernel/src/NexusHDF5Descriptor.cpp
+++ b/Framework/Kernel/src/NexusHDF5Descriptor.cpp
@@ -246,7 +246,7 @@ bool NexusHDF5Descriptor::isEntry(const std::string &entryName,
 
 bool NexusHDF5Descriptor::isEntry(const std::string &entryName) const noexcept {
 
-  for (auto itClass = m_allEntries.cbegin(); itClass != m_allEntries.cend();
+  for (auto itClass = m_allEntries.rbegin(); itClass != m_allEntries.rend();
        ++itClass) {
     if (itClass->second.count(entryName) == 1) {
       return true;
-- 
GitLab