Mantid
|
The WorkspaceFactory class is in charge of the creation of all types of workspaces. More...
#include <WorkspaceFactory.h>
Public Member Functions | |
MatrixWorkspace_sptr | create (const MatrixWorkspace_const_sptr &parent, size_t NVectors=size_t(-1), size_t XLength=size_t(-1), size_t YLength=size_t(-1)) const |
Create a new instance of the same type of workspace as that given as argument. More... | |
MatrixWorkspace_sptr | create (const std::string &className, const size_t &NVectors, const size_t &XLength, const size_t &YLength) const |
Creates a new instance of the class with the given name, and allocates memory for the arrays. More... | |
std::shared_ptr< IPeaksWorkspace > | createPeaks (const std::string &className="PeaksWorkspace") const |
Create a IPeaksWorkspace. More... | |
std::shared_ptr< ITableWorkspace > | createTable (const std::string &className="TableWorkspace") const |
Create a ITableWorkspace. More... | |
void | initializeFromParent (const MatrixWorkspace &parent, MatrixWorkspace &child, const bool differentSize) const |
Initialize a workspace from its parent This sets values such as title, instrument, units, sample, spectramap. More... | |
WorkspaceFactoryImpl & | operator= (const WorkspaceFactoryImpl &)=delete |
WorkspaceFactoryImpl (const WorkspaceFactoryImpl &)=delete | |
Public Member Functions inherited from Mantid::Kernel::DynamicFactory< Workspace > | |
virtual std::shared_ptr< Workspace > | create (const std::string &className) const |
Creates a new instance of the class with the given name. More... | |
virtual Workspace * | createUnwrapped (const std::string &className) const |
Creates a new instance of the class with the given name, which is not wrapped in a boost shared_ptr. More... | |
void | disableNotifications () |
Disable notifications. More... | |
DynamicFactory (const DynamicFactory &)=delete | |
void | enableNotifications () |
Enable notifications. More... | |
bool | exists (const std::string &className) const |
Returns true if the given class is currently registered. More... | |
virtual const std::vector< std::string > | getKeys () const |
Returns the keys in the map. More... | |
DynamicFactory & | operator= (const DynamicFactory &)=delete |
void | subscribe (const std::string &className) |
Registers the instantiator for the given class with the DynamicFactory. More... | |
void | subscribe (const std::string &className, std::unique_ptr< AbstractFactory > pAbstractFactory, SubscribeAction replace=ErrorIfExists) |
Registers the instantiator for the given class with the DynamicFactory. More... | |
void | unsubscribe (const std::string &className) |
Unregisters the given class and deletes the instantiator for the class. More... | |
virtual | ~DynamicFactory ()=default |
Destroys the DynamicFactory and deletes the instantiators for all registered classes. More... | |
Private Member Functions | |
WorkspaceFactoryImpl () | |
Private Constructor for singleton class. More... | |
~WorkspaceFactoryImpl () override=default | |
Private Destructor. More... | |
Friends | |
struct | Mantid::Kernel::CreateUsingNew< WorkspaceFactoryImpl > |
Additional Inherited Members | |
Public Types inherited from Mantid::Kernel::DynamicFactory< Workspace > | |
using | AbstractFactory = AbstractInstantiator< Workspace > |
A typedef for the instantiator. More... | |
enum | NotificationStatus |
Defines the whether notifications are dispatched. More... | |
enum | SubscribeAction |
Defines replacement behaviour. More... | |
Public Attributes inherited from Mantid::Kernel::DynamicFactory< Workspace > | |
Poco::NotificationCenter | notificationCenter |
Sends notifications to observers. More... | |
Protected Member Functions inherited from Mantid::Kernel::DynamicFactory< Workspace > | |
DynamicFactory () | |
Protected constructor for base class. More... | |
The WorkspaceFactory class is in charge of the creation of all types of workspaces.
It inherits most of its implementation from the Dynamic Factory base class. It is implemented as a singleton class.
Definition at line 44 of file WorkspaceFactory.h.
|
delete |
|
private |
Private Constructor for singleton class.
Private constructor for singleton class.
Definition at line 28 of file WorkspaceFactory.cpp.
References Mantid::Kernel::Logger::debug(), and Mantid::API::g_log.
|
overrideprivatedefault |
Private Destructor.
MatrixWorkspace_sptr Mantid::API::WorkspaceFactoryImpl::create | ( | const MatrixWorkspace_const_sptr & | parent, |
size_t | NVectors = size_t(-1) , |
||
size_t | XLength = size_t(-1) , |
||
size_t | YLength = size_t(-1) |
||
) | const |
Create a new instance of the same type of workspace as that given as argument.
If the optional size parameters are given, the workspace will be initialised using those; otherwise it will be initialised to the same size as the parent. This method should be used when you want to carry over the Workspace data members relating to the Instrument, Spectra-Detector Map, Sample & Axes to the new workspace. If the workspace is the same size as its parent, then the X data, axes and mask list are copied. If its a different size then they are not.
parent | A shared pointer to the parent workspace |
NVectors | (Optional) The number of vectors/histograms/detectors in the workspace |
XLength | (Optional) The number of X data points/bin boundaries in each vector (must all be the same) |
YLength | (Optional) The number of data/error points in each vector (must all be the same) |
std::out_of_range | If invalid (0 or less) size arguments are given |
NotFoundException | If the class is not registered in the factory |
Definition at line 57 of file WorkspaceFactory.cpp.
References create(), and initializeFromParent().
Referenced by create(), createPeaks(), createTable(), and export_WorkspaceFactory().
MatrixWorkspace_sptr Mantid::API::WorkspaceFactoryImpl::create | ( | const std::string & | className, |
const size_t & | NVectors, | ||
const size_t & | XLength, | ||
const size_t & | YLength | ||
) | const |
Creates a new instance of the class with the given name, and allocates memory for the arrays.
className | The name of the class you wish to create |
NVectors | The number of vectors/histograms/detectors in the workspace |
XLength | The number of X data points/bin boundaries in each vector (must all be the same) |
YLength | The number of data/error points in each vector (must all be the same) |
std::out_of_range | If invalid (0 or less) size arguments are given |
NotFoundException | If the class is not registered in the factory |
Definition at line 163 of file WorkspaceFactory.cpp.
References create(), Mantid::Kernel::Logger::error(), and Mantid::API::g_log.
IPeaksWorkspace_sptr Mantid::API::WorkspaceFactoryImpl::createPeaks | ( | const std::string & | className = "PeaksWorkspace" | ) | const |
Create a IPeaksWorkspace.
Definition at line 191 of file WorkspaceFactory.cpp.
References create().
Referenced by export_WorkspaceFactory().
ITableWorkspace_sptr Mantid::API::WorkspaceFactoryImpl::createTable | ( | const std::string & | className = "TableWorkspace" | ) | const |
Create a ITableWorkspace.
Definition at line 177 of file WorkspaceFactory.cpp.
References create().
Referenced by export_WorkspaceFactory().
void Mantid::API::WorkspaceFactoryImpl::initializeFromParent | ( | const MatrixWorkspace & | parent, |
MatrixWorkspace & | child, | ||
const bool | differentSize | ||
) | const |
Initialize a workspace from its parent This sets values such as title, instrument, units, sample, spectramap.
This does NOT copy any data.
parent | :: the parent workspace |
child | :: the child workspace |
differentSize | :: A flag to indicate if the two workspace will be different sizes |
Definition at line 95 of file WorkspaceFactory.cpp.
References Mantid::API::ExperimentInfo::copyExperimentInfoFrom(), Mantid::API::ISpectrum::copyInfoFrom(), Mantid::API::Workspace::getComment(), Mantid::API::MatrixWorkspace::getNumberHistograms(), Mantid::API::MatrixWorkspace::getSpectrum(), Mantid::API::MatrixWorkspace::getTitle(), Mantid::API::MatrixWorkspace::indexInfo(), Mantid::API::MatrixWorkspace::isDistribution(), Mantid::API::MatrixWorkspace::m_axes, Mantid::API::MatrixWorkspace::m_isInitialized, Mantid::API::MatrixWorkspace::m_masks, Mantid::API::MatrixWorkspace::m_YUnit, Mantid::API::MatrixWorkspace::m_YUnitLabel, Mantid::API::Workspace::setComment(), Mantid::API::MatrixWorkspace::setDistribution(), Mantid::API::MatrixWorkspace::setIndexInfoWithoutISpectrumUpdate(), Mantid::API::MatrixWorkspace::setTitle(), Mantid::API::MatrixWorkspace::setYUnit(), and Mantid::API::MatrixWorkspace::setYUnitLabel().
Referenced by create().
|
delete |
References Mantid::DataObjects::create().
|
friend |
Definition at line 59 of file WorkspaceFactory.h.