Mantid
Loading...
Searching...
No Matches
PropertyManager.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
9//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
12#include <map>
13#include <vector>
14
16
17namespace Mantid {
18namespace Kernel {
19//----------------------------------------------------------------------
20// Forward Declaration
21//----------------------------------------------------------------------
22class SplittingInterval;
23template <typename T> class TimeSeriesProperty;
24
42class MANTID_KERNEL_DLL PropertyManager : virtual public IPropertyManager {
43public:
44 static const std::string INVALID_VALUES_SUFFIX;
45 // Gets the correct log name for the matching invalid values log for a given
46 // log name
47 static std::string getInvalidValuesFilterLogName(const std::string &logName);
48 static std::string getLogNameFromInvalidValuesFilter(const std::string &logName);
49 static bool isAnInvalidValuesFilterLog(const std::string &logName);
50
53 PropertyManager &operator=(const PropertyManager &);
55
56 void filterByTime(const Types::Core::DateAndTime &start, const Types::Core::DateAndTime &stop) override;
57 void splitByTime(std::vector<SplittingInterval> &splitter, std::vector<PropertyManager *> outputs) const override;
58 void filterByProperty(const TimeSeriesProperty<bool> &filter,
59 const std::vector<std::string> &excludedFromFiltering = std::vector<std::string>()) override;
60
61 virtual ~PropertyManager() override;
62
63 // Function to declare properties (i.e. store them)
64 void declareProperty(std::unique_ptr<Property> p, const std::string &doc = "") override;
65 using IPropertyManager::declareProperty;
66 void declareOrReplaceProperty(std::unique_ptr<Property> p, const std::string &doc = "") override;
67 void resetProperties() override;
68 // Sets all the declare properties
69 void setProperties(const std::string &propertiesJson,
70 const std::unordered_set<std::string> &ignoreProperties = std::unordered_set<std::string>(),
71 bool createMissing = false) override;
72 void setProperties(const std::string &propertiesJson, IPropertyManager *targetPropertyManager,
73 const std::unordered_set<std::string> &ignoreProperties, bool createMissing = false);
74 void setProperties(const ::Json::Value &jsonValue,
75 const std::unordered_set<std::string> &ignoreProperties = std::unordered_set<std::string>(),
76 bool createMissing = false) override;
77 void setProperties(const ::Json::Value &jsonValue, IPropertyManager *targetPropertyManager,
78 const std::unordered_set<std::string> &ignoreProperties = std::unordered_set<std::string>(),
79 bool createMissing = false);
80 void setPropertiesWithString(
81 const std::string &propertiesString,
82 const std::unordered_set<std::string> &ignoreProperties = std::unordered_set<std::string>()) override;
83 void setPropertyValue(const std::string &name, const std::string &value) override;
84 void setPropertyValueFromJson(const std::string &name, const Json::Value &value) override;
85 void setPropertyOrdinal(const int &index, const std::string &value) override;
86
87 bool existsProperty(const std::string &name) const override;
88 bool validateProperties() const override;
89 size_t propertyCount() const override;
90 std::string getPropertyValue(const std::string &name) const override;
91 const std::vector<Property *> &getProperties() const override;
92 std::vector<std::string> getDeclaredPropertyNames() const noexcept override;
93
95 void removeProperty(const std::string &name, const bool delproperty = true) override;
97 std::unique_ptr<Property> takeProperty(const size_t index) override;
99 void clear() override;
100
102 TypedValue getProperty(const std::string &name) const override;
104 std::string asString(bool withDefaultValues = false) const override;
106 ::Json::Value asJson(bool withDefaultValues = false) const override;
107
108 bool operator==(const PropertyManager &other) const;
109 bool operator!=(const PropertyManager &other) const;
110
111 Property *getPointerToProperty(const std::string &name) const override;
112
113protected:
115
116 Property *getPointerToPropertyOrdinal(const int &index) const override;
117 Property *getPointerToPropertyOrNull(const std::string &name) const;
118
119private:
120 void setPropertiesWithSimpleString(const std::string &propertiesString,
121 const std::unordered_set<std::string> &ignoreProperties);
122 void setPropertiesWithJSONString(const std::string &propertiesString,
123 const std::unordered_set<std::string> &ignoreProperties);
124
126 using PropertyMap = std::map<std::string, std::unique_ptr<Property>>;
128 PropertyMap m_properties;
130 std::vector<Property *> m_orderedProperties;
131};
132
134using PropertyManager_sptr = std::shared_ptr<PropertyManager>;
135
137MANTID_KERNEL_DLL ::Json::Value encodeAsJson(const PropertyManager &propMgr);
138
139} // namespace Kernel
140} // namespace Mantid
const std::vector< double > & rhs
double value
The value of the point.
Definition: FitMW.cpp:51
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
Interface to PropertyManager.
Kernel/PropertyManagerOwner.h.
Property manager helper class.
std::map< std::string, std::unique_ptr< Property > > PropertyMap
typedef for the map holding the properties
static const std::string INVALID_VALUES_SUFFIX
Base class for properties.
Definition: Property.h:94
A specialised Property class for holding a series of time-value pairs.
Definition: Algorithm.h:38
MatrixWorkspace_sptr MANTID_API_DLL operator+=(const MatrixWorkspace_sptr &lhs, const MatrixWorkspace_sptr &rhs)
Adds two workspaces.
std::shared_ptr< PropertyManager > PropertyManager_sptr
Typedef for a shared pointer to a PropertyManager.
Helper class which provides the Collimation Length for SANS instruments.
STL namespace.
Utility class that enables the getProperty() method to effectively be templated on the return type.