Mantid
Loading...
Searching...
No Matches
WorkspaceProperty.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
10#include "MantidKernel/Logger.h"
12
13#include <string>
14
15namespace Mantid {
16namespace API {
17// -------------------------------------------------------------------------
18// Forward decaration
19// -------------------------------------------------------------------------
20class MatrixWorkspace;
21class WorkspaceGroup;
22
24struct LockMode {
25 enum Type { Lock, NoLock };
26};
27
50template <typename TYPE = MatrixWorkspace>
51class WorkspaceProperty : public Kernel::PropertyWithValue<std::shared_ptr<TYPE>>, public IWorkspaceProperty {
52public:
53 explicit WorkspaceProperty(
54 const std::string &name, const std::string &wsName, const unsigned int direction,
56
57 explicit WorkspaceProperty(
58 const std::string &name, const std::string &wsName, const unsigned int direction,
59 const PropertyMode::Type optional,
61
62 explicit WorkspaceProperty(
63 const std::string &name, const std::string &wsName, const unsigned int direction,
64 const PropertyMode::Type optional, const LockMode::Type locking,
66
68
70
71 WorkspaceProperty &operator=(const std::shared_ptr<TYPE> &value) override;
72
74
75 WorkspaceProperty<TYPE> *clone() const override;
76
77 std::string value() const override;
78
79 Json::Value valueAsJson() const override;
80
81 bool isValueSerializable() const override;
82
83 std::string getDefault() const override;
84
85 std::string setValue(const std::string &value) override;
86
87 std::string setValueFromJson(const Json::Value &value) override;
88
89 std::string setDataItem(const std::shared_ptr<Kernel::DataItem> &value) override;
90
91 void setPropertyMode(const PropertyMode::Type &optional) override;
92
93 std::string isValid() const override;
94
95 bool isDefault() const override;
96
97 bool isOptional() const override;
98 bool isLocking() const override;
99
100 std::vector<std::string> allowedValues() const override;
101
102 const Kernel::PropertyHistory createHistory() const override;
103
104 bool store() override;
105
106 Workspace_sptr getWorkspace() const override;
107
108private:
109 std::string isValidGroup(const std::shared_ptr<WorkspaceGroup> &wsGroup) const;
110
111 std::string isValidOutputWs() const;
112
113 std::string isOptionalWs() const;
114
115 void clear() override;
116
118
120 std::string m_workspaceName;
122 std::string m_initialWSName;
129
132};
133
134template <typename TYPE> Kernel::Logger WorkspaceProperty<TYPE>::g_log("WorkspaceProperty");
135
136} // namespace API
137} // namespace Mantid
double right
An interface that is implemented by WorkspaceProperty.
A property class for workspaces.
std::string value() const override
Get the name of the workspace.
std::string setDataItem(const std::shared_ptr< Kernel::DataItem > &value) override
Set a value from a data item.
void setPropertyMode(const PropertyMode::Type &optional) override
Set the property mode of the property e.g.
std::string isOptionalWs() const
Checks whether the entered workspace (that by this point we've found is not in the ADS) is actually a...
std::string setValue(const std::string &value) override
Set the name of the workspace.
bool isLocking() const override
Does the workspace need to be locked before starting an algorithm?
std::string isValidGroup(const std::shared_ptr< WorkspaceGroup > &wsGroup) const
Checks whether the entered workspace group is valid.
WorkspaceProperty< TYPE > * clone() const override
'Virtual copy constructor'
std::string m_initialWSName
The name of the workspace that the this this object was created for.
Workspace_sptr getWorkspace() const override
Get a pointer to the workspace.
WorkspaceProperty & operator+=(Kernel::Property const *) override
Add the value of another property.
Json::Value valueAsJson() const override
std::string isValidOutputWs() const
Checks whether the entered output workspace is valid.
void retrieveWorkspaceFromADS()
Attempts to retreive the data from the ADS if the data is not foung the internal pointer is set to nu...
static Kernel::Logger g_log
for access to logging streams
std::string setValueFromJson(const Json::Value &value) override
Set the name of the workspace from a Json::Value object Also tries to retrieve it from the AnalysisDa...
bool isOptional() const override
Is the workspace property optional.
std::string getDefault() const override
Get the value the property was initialised with -its default value.
std::string isValid() const override
Checks whether the entered workspace is valid.
bool isValueSerializable() const override
Returns true if the workspace is in the ADS or there is none.
const Kernel::PropertyHistory createHistory() const override
Create a history record.
void clear() override
Reset the pointer to the workspace.
bool isDefault() const override
Indicates if the object is still pointing to the same workspace.
std::vector< std::string > allowedValues() const override
Returns the current contents of the AnalysisDataService for input workspaces.
WorkspaceProperty & operator=(const WorkspaceProperty &right)
Copy assignment operator.
PropertyMode::Type m_optional
A flag indicating whether the property should be considered optional.
std::string m_workspaceName
The name of the workspace (as used by the AnalysisDataService)
LockMode::Type m_locking
A flag indicating whether the workspace should be read or write-locked when an algorithm begins.
bool store() override
If this is an output workspace, store it into the AnalysisDataService.
The Logger class is in charge of the publishing messages from the framework through various channels.
Definition Logger.h:51
NullValidator is a validator that doesn't.
This class stores information about the parameters used by an algorithm.
The concrete, templated class for properties.
Base class for properties.
Definition Property.h:94
unsigned int direction() const
returns the direction of the property
Definition Property.h:177
const std::string & name() const
Get the property's name.
Definition Property.cpp:61
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< IValidator > IValidator_sptr
A shared_ptr to an IValidator.
Definition IValidator.h:26
Helper class which provides the Collimation Length for SANS instruments.
Enumeration for locking behaviour.