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;
24class TimeROI;
25class LogFilter;
26
44class MANTID_KERNEL_DLL PropertyManager : virtual public IPropertyManager {
45public:
46 static const std::string INVALID_VALUES_SUFFIX;
47 // Gets the correct log name for the matching invalid values log for a given
48 // log name
49 static std::string getInvalidValuesFilterLogName(const std::string &logName);
50 static std::string getLogNameFromInvalidValuesFilter(const std::string &logName);
52 static bool isAnInvalidValuesFilterLog(const std::string &logName);
53
56 PropertyManager &operator=(const PropertyManager &);
58
59 void filterByProperty(Mantid::Kernel::LogFilter *logFilter,
60 const std::vector<std::string> &excludedFromFiltering = std::vector<std::string>()) override;
61
62 // Create a new PropertyManager with a partial copy of its time series properties according to TimeROI
63 PropertyManager *cloneInTimeROI(const Kernel::TimeROI &timeROI);
64
65 // For the time series properties, remove values according to TimeROI
66 void removeDataOutsideTimeROI(const Kernel::TimeROI &timeROI);
67
68 virtual ~PropertyManager() override;
69
70 // Function to declare properties (i.e. store them)
71 void declareProperty(std::unique_ptr<Property> p, const std::string &doc = "") override;
72 using IPropertyManager::declareProperty;
73 void declareOrReplaceProperty(std::unique_ptr<Property> p, const std::string &doc = "") override;
74 void resetProperties() override;
75 // Sets all the declare properties
76 void setProperties(const std::string &propertiesJson,
77 const std::unordered_set<std::string> &ignoreProperties = std::unordered_set<std::string>(),
78 bool createMissing = false) override;
79 void setProperties(const std::string &propertiesJson, IPropertyManager *targetPropertyManager,
80 const std::unordered_set<std::string> &ignoreProperties, bool createMissing = false);
81 void setProperties(const ::Json::Value &jsonValue,
82 const std::unordered_set<std::string> &ignoreProperties = std::unordered_set<std::string>(),
83 bool createMissing = false) override;
84 void setProperties(const ::Json::Value &jsonValue, IPropertyManager *targetPropertyManager,
85 const std::unordered_set<std::string> &ignoreProperties = std::unordered_set<std::string>(),
86 bool createMissing = false);
87 void setPropertiesWithString(
88 const std::string &propertiesString,
89 const std::unordered_set<std::string> &ignoreProperties = std::unordered_set<std::string>()) override;
90 void setPropertyValue(const std::string &name, const std::string &value) override;
91 void setPropertyValueFromJson(const std::string &name, const Json::Value &value) override;
92 void setPropertyOrdinal(const int &index, const std::string &value) override;
93
94 bool existsProperty(const std::string &name) const override;
95 bool validateProperties() const override;
96 size_t propertyCount() const override;
97 std::string getPropertyValue(const std::string &name) const override;
98 const std::vector<Property *> &getProperties() const override;
99 std::vector<std::string> getDeclaredPropertyNames() const noexcept override;
100
102 void removeProperty(const std::string &name, const bool delproperty = true) override;
104 std::unique_ptr<Property> takeProperty(const size_t index) override;
106 void clear() override final;
107
109 TypedValue getProperty(const std::string &name) const override;
111 std::string asString(bool withDefaultValues = false) const override;
113 ::Json::Value asJson(bool withDefaultValues = false) const override;
114
115 bool operator==(const PropertyManager &other) const;
116 bool operator!=(const PropertyManager &other) const;
117
118 Property *getPointerToProperty(const std::string &name) const override;
119
120protected:
122
123 Property *getPointerToPropertyOrdinal(const int &index) const override;
124 Property *getPointerToPropertyOrNull(const std::string &name) const;
125
126private:
127 void setPropertiesWithSimpleString(const std::string &propertiesString,
128 const std::unordered_set<std::string> &ignoreProperties);
129 void setPropertiesWithJSONString(const std::string &propertiesString,
130 const std::unordered_set<std::string> &ignoreProperties);
131
133 using PropertyMap = std::map<std::string, std::unique_ptr<Property>>;
135 PropertyMap m_properties;
137 std::vector<Property *> m_orderedProperties;
138};
139
141using PropertyManager_sptr = std::shared_ptr<PropertyManager>;
142
144MANTID_KERNEL_DLL ::Json::Value encodeAsJson(const PropertyManager &propMgr);
145
146} // namespace Kernel
147} // namespace Mantid
std::string name
Definition Run.cpp:60
const std::vector< double > & rhs
double value
The value of the point.
Definition FitMW.cpp:51
std::map< DeltaEMode::Type, std::string > index
Interface to PropertyManager.
This class is for filtering TimeSeriesProperty data.
Definition LogFilter.h:32
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
TimeROI : Object that holds information about when the time measurement was active.
Definition TimeROI.h:18
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.