Mantid
Loading...
Searching...
No Matches
LogManager.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2010 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#include "MantidAPI/DllConfig.h"
13
14#include <memory>
15#include <vector>
16
17namespace NeXus {
18class File;
19}
20
21namespace Mantid {
22namespace Types {
23namespace Core {
24class DateAndTime;
25}
26} // namespace Types
27namespace Kernel {
28template <class KEYTYPE, class VALUETYPE> class Cache;
29template <typename TYPE> class TimeSeriesProperty;
31using TimeSplitterType = std::vector<SplittingInterval>;
32class PropertyManager;
33} // namespace Kernel
34
35namespace API {
36
44class MANTID_API_DLL LogManager {
45public:
46 // Gets the correct log name for the matching invalid values log for a given
47 // log name
48 static std::string getInvalidValuesFilterLogName(const std::string &logName);
49
50 LogManager();
51 LogManager(const LogManager &other);
54 virtual ~LogManager();
55 LogManager &operator=(const LogManager &other);
56
57 //-------------------------------------------------------------
59 void setStartAndEndTime(const Types::Core::DateAndTime &start, const Types::Core::DateAndTime &end);
61 const Types::Core::DateAndTime startTime() const;
63 const Types::Core::DateAndTime endTime() const;
64 //-------------------------------------------------------------
65
67 virtual void filterByTime(const Types::Core::DateAndTime start, const Types::Core::DateAndTime stop);
69 virtual void splitByTime(Kernel::TimeSplitterType &splitter, std::vector<LogManager *> outputs) const;
71 void filterByLog(const Kernel::TimeSeriesProperty<bool> &filter,
72 const std::vector<std::string> &excludedFromFiltering = std::vector<std::string>());
73
75 virtual size_t getMemorySize() const;
76
79 void addProperty(Kernel::Property *prop, bool overwrite = false) {
80 addProperty(std::unique_ptr<Kernel::Property>(prop), overwrite);
81 };
83 void addProperty(std::unique_ptr<Kernel::Property> prop, bool overwrite = false);
85 template <class TYPE> void addProperty(const std::string &name, const TYPE &value, bool overwrite = false);
86
87 template <class TYPE>
88 void addProperty(const std::string &name, const TYPE &value, const std::string &units, bool overwrite = false);
89
91 bool hasProperty(const std::string &name) const;
93 void removeProperty(const std::string &name, bool delProperty = true);
94 const std::vector<Kernel::Property *> &getProperties() const;
95
98 template <typename T> Kernel::TimeSeriesProperty<T> *getTimeSeriesProperty(const std::string &name) const;
101 template <typename HeldType> HeldType getPropertyValueAsType(const std::string &name) const;
103 double getPropertyAsSingleValue(const std::string &name,
104 Kernel::Math::StatisticType statistic = Kernel::Math::Mean) const;
106 int getPropertyAsIntegerValue(const std::string &name) const;
108 Kernel::Property *getProperty(const std::string &name) const;
109
115 void addLogData(Kernel::Property *p) { addLogData(std::unique_ptr<Kernel::Property>(p)); }
116
122 void addLogData(std::unique_ptr<Kernel::Property> p, bool overwrite = false) { addProperty(std::move(p), overwrite); }
123
129 Kernel::Property *getLogData(const std::string &name) const { return getProperty(name); }
134 const std::vector<Kernel::Property *> &getLogData() const { return getProperties(); }
140 void removeLogData(const std::string &name, const bool delproperty = true) {
141 return removeProperty(name, delproperty);
142 }
149 double getLogAsSingleValue(const std::string &name,
150 Kernel::Math::StatisticType statistic = Kernel::Math::Mean) const {
151 return getPropertyAsSingleValue(name, statistic);
152 }
153
155 double getTimeAveragedStd(const std::string &name) const;
156
158 void clearTimeSeriesLogs();
160 void clearOutdatedTimeSeriesLogValues();
161
163 virtual void saveNexus(::NeXus::File *file, const std::string &group, bool keepOpen = false) const;
164
175 virtual void loadNexus(::NeXus::File *file, const std::string &group,
176 const Mantid::Kernel::NexusHDF5Descriptor &fileInfo, const std::string &prefix,
177 bool keepOpen = false);
179 virtual void loadNexus(::NeXus::File *file, const std::string &group, bool keepOpen = false);
181 void clearLogs();
182
183 // returns true if the log has a matching invalid values log filter
184 bool hasInvalidValuesFilter(const std::string &logName) const;
185
186 // returns the invalid values log if the log has a matching invalid values log
187 // filter
188 Kernel::TimeSeriesProperty<bool> *getInvalidValuesFilter(const std::string &logName) const;
189
190 bool operator==(const LogManager &other) const;
191 bool operator!=(const LogManager &other) const;
192
193protected:
194 void loadNexus(::NeXus::File *file, const Mantid::Kernel::NexusHDF5Descriptor &fileInfo, const std::string &prefix);
196 void loadNexus(::NeXus::File *file, const std::map<std::string, std::string> &entries);
198 std::unique_ptr<Kernel::PropertyManager> m_manager;
201 static const char *PROTON_CHARGE_LOG_NAME;
202
203private:
205 std::unique_ptr<Kernel::Cache<std::pair<std::string, Kernel::Math::StatisticType>, double>> m_singleValueCache;
206};
208using LogManager_sptr = std::shared_ptr<LogManager>;
210using LogManager_const_sptr = std::shared_ptr<const LogManager>;
211
219template <class TYPE> void LogManager::addProperty(const std::string &name, const TYPE &value, bool overwrite) {
220 addProperty(std::make_unique<Kernel::PropertyWithValue<TYPE>>(name, value), overwrite);
221}
222
232template <class TYPE>
233void LogManager::addProperty(const std::string &name, const TYPE &value, const std::string &units, bool overwrite) {
234 auto newProp = std::make_unique<Kernel::PropertyWithValue<TYPE>>(name, value);
235 newProp->setUnits(units);
236 addProperty(std::move(newProp), overwrite);
237}
238} // namespace API
239} // namespace Mantid
double value
The value of the point.
Definition: FitMW.cpp:51
This class contains the information about the log entries.
Definition: LogManager.h:44
void addLogData(Kernel::Property *p)
Add a log entry.
Definition: LogManager.h:115
const std::vector< Kernel::Property * > & getLogData() const
Access all log entries.
Definition: LogManager.h:134
std::unique_ptr< Kernel::PropertyManager > m_manager
A pointer to a property manager.
Definition: LogManager.h:198
virtual ~LogManager()
Destructor.
static const char * PROTON_CHARGE_LOG_NAME
Name of the log entry containing the proton charge when retrieved using getProtonCharge.
Definition: LogManager.h:201
Kernel::Property * getLogData(const std::string &name) const
Access a single log entry.
Definition: LogManager.h:129
std::unique_ptr< Kernel::Cache< std::pair< std::string, Kernel::Math::StatisticType >, double > > m_singleValueCache
Cache for the retrieved single values.
Definition: LogManager.h:205
void addProperty(Kernel::Property *prop, bool overwrite=false)
Add data to the object in the form of a property.
Definition: LogManager.h:79
void addLogData(std::unique_ptr< Kernel::Property > p, bool overwrite=false)
Add a log entry.
Definition: LogManager.h:122
double getLogAsSingleValue(const std::string &name, Kernel::Math::StatisticType statistic=Kernel::Math::Mean) const
Definition: LogManager.h:149
void removeLogData(const std::string &name, const bool delproperty=true)
Remove a named log entry.
Definition: LogManager.h:140
Cache is a generic caching storage class.
Definition: Cache.h:27
Property manager helper class.
The concrete, templated class for properties.
Base class for properties.
Definition: Property.h:94
Class holding a start/end time and a destination for splitting event lists and logs.
Definition: TimeSplitter.h:23
A specialised Property class for holding a series of time-value pairs.
std::shared_ptr< const LogManager > LogManager_const_sptr
shared pointer to the logManager base class (const version)
Definition: LogManager.h:210
std::shared_ptr< LogManager > LogManager_sptr
shared pointer to the logManager base class
Definition: LogManager.h:208
StatisticType
Maps a "statistic" to a number.
Definition: Statistics.h:18
std::vector< SplittingInterval > TimeSplitterType
A typedef for splitting events according their pulse time.
Definition: LogManager.h:31
Helper class which provides the Collimation Length for SANS instruments.
constexpr bool operator==(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
constexpr bool operator!=(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)