diff --git a/Framework/API/inc/MantidAPI/Algorithm.h b/Framework/API/inc/MantidAPI/Algorithm.h index aa4307326bd54867bac6dc99004375c93d7656bb..0e7da02e52ec45961ae2b26dbc54ae694eac052b 100644 --- a/Framework/API/inc/MantidAPI/Algorithm.h +++ b/Framework/API/inc/MantidAPI/Algorithm.h @@ -92,52 +92,40 @@ class MANTID_API_DLL Algorithm : public IAlgorithm, public Kernel::PropertyManagerOwner { public: /// Base class for algorithm notifications - class AlgorithmNotification : public Poco::Notification { + class MANTID_API_DLL AlgorithmNotification : public Poco::Notification { public: - AlgorithmNotification(const Algorithm *const alg) - : Poco::Notification(), m_algorithm(alg) {} ///< Constructor - const IAlgorithm *algorithm() const { - return m_algorithm; - } ///< The algorithm + AlgorithmNotification(const Algorithm *const alg); + const IAlgorithm *algorithm() const; + private: const IAlgorithm *const m_algorithm; ///< The algorithm }; /// StartedNotification is sent when the algorithm begins execution. - class StartedNotification : public AlgorithmNotification { + class MANTID_API_DLL StartedNotification : public AlgorithmNotification { public: - StartedNotification(const Algorithm *const alg) - : AlgorithmNotification(alg) {} ///< Constructor - std::string name() const override { - return "StartedNotification"; - } ///< class name + StartedNotification(const Algorithm *const alg); + std::string name() const override; }; /// FinishedNotification is sent after the algorithm finishes its execution - class FinishedNotification : public AlgorithmNotification { + class MANTID_API_DLL FinishedNotification : public AlgorithmNotification { public: - FinishedNotification(const Algorithm *const alg, bool res) - : AlgorithmNotification(alg), success(res) {} ///< Constructor - std::string name() const override { - return "FinishedNotification"; - } ///< class name + FinishedNotification(const Algorithm *const alg, bool res); + std::string name() const override; bool success; ///< true if the finished algorithm was successful or false if /// it failed. }; /// An algorithm can report its progress by sending ProgressNotification. Use /// Algorithm::progress(double) function to send a progress notification. - class ProgressNotification : public AlgorithmNotification { + class MANTID_API_DLL ProgressNotification : public AlgorithmNotification { public: /// Constructor ProgressNotification(const Algorithm *const alg, double p, const std::string &msg, double estimatedTime, - int progressPrecision) - : AlgorithmNotification(alg), progress(p), message(msg), - estimatedTime(estimatedTime), progressPrecision(progressPrecision) {} - std::string name() const override { - return "ProgressNotification"; - } ///< class name + int progressPrecision); + std::string name() const override; double progress; ///< Current progress. Value must be between 0 and 1. std::string message; ///< Message sent with notification double estimatedTime; ///<Estimated time to completion @@ -147,14 +135,11 @@ public: /// ErrorNotification is sent when an exception is caught during execution of /// the algorithm. - class ErrorNotification : public AlgorithmNotification { + class MANTID_API_DLL ErrorNotification : public AlgorithmNotification { public: /// Constructor - ErrorNotification(const Algorithm *const alg, const std::string &str) - : AlgorithmNotification(alg), what(str) {} - std::string name() const override { - return "ErrorNotification"; - } ///< class name + ErrorNotification(const Algorithm *const alg, const std::string &str); + std::string name() const override; std::string what; ///< message string }; @@ -165,14 +150,10 @@ public: /// periodically Algorithm::interuption_point() which checks if /// Algorithm::cancel() has been called /// and throws CancelException if needed. - class CancelException : public std::exception { + class MANTID_API_DLL CancelException : public std::exception { public: /// Returns the message string. - const char *what() const noexcept override { return outMessage.c_str(); } - - private: - /// The message returned by what() - std::string outMessage{"Algorithm terminated"}; + const char *what() const noexcept override; }; //============================================================================ diff --git a/Framework/API/src/Algorithm.cpp b/Framework/API/src/Algorithm.cpp index 92fe324c22e92feef6feea7673b9fecd41da4c23..48c38ae93ff69771e032206749817061bea7ac1c 100644 --- a/Framework/API/src/Algorithm.cpp +++ b/Framework/API/src/Algorithm.cpp @@ -1769,6 +1769,53 @@ void Algorithm::setCommunicator(const Parallel::Communicator &communicator) { m_communicator = Kernel::make_unique<Parallel::Communicator>(communicator); } +//--------------------------------------------------------------------------- +// Algorithm's inner classes +//--------------------------------------------------------------------------- + +Algorithm::AlgorithmNotification::AlgorithmNotification( + const Algorithm *const alg) + : Poco::Notification(), m_algorithm(alg) {} + +const IAlgorithm *Algorithm::AlgorithmNotification::algorithm() const { + return m_algorithm; +} + +Algorithm::StartedNotification::StartedNotification(const Algorithm *const alg) + : AlgorithmNotification(alg) {} +std::string Algorithm::StartedNotification::name() const { + return "StartedNotification"; +} ///< class name + +Algorithm::FinishedNotification::FinishedNotification( + const Algorithm *const alg, bool res) + : AlgorithmNotification(alg), success(res) {} +std::string Algorithm::FinishedNotification::name() const { + return "FinishedNotification"; +} + +Algorithm::ProgressNotification::ProgressNotification( + const Algorithm *const alg, double p, const std::string &msg, + double estimatedTime, int progressPrecision) + : AlgorithmNotification(alg), progress(p), message(msg), + estimatedTime(estimatedTime), progressPrecision(progressPrecision) {} + +std::string Algorithm::ProgressNotification::name() const { + return "ProgressNotification"; +} + +Algorithm::ErrorNotification::ErrorNotification(const Algorithm *const alg, + const std::string &str) + : AlgorithmNotification(alg), what(str) {} + +std::string Algorithm::ErrorNotification::name() const { + return "ErrorNotification"; +} + +const char *Algorithm::CancelException::what() const noexcept { + return "Algorithm terminated"; +} + } // namespace API //---------------------------------------------------------------------------