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
26};
28struct LockMode {
29 enum Type { Lock, NoLock };
30};
31
54template <typename TYPE = MatrixWorkspace>
55class WorkspaceProperty : public Kernel::PropertyWithValue<std::shared_ptr<TYPE>>, public IWorkspaceProperty {
56public:
58 const std::string &name, const std::string &wsName, const unsigned int direction,
60
62 const std::string &name, const std::string &wsName, const unsigned int direction,
63 const PropertyMode::Type optional,
65
67 const std::string &name, const std::string &wsName, const unsigned int direction,
68 const PropertyMode::Type optional, const LockMode::Type locking,
70
72
74
75 WorkspaceProperty &operator=(const std::shared_ptr<TYPE> &value) override;
76
78
79 WorkspaceProperty<TYPE> *clone() const override;
80
81 std::string value() const override;
82
83 Json::Value valueAsJson() const override;
84
85 bool isValueSerializable() const override;
86
87 std::string getDefault() const override;
88
89 std::string setValue(const std::string &value) override;
90
91 std::string setValueFromJson(const Json::Value &value) override;
92
93 std::string setDataItem(const std::shared_ptr<Kernel::DataItem> &value) override;
94
95 std::string isValid() const override;
96
97 bool isDefault() const override;
98
99 bool isOptional() const override;
100 bool isLocking() const override;
101
102 std::vector<std::string> allowedValues() const override;
103
105
106 bool store() override;
107
108 Workspace_sptr getWorkspace() const override;
109
110 void setIsMasterRank(bool isMasterRank) override;
111
112private:
113 std::string isValidGroup(const std::shared_ptr<WorkspaceGroup> &wsGroup) const;
114
115 std::string isValidOutputWs() const;
116
117 std::string isOptionalWs() const;
118
119 void clear() override;
120
122
124 std::string m_workspaceName;
126 std::string m_initialWSName;
133
136
137 bool m_isMasterRank{true};
138};
139
140template <typename TYPE> Kernel::Logger WorkspaceProperty<TYPE>::g_log("WorkspaceProperty");
141
142} // namespace API
143} // namespace Mantid
double value
The value of the point.
Definition: FitMW.cpp:51
double right
Definition: LineProfile.cpp:81
An interface that is implemented by WorkspaceProperty.
A property class for workspaces.
std::string value() const override
Returns the value of the property as a string.
std::string setDataItem(const std::shared_ptr< Kernel::DataItem > &value) override
Set the value of the property via a DataItem pointer.
std::string isOptionalWs() const
std::string setValue(const std::string &value) override
Set the value of the property via a string.
bool isLocking() const override
Will the workspace be locked when starting an algorithm?
WorkspaceProperty & operator+=(Kernel::Property const *) override
Add to this.
std::string isValidGroup(const std::shared_ptr< WorkspaceGroup > &wsGroup) const
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.
Json::Value valueAsJson() const override
Returns the value of the property as a Json::Value.
WorkspaceProperty & operator=(const WorkspaceProperty &right)
void setIsMasterRank(bool isMasterRank) override
Sets a flag indicating whether this is the master rank in MPI builds.
WorkspaceProperty & operator=(const std::shared_ptr< TYPE > &value) override
WorkspaceProperty(const std::string &name, const std::string &wsName, const unsigned int direction, const PropertyMode::Type optional, const LockMode::Type locking, const Kernel::IValidator_sptr &validator=Kernel::IValidator_sptr(new Kernel::NullValidator))
std::string isValidOutputWs() const
static Kernel::Logger g_log
for access to logging streams
std::string setValueFromJson(const Json::Value &value) override
Set the value of the property via a Json object.
WorkspaceProperty(const std::string &name, const std::string &wsName, const unsigned int direction, const PropertyMode::Type optional, const Kernel::IValidator_sptr &validator=Kernel::IValidator_sptr(new Kernel::NullValidator))
bool isOptional() const override
Is the input workspace property optional (can be blank)?
std::string getDefault() const override
Get the default value for the property which is the value the property was initialised with.
std::string isValid() const override
Overridden function that checks whether the property, if not overriden returns "".
bool isValueSerializable() const override
Whether the string returned by value() can be used for serialization.
const Kernel::PropertyHistory createHistory() const override
Create a PropertyHistory object representing the current state of the Property.
void clear() override
Clear the stored pointer.
WorkspaceProperty(const std::string &name, const std::string &wsName, const unsigned int direction, const Kernel::IValidator_sptr &validator=Kernel::IValidator_sptr(new Kernel::NullValidator))
bool isDefault() const override
Overriden function that returns if property has the same value that it was initialised with,...
std::vector< std::string > allowedValues() const override
Returns the set of valid values for this property, if such a set exists.
WorkspaceProperty(const WorkspaceProperty &right)
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
Store a workspace into the AnalysisDataService.
The Logger class is in charge of the publishing messages from the framework through various channels.
Definition: Logger.h:52
NullValidator is a validator that doesn't.
Definition: NullValidator.h:20
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:172
const std::string & name() const
Get the property's name.
Definition: Property.cpp:60
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
Definition: Workspace_fwd.h:20
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.
Enumeration for a mandatory/optional property.