Newer
Older
#ifndef MANTID_DATAHANDLING_LOAD_H_
#define MANTID_DATAHANDLING_LOAD_H_
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/Algorithm.h"
#include <Poco/Mutex.h>
namespace Mantid
{
namespace DataHandling
/**
Loads a workspace from a data file. The algorithm tries to determine the actual type
of the file (raw, nxs, ...) and use the specialized loading algorithm to load it.
Copyright © 2007-2013 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport Load : public API::Algorithm
Sofia Antony
committed
/// Default constructor
Gigg, Martyn Anthony
committed
Load();
Sofia Antony
committed
/// Algorithm's name for identification overriding a virtual method
virtual const std::string name() const { return "Load"; }
///Summary of algorithms purpose
virtual const std::string summary() const {return "Attempts to load a given file by finding an appropriate Load algorithm.";}
Sofia Antony
committed
/// Algorithm's version for identification overriding a virtual method
Janik Zikovsky
committed
virtual int version() const { return 1; }
Gigg, Martyn Anthony
committed
/// Category
virtual const std::string category() const { return "DataHandling"; }
/// Aliases
virtual const std::string alias() const { return "load"; }
Gigg, Martyn Anthony
committed
/// Override setPropertyValue
virtual void setPropertyValue(const std::string &name, const std::string &value);
Gigg, Martyn Anthony
committed
Gigg, Martyn Anthony
committed
private:
Gigg, Martyn Anthony
committed
/// This method returns shared pointer to a load algorithm which got
/// the highest preference after file check.
API::IAlgorithm_sptr getFileLoader(const std::string& filePath);
void findFilenameProperty(const API::IAlgorithm_sptr & loader);
Gigg, Martyn Anthony
committed
/// Declare any additional input properties from the concrete loader
void declareLoaderProperties(const API::IAlgorithm_sptr & loader);
Gigg, Martyn Anthony
committed
/// Initialize the static base properties
Gigg, Martyn Anthony
committed
/// Execute
/// Called when there is only one file to load.
void loadSingleFile();
/// Called when there are multiple files to load.
void loadMultipleFiles();
Roman Tolchenov
committed
/// Overrides the cancel() method to call m_loader->cancel()
Gigg, Martyn Anthony
committed
/// Create the concrete instance use for the actual loading.
API::IAlgorithm_sptr createLoader(const double startProgress = -1.0,
const double endProgress=-1.0, const bool logging = true) const;
/// Set the loader option for use as a Child Algorithm.
void setUpLoader(API::IAlgorithm_sptr & loader, const double startProgress = -1.0,
const double endProgress=-1.0, const bool logging = true) const;
void setOutputWorkspace(const API::IAlgorithm_sptr & loader);
/// Retrieve a pointer to the output workspace from the Child Algorithm
Gigg, Martyn Anthony
committed
API::Workspace_sptr getOutputWorkspace(const std::string & propName,
const API::IAlgorithm_sptr & loader) const;
Gigg, Martyn Anthony
committed
/// Load a file to a given workspace name.
API::Workspace_sptr loadFileToWs(const std::string & fileName, const std::string & wsName);
/// Plus two workspaces together, "in place".
API::Workspace_sptr plusWs(API::Workspace_sptr ws1, API::Workspace_sptr ws2);
/// Manually group workspaces.
API::WorkspaceGroup_sptr groupWsList(const std::vector<API::Workspace_sptr> & wsList);
Gigg, Martyn Anthony
committed
/// The base properties
std::set<std::string> m_baseProps;
Roman Tolchenov
committed
/// The actual loader
API::IAlgorithm_sptr m_loader;
/// The name of the property that will be passed the property from our Filename
std::string m_filenamePropName;
/// Mutex for temporary fix for #5963
static Poco::Mutex m_mutex;
} // namespace DataHandling
} // namespace Mantid
#endif /* MANTID_DATAHANDLING_LOAD_H_ */