diff --git a/Framework/API/inc/MantidAPI/Workspace.h b/Framework/API/inc/MantidAPI/Workspace.h index e089fb57640b80ad560951268dde19b106a96085..f40ee894978442a0450f9cf36db06eb6bcfa06dc 100644 --- a/Framework/API/inc/MantidAPI/Workspace.h +++ b/Framework/API/inc/MantidAPI/Workspace.h @@ -1,9 +1,6 @@ #ifndef MANTID_API_WORKSPACE_H_ #define MANTID_API_WORKSPACE_H_ -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- #include "MantidAPI/Workspace_fwd.h" #include "MantidAPI/WorkspaceHistory.h" #include "MantidAPI/DllConfig.h" @@ -12,17 +9,11 @@ namespace Mantid { -//---------------------------------------------------------------------- -// Forward Declaration -//---------------------------------------------------------------------- namespace Kernel { class Logger; } namespace API { -//---------------------------------------------------------------------- -// Forward Declaration -//---------------------------------------------------------------------- class AnalysisDataServiceImpl; /** Base Workspace Abstract Class. @@ -53,7 +44,8 @@ class AnalysisDataServiceImpl; */ class MANTID_API_DLL Workspace : public Kernel::DataItem { public: - Workspace() = default; + Workspace(); + ~Workspace(); /** Returns a clone (copy) of the workspace with covariant return type in all * derived classes. @@ -99,13 +91,13 @@ public: std::string getMemorySizeAsStr() const; /// Returns a reference to the WorkspaceHistory - WorkspaceHistory &history() { return m_history; } + WorkspaceHistory &history() { return *m_history; } /// Returns a reference to the WorkspaceHistory const - const WorkspaceHistory &getHistory() const { return m_history; } + const WorkspaceHistory &getHistory() const { return *m_history; } protected: /// Protected copy constructor. May be used by childs for cloning. - Workspace(const Workspace &) = default; + Workspace(const Workspace &); private: void setName(const std::string &); @@ -117,7 +109,7 @@ private: /// workspace algebra std::string m_name; /// The history of the workspace, algorithm and environment - WorkspaceHistory m_history; + std::unique_ptr<WorkspaceHistory> m_history; /// Virtual clone method. Not implemented to force implementation in childs. virtual Workspace *doClone() const = 0; diff --git a/Framework/API/src/Workspace.cpp b/Framework/API/src/Workspace.cpp index d6d8f9b830042b6f614f45d8b3c73908139ba922..b65fb680d35d0f5cbf3ae946c1b62017bc1757d2 100644 --- a/Framework/API/src/Workspace.cpp +++ b/Framework/API/src/Workspace.cpp @@ -1,12 +1,24 @@ #include "MantidAPI/Workspace.h" +#include "MantidAPI/WorkspaceHistory.h" #include "MantidKernel/IPropertyManager.h" #include "MantidKernel/Memory.h" +#include "MantidKernel/make_unique.h" #include <boost/lexical_cast.hpp> namespace Mantid { namespace API { +Workspace::Workspace() : m_history(Kernel::make_unique<WorkspaceHistory>()) {} + +// Defined as default in source for forward declaration with std::unique_ptr. +Workspace::~Workspace() = default; + +Workspace::Workspace(const Workspace &other) + : Kernel::DataItem(other), m_title(other.m_title), + m_comment(other.m_comment), m_name(other.m_name), + m_history(Kernel::make_unique<WorkspaceHistory>(other.getHistory())) {} + /** Set the title of the workspace * * @param t :: The title @@ -55,7 +67,7 @@ const std::string &Workspace::getName() const { return m_name; } * @param n: number of algorithms defining a clean workspace */ bool Workspace::isDirty(const int n) const { - return static_cast<int>(m_history.size()) > n; + return static_cast<int>(m_history->size()) > n; } /** @@ -109,4 +121,4 @@ IPropertyManager::getValue<Mantid::API::Workspace_const_sptr>( } // namespace Kernel } // namespace Mantid -///\endcond TEMPLATE + ///\endcond TEMPLATE