Skip to content

Commit

Permalink
Merge pull request #34894 from peterfpeterson/928_timeroi_object
Browse files Browse the repository at this point in the history
TimeROI object in C++
  • Loading branch information
AndreiSavici authored Jan 10, 2023
2 parents 0130570 + ad10d0a commit 896a7fc
Show file tree
Hide file tree
Showing 5 changed files with 718 additions and 4 deletions.
7 changes: 5 additions & 2 deletions Framework/Kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
set(SRC_FILES
src/SetValueWhenProperty.cpp
src/ANN_complete.cpp
src/ArrayBoundedValidator.cpp
src/ArrayLengthValidator.cpp
Expand Down Expand Up @@ -95,6 +94,7 @@ set(SRC_FILES
src/ReadLock.cpp
src/RebinParamsValidator.cpp
src/RegexStrings.cpp
src/SetValueWhenProperty.cpp
src/SingletonHolder.cpp
src/SobolSequence.cpp
src/StartsWithValidator.cpp
Expand All @@ -107,6 +107,7 @@ set(SRC_FILES
src/ThreadPool.cpp
src/ThreadPoolRunnable.cpp
src/ThreadSafeLogStream.cpp
src/TimeROI.cpp
src/TimeSeriesProperty.cpp
src/TimeSplitter.cpp
src/Timer.cpp
Expand Down Expand Up @@ -139,7 +140,6 @@ set(SRC_UNITY_IGNORE_FILES
)

set(INC_FILES
inc/MantidKernel/SetValueWhenProperty.h
inc/MantidKernel/ANN/ANN.h
inc/MantidKernel/ANN/ANNperf.h
inc/MantidKernel/ANN/ANNx.h
Expand Down Expand Up @@ -265,6 +265,7 @@ set(INC_FILES
inc/MantidKernel/RebinParamsValidator.h
inc/MantidKernel/RegexStrings.h
inc/MantidKernel/RegistrationHelper.h
inc/MantidKernel/SetValueWhenProperty.h
inc/MantidKernel/SingletonHolder.h
inc/MantidKernel/SobolSequence.h
inc/MantidKernel/SpecialCoordinateSystem.h
Expand All @@ -282,6 +283,7 @@ set(INC_FILES
inc/MantidKernel/ThreadSafeLogStream.h
inc/MantidKernel/ThreadScheduler.h
inc/MantidKernel/ThreadSchedulerMutexes.h
inc/MantidKernel/TimeROI.h
inc/MantidKernel/TimeSeriesProperty.h
inc/MantidKernel/TimeSplitter.h
inc/MantidKernel/Timer.h
Expand Down Expand Up @@ -426,6 +428,7 @@ set(TEST_FILES
ThreadPoolTest.h
ThreadSchedulerMutexesTest.h
ThreadSchedulerTest.h
TimeROITest.h
TimeSeriesPropertyTest.h
TimeSplitterTest.h
TimerTest.h
Expand Down
55 changes: 55 additions & 0 deletions Framework/Kernel/inc/MantidKernel/TimeROI.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2022 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once

#include "MantidKernel/DllConfig.h"
#include "MantidKernel/TimeSeriesProperty.h"

namespace Mantid {
namespace Kernel {

namespace {
// const std::string NAME{"roi"};
}

/** TimeROI : Object that holds information about when the time measurement was active.
*/
class MANTID_KERNEL_DLL TimeROI {
public:
TimeROI();
TimeROI(const Types::Core::DateAndTime &startTime, const Types::Core::DateAndTime &stopTime);
double durationInSeconds() const;
double durationInSeconds(const Types::Core::DateAndTime &startTime, const Types::Core::DateAndTime &stopTime) const;
std::size_t numBoundaries() const;
bool empty() const;
void addROI(const std::string &startTime, const std::string &stopTime);
void addROI(const Types::Core::DateAndTime &startTime, const Types::Core::DateAndTime &stopTime);
void addROI(const std::time_t &startTime, const std::time_t &stopTime);
void addMask(const std::string &startTime, const std::string &stopTime);
void addMask(const Types::Core::DateAndTime &startTime, const Types::Core::DateAndTime &stopTime);
void addMask(const std::time_t &startTime, const std::time_t &stopTime);
bool valueAtTime(const Types::Core::DateAndTime &time) const;
void update_union(const TimeROI &other);
void update_intersection(const TimeROI &other);
void removeRedundantEntries();
bool operator==(const TimeROI &other) const;
void debugPrint() const;

private:
std::vector<Types::Core::DateAndTime> getAllTimes(const TimeROI &other);
void replaceValues(const std::vector<Types::Core::DateAndTime> &times, const std::vector<bool> &values);
bool isCompletelyInROI(const Types::Core::DateAndTime &startTime, const Types::Core::DateAndTime &stopTime) const;
/**
* @brief m_roi private member that holds most of the information
*
* This handles the details of the ROI and guarantees that views into the underlying structure is sorted by time.
*/
TimeSeriesProperty<bool> m_roi;
};

} // namespace Kernel
} // namespace Mantid
Loading

0 comments on commit 896a7fc

Please sign in to comment.