From 7727efdc005db912e69d93c80bd2716cda98dee6 Mon Sep 17 00:00:00 2001
From: Alex Buts <Alex.Buts@stfc.ac.uk>
Date: Fri, 5 Apr 2013 23:42:06 +0100
Subject: [PATCH] Refs #6449 Fixing Unix compiler issues.

---
 .../Framework/Kernel/inc/MantidKernel/DiskBuffer.h   |  8 ++++----
 .../Framework/Kernel/inc/MantidKernel/ISaveable.h    |  6 +++---
 Code/Mantid/Framework/Kernel/src/DiskBuffer.cpp      |  4 ++--
 Code/Mantid/Framework/Kernel/src/ISaveable.cpp       | 10 ++++++----
 .../MDEvents/inc/MantidMDEvents/BoxControllerNxSIO.h |  4 ++--
 .../Framework/MDEvents/inc/MantidMDEvents/MDBox.h    |  4 ++--
 .../MDEvents/inc/MantidMDEvents/MDGridBox.h          |  6 ++----
 .../Framework/MDEvents/src/BoxControllerNxSIO.cpp    | 12 +++++++++---
 Code/Mantid/Framework/MDEvents/src/MDBox.cpp         |  6 ++++++
 Code/Mantid/Framework/MDEvents/src/MDGridBox.cpp     | 12 ++++++++++--
 10 files changed, 46 insertions(+), 26 deletions(-)

diff --git a/Code/Mantid/Framework/Kernel/inc/MantidKernel/DiskBuffer.h b/Code/Mantid/Framework/Kernel/inc/MantidKernel/DiskBuffer.h
index 3fd1d63f784..671e92e5b6e 100644
--- a/Code/Mantid/Framework/Kernel/inc/MantidKernel/DiskBuffer.h
+++ b/Code/Mantid/Framework/Kernel/inc/MantidKernel/DiskBuffer.h
@@ -14,7 +14,7 @@
 #include <map>
 #include <stdint.h>
 #include <vector>
-#include <forward_list>
+#include <list>
 
 namespace Mantid
 {
@@ -77,9 +77,9 @@ namespace Kernel
     DiskBuffer(uint64_t m_writeBufferSize);
     virtual ~DiskBuffer();
 
-    void toWrite(ISaveable * const item);
+    void toWrite(ISaveable *  item);
     void flushCache();
-    void objectDeleted(ISaveable *const item);
+    void objectDeleted(ISaveable * item);
 
     // Free space map methods
     void freeBlock(uint64_t const pos, uint64_t const fileSize);
@@ -143,7 +143,7 @@ namespace Kernel
     /// number of objects stored in to write buffer list
     size_t m_nObjectsToWrite;
     /** A forward list for the buffer of "toWrite" objects.   */
-    std::list<ISaveable * const> m_toWriteBuffer;
+    std::list<ISaveable * > m_toWriteBuffer;
 
     /// Mutex for modifying the the toWrite buffer.
     Kernel::Mutex m_mutex;
diff --git a/Code/Mantid/Framework/Kernel/inc/MantidKernel/ISaveable.h b/Code/Mantid/Framework/Kernel/inc/MantidKernel/ISaveable.h
index ae8631966b7..3cf478359c6 100644
--- a/Code/Mantid/Framework/Kernel/inc/MantidKernel/ISaveable.h
+++ b/Code/Mantid/Framework/Kernel/inc/MantidKernel/ISaveable.h
@@ -107,7 +107,7 @@ namespace Kernel
     Kernel::Mutex m_setter; 
   private:
     // the iterator which describes the position of this object in the DiskBuffer. Undefined if not placed to buffer
-    boost::optional< std::list<ISaveable * const >::iterator> m_BufPosition;
+    boost::optional< std::list<ISaveable * >::iterator> m_BufPosition;
     // the size of the object in the memory buffer, used to calculate the total amount of memory the objects occupy
     size_t m_BufMemorySize;
 
@@ -120,9 +120,9 @@ namespace Kernel
     void saveAt(uint64_t newPos, uint64_t newSize);
 
     /// sets the iterator pointing to the location of this object in the memory buffer to write later
-    size_t setBufferPosition(std::list<ISaveable *const >::iterator &bufPosition);
+    size_t setBufferPosition(std::list<ISaveable * >::iterator bufPosition);
     /// returns the iterator pointing to the position of this object within the memory to-write buffer
-    boost::optional<std::list<ISaveable *const>::iterator > & getBufPostion()
+    boost::optional<std::list<ISaveable *>::iterator > & getBufPostion()
     {return m_BufPosition;}
     /// return the amount of memory, this object had when it was stored in buffer last time;
     size_t getBufferSize()const{return m_BufMemorySize;}
diff --git a/Code/Mantid/Framework/Kernel/src/DiskBuffer.cpp b/Code/Mantid/Framework/Kernel/src/DiskBuffer.cpp
index 1485d4fdc64..26a6cfc7730 100644
--- a/Code/Mantid/Framework/Kernel/src/DiskBuffer.cpp
+++ b/Code/Mantid/Framework/Kernel/src/DiskBuffer.cpp
@@ -98,7 +98,7 @@ namespace Kernel
    *
    * @param item :: ISaveable object that is getting deleted.
    */
-  void DiskBuffer::objectDeleted(ISaveable *const item)
+  void DiskBuffer::objectDeleted(ISaveable * item)
   {
     // have it ever been in the buffer?
     auto opt2it = item->getBufPostion();
@@ -133,7 +133,7 @@ namespace Kernel
 
     m_mutex.lock();
     // Holder for any objects that you were NOT able to write.
-    std::list<ISaveable *const> couldNotWrite;
+    std::list<ISaveable *> couldNotWrite;
     size_t objectsNotWritten(0);
     size_t memoryNotWritten(0);
 
diff --git a/Code/Mantid/Framework/Kernel/src/ISaveable.cpp b/Code/Mantid/Framework/Kernel/src/ISaveable.cpp
index fea1a57b910..b7a21397e22 100644
--- a/Code/Mantid/Framework/Kernel/src/ISaveable.cpp
+++ b/Code/Mantid/Framework/Kernel/src/ISaveable.cpp
@@ -18,7 +18,9 @@ namespace Kernel
   //----------------------------------------------------------------------------------------------
   /** Copy constructor --> needed for std containers and not to copy mutexes   */
   ISaveable::ISaveable(const ISaveable & other):
-     m_fileIndexStart(other.m_fileIndexStart),m_fileNumEvents(other.m_fileNumEvents)
+     m_fileIndexStart(other.m_fileIndexStart),m_fileNumEvents(other.m_fileNumEvents),
+     m_BufPosition(other.m_BufPosition),
+     m_BufMemorySize(other.m_BufMemorySize)
  { }
 
   //ISaveable::ISaveable(const size_t fileId):
@@ -30,10 +32,10 @@ namespace Kernel
    * @param bufPosition -- the allocator which specifies the position of the object in the list of objects to write
    * @returns the size of the object it currently occupies in memory. This size is also stored by the object itself for further references
   */
-  size_t ISaveable::setBufferPosition(std::list<ISaveable *const>::iterator &bufPosition)
+  size_t ISaveable::setBufferPosition(std::list<ISaveable *>::iterator bufPosition)
   {
       m_setter.lock();
-      m_BufPosition = boost::optional<std::list<ISaveable *const>::iterator >(bufPosition);
+      m_BufPosition = boost::optional<std::list<ISaveable *>::iterator >(bufPosition);
       m_BufMemorySize  = this->getDataMemorySize();
       m_setter.unlock();
       return m_BufMemorySize ;
@@ -59,7 +61,7 @@ namespace Kernel
   {
       m_setter.lock();
       m_BufMemorySize=0;
-      m_BufPosition = boost::optional<std::list<ISaveable *const>::iterator>();
+      m_BufPosition = boost::optional<std::list<ISaveable *>::iterator>();
       m_setter.unlock();
   }
 } // namespace Mantid
diff --git a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/BoxControllerNxSIO.h b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/BoxControllerNxSIO.h
index d8434f6e484..8fb7b8de6e1 100644
--- a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/BoxControllerNxSIO.h
+++ b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/BoxControllerNxSIO.h
@@ -81,7 +81,7 @@ namespace MDEvents
             ::NeXus::File * getFile(){return m_File;}
     private:
         /// Default size of the events block which can be written in the NeXus array at once identified by efficiency or some other external reasons
-        static enum {DATA_CHUNK=10000};
+        enum {DATA_CHUNK=10000};
 
         /// full file name (with path) of the Nexis file responsible for the IO operations (as NeXus filename has very strange properties and often truncated to 64 bytes)
         std::string m_fileName;
@@ -106,7 +106,7 @@ namespace MDEvents
         unsigned int m_CoordSize;
         /// possible event types this class understands. The enum numbers have to correspond to the numbers of symbolic event types, 
         /// defined in EVENT_TYPES_SUPPORTED vector
-        static enum EventType
+        enum EventType
         {
             LeanEvent=0, //< the event consisting of signal error and event coordinate
             FatEvent=1   //< the event havint the same as lean event plus RunID and detID
diff --git a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBox.h b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBox.h
index 1848ae48add..09eb4f074f4 100644
--- a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBox.h
+++ b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBox.h
@@ -120,8 +120,8 @@ namespace MDEvents
     // add range of events 
     virtual size_t addEvents(const std::vector<MDE> & events);
     // unhide MDBoxBase methods
-    virtual size_t addEventsUnsafe(const std::vector<MDE> & events)
-    {return MDBoxBase::addEventsUnsafe( events);}
+    virtual size_t addEventsUnsafe(const std::vector<MDE> & events);
+
 
     /*--------------->  EVENTS from event data              <-------------------------------------------------------------*/
     virtual void addEvent(const signal_t Signal,const signal_t errorSq,const std::vector<coord_t> &point, uint16_t runIndex,uint32_t detectorId);
diff --git a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDGridBox.h b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDGridBox.h
index 9e5f2ce0e74..d77ed859764 100644
--- a/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDGridBox.h
+++ b/Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDGridBox.h
@@ -104,10 +104,8 @@ namespace MDEvents
     void addEventUnsafe(const MDE & event);
     void addAndTraceEvent(const MDE & point,size_t index);
     // unhide MDBoxBase methods
-    virtual size_t addEvents(const std::vector<MDE> & events)
-    { return MDBoxBase::addEvents(events); }
-    virtual size_t addEventsUnsafe(const std::vector<MDE> & events)
-    {return MDBoxBase::addEventsUnsafe( events);}
+    virtual size_t addEvents(const std::vector<MDE> & events);
+    virtual size_t addEventsUnsafe(const std::vector<MDE> & events);
 
 
     /*--------------->  EVENTS from event data              <-------------------------------------------------------------*/
diff --git a/Code/Mantid/Framework/MDEvents/src/BoxControllerNxSIO.cpp b/Code/Mantid/Framework/MDEvents/src/BoxControllerNxSIO.cpp
index e8cb4933475..73734be59f6 100644
--- a/Code/Mantid/Framework/MDEvents/src/BoxControllerNxSIO.cpp
+++ b/Code/Mantid/Framework/MDEvents/src/BoxControllerNxSIO.cpp
@@ -2,7 +2,7 @@
 #include "MantidMDEvents/MDBoxFlatTree.h"
 #include "MantidKernel/Exception.h"
 #include "MantidAPI/FileFinder.h"
-#include <NeXusFile.hpp>
+#include <nexus/NeXusFile.hpp>
 
 #include <string>
 
@@ -35,8 +35,14 @@ namespace MDEvents
    {
        m_BlockSize[1] = 4+m_bc->getNDims();
 
-       m_EventsTypesSupported.assign(EventTypes,std::end(EventTypes));
-       m_EventsTypeHeaders.assign(EventHeaders,std::end(EventHeaders));
+       for(size_t  i=0;i<2;i++)
+       {
+           m_EventsTypesSupported.push_back(EventTypes[i]);
+           m_EventsTypeHeaders.push_back(EventHeaders[i]);
+       }
+
+       //m_EventsTypesSupported.assign(EventTypes,std::end(EventTypes));
+       //m_EventsTypeHeaders.assign(EventHeaders,std::end(EventHeaders));
    }
    /**get event type form its string representation*/ 
    BoxControllerNxSIO::EventType BoxControllerNxSIO::TypeFromString(const std::vector<std::string> &typesSupported,const std::string typeName)
diff --git a/Code/Mantid/Framework/MDEvents/src/MDBox.cpp b/Code/Mantid/Framework/MDEvents/src/MDBox.cpp
index 9f4ff19d05d..389582f6b95 100644
--- a/Code/Mantid/Framework/MDEvents/src/MDBox.cpp
+++ b/Code/Mantid/Framework/MDEvents/src/MDBox.cpp
@@ -117,6 +117,12 @@ namespace MDEvents
 
     }
   }
+  // unhide MDBoxBase method
+  TMDE(
+  size_t MDBox)::addEventsUnsafe(const std::vector<MDE> & events)
+  {
+      return MDBoxBase<MDE,nd>::addEventsUnsafe( events);
+  }
 
 
   //-----------------------------------------------------------------------------------------------
diff --git a/Code/Mantid/Framework/MDEvents/src/MDGridBox.cpp b/Code/Mantid/Framework/MDEvents/src/MDGridBox.cpp
index 8738121512d..1f07141e917 100644
--- a/Code/Mantid/Framework/MDEvents/src/MDGridBox.cpp
+++ b/Code/Mantid/Framework/MDEvents/src/MDGridBox.cpp
@@ -38,8 +38,16 @@ namespace MDEvents
   // : MDBoxBase<MDE, nd>(), numBoxes(0), nPoints(0)
   //{
   //}
- 
-
+   template<typename MDE,size_t nd>
+    size_t MDGridBox<MDE,nd>::addEvents(const std::vector<MDE> & events)
+    {
+        return MDBoxBase<MDE,nd>::addEvents(events);
+    }
+   template<typename MDE,size_t nd>
+   size_t MDGridBox<MDE,nd>::addEventsUnsafe(const std::vector<MDE> & events)
+   {
+        return MDBoxBase<MDE,nd>::addEventsUnsafe( events);
+   }
 
   //-----------------------------------------------------------------------------------------------
   /** Constructor with a box controller.
-- 
GitLab