From a078fcfc0e1240571c51f06ff91b70cd63f32603 Mon Sep 17 00:00:00 2001 From: LamarMoore <lamar.moore@stfc.ac.uk> Date: Tue, 26 Sep 2017 09:24:05 +0100 Subject: [PATCH] move DateAndTime/TofEvents to Types::Core/Event #20436 --- Framework/API/inc/MantidAPI/Algorithm.h | 2 +- .../API/inc/MantidAPI/AlgorithmHistory.h | 16 +- Framework/API/inc/MantidAPI/HistoryView.h | 8 +- Framework/API/inc/MantidAPI/IEventList.h | 12 +- Framework/API/inc/MantidAPI/IEventWorkspace.h | 8 +- Framework/API/inc/MantidAPI/ILiveListener.h | 4 +- .../API/inc/MantidAPI/IRemoteJobManager.h | 8 +- Framework/API/inc/MantidAPI/LogManager.h | 22 +- Framework/API/inc/MantidAPI/MatrixWorkspace.h | 6 +- .../API/inc/MantidAPI/PrecompiledHeader.h | 2 +- Framework/API/inc/MantidAPI/Run.h | 4 +- .../API/inc/MantidAPI/ScriptRepository.h | 4 +- Framework/API/src/Algorithm.cpp | 10 +- Framework/API/src/AlgorithmHistory.cpp | 8 +- Framework/API/src/ExperimentInfo.cpp | 173 +++-- Framework/API/src/HistoryView.cpp | 6 +- Framework/API/src/LogManager.cpp | 73 +- Framework/API/src/MatrixWorkspace.cpp | 9 +- Framework/API/src/Run.cpp | 6 +- Framework/API/src/WorkspaceHistory.cpp | 11 +- Framework/API/test/AlgorithmHistoryTest.h | 4 +- Framework/API/test/CMakeLists.txt | 1 + Framework/API/test/ExperimentInfoTest.h | 32 +- Framework/API/test/HistoryViewTest.h | 5 +- Framework/API/test/LiveListenerTest.h | 2 +- Framework/API/test/LogFilterGeneratorTest.h | 43 +- Framework/API/test/LogManagerTest.h | 36 +- Framework/API/test/MatrixWorkspaceTest.h | 35 +- Framework/API/test/WorkspaceHistoryIOTest.h | 22 +- Framework/API/test/WorkspaceHistoryTest.h | 15 +- .../inc/MantidAlgorithms/AddSampleLog.h | 4 +- .../inc/MantidAlgorithms/CalculateCountRate.h | 2 +- .../inc/MantidAlgorithms/ChangeTimeZero.h | 2 +- .../MantidAlgorithms/ExportTimeSeriesLog.h | 12 +- .../inc/MantidAlgorithms/FilterByTime2.h | 2 +- .../inc/MantidAlgorithms/FilterEvents.h | 8 +- .../MantidAlgorithms/GenerateEventsFilter.h | 64 +- .../GetTimeSeriesLogInformation.h | 28 +- Framework/Algorithms/src/AddLogDerivative.cpp | 28 +- Framework/Algorithms/src/AddNote.cpp | 5 +- Framework/Algorithms/src/AddSampleLog.cpp | 30 +- .../Algorithms/src/CalculateCountRate.cpp | 64 +- Framework/Algorithms/src/ChangeLogTime.cpp | 7 +- Framework/Algorithms/src/ChangeTimeZero.cpp | 27 +- .../Algorithms/src/CompareWorkspaces.cpp | 2 +- .../Algorithms/src/CorelliCrossCorrelate.cpp | 3 +- .../Algorithms/src/CreateSampleWorkspace.cpp | 35 +- .../DiffractionEventCalibrateDetectors.cpp | 21 +- .../Algorithms/src/EQSANSTofStructure.cpp | 59 +- .../Algorithms/src/ExportTimeSeriesLog.cpp | 40 +- Framework/Algorithms/src/ExtractSpectra.cpp | 2 +- Framework/Algorithms/src/FilterByLogValue.cpp | 12 +- Framework/Algorithms/src/FilterByTime.cpp | 11 +- Framework/Algorithms/src/FilterEvents.cpp | 69 +- .../Algorithms/src/GenerateEventsFilter.cpp | 41 +- .../src/GenerateIPythonNotebook.cpp | 22 +- .../Algorithms/src/GeneratePythonScript.cpp | 22 +- Framework/Algorithms/src/GetAllEi.cpp | 12 +- .../src/GetTimeSeriesLogInformation.cpp | 50 +- Framework/Algorithms/src/Pause.cpp | 5 +- .../src/PlotAsymmetryByLogValue.cpp | 119 ++- Framework/Algorithms/src/RebinByTimeBase.cpp | 2 +- .../SampleLogsBehaviour.cpp | 2 +- Framework/Algorithms/src/ShiftLogTime.cpp | 2 +- .../Algorithms/src/SumEventsByLogValue.cpp | 1 - Framework/Algorithms/test/AddNoteTest.h | 11 +- Framework/Algorithms/test/AddSampleLogTest.h | 25 +- .../Algorithms/test/AddTimeSeriesLogTest.h | 9 +- Framework/Algorithms/test/AppendSpectraTest.h | 11 +- .../Algorithms/test/AverageLogDataTest.h | 4 +- .../Algorithms/test/CalculateCountRateTest.h | 20 +- Framework/Algorithms/test/ChangeLogTimeTest.h | 11 +- .../Algorithms/test/ChangePulsetime2Test.h | 13 +- .../Algorithms/test/ChangePulsetimeTest.h | 21 +- .../Algorithms/test/ChangeTimeZeroTest.h | 43 +- Framework/Algorithms/test/ConvertUnitsTest.h | 4 +- .../test/CorelliCrossCorrelateTest.h | 11 +- .../test/CreateLogPropertyTableTest.h | 3 +- .../test/DiffractionFocussing2Test.h | 2 +- .../test/EstimateResolutionDiffractionTest.h | 10 +- .../Algorithms/test/ExportTimeSeriesLogTest.h | 8 +- .../Algorithms/test/FilterByLogValueTest.h | 16 +- Framework/Algorithms/test/FilterByTime2Test.h | 4 +- Framework/Algorithms/test/FilterByTimeTest.h | 13 +- Framework/Algorithms/test/FilterEventsTest.h | 70 +- .../test/FindDetectorsOutsideLimitsTest.h | 13 +- .../test/GenerateEventsFilterTest.h | 86 +-- Framework/Algorithms/test/GetAllEiTest.h | 26 +- .../test/GetTimeSeriesLogInformationTest.h | 10 +- .../test/ModeratorTzeroLinearTest.h | 2 +- .../Algorithms/test/ModeratorTzeroTest.h | 2 +- .../Algorithms/test/NormaliseByCurrentTest.h | 4 +- .../Algorithms/test/RebinByTimeAtSampleTest.h | 2 +- .../Algorithms/test/RebinByTimeBaseTest.h | 6 +- .../test/SANSCollimationLengthEstimatorTest.h | 15 +- Framework/Algorithms/test/ShiftLogTimeTest.h | 13 +- Framework/Algorithms/test/SortEventsTest.h | 2 +- .../Algorithms/test/SumEventsByLogValueTest.h | 9 +- .../test/TOFSANSResolutionByPixelTest.h | 15 +- Framework/Beamline/src/DetectorInfo.cpp | 4 +- Framework/CMakeLists.txt | 3 +- Framework/Crystal/src/LoadIsawPeaks.cpp | 6 +- Framework/Crystal/src/SaveIsawPeaks.cpp | 2 +- Framework/Crystal/src/SetGoniometer.cpp | 2 +- Framework/Crystal/test/CentroidPeaksTest.h | 10 +- .../Crystal/test/NormaliseVanadiumTest.h | 31 +- Framework/Crystal/test/PeakIntegrationTest.h | 10 +- .../inc/MantidDataHandling/BankPulseTimes.h | 6 +- .../EventWorkspaceCollection.h | 2 +- .../FilterEventsByLogValuePreNexus.h | 25 +- .../inc/MantidDataHandling/LoadANSTOHelper.h | 2 +- .../MantidDataHandling/LoadEventPreNexus2.h | 6 +- .../MantidDataHandling/LoadILLDiffraction.h | 6 +- .../inc/MantidDataHandling/LoadRawHelper.h | 4 +- .../inc/MantidDataHandling/LoadSpice2D.h | 6 +- .../inc/MantidDataHandling/LoadTOFRawNexus.h | 4 +- .../StartAndEndTimeFromNexusFileExtractor.h | 6 +- Framework/DataHandling/src/BankPulseTimes.cpp | 6 +- .../src/CreateChunkingFromInstrument.cpp | 5 +- .../src/CreateSimulationWorkspace.cpp | 16 +- .../src/EventWorkspaceCollection.cpp | 2 +- .../src/FilterEventsByLogValuePreNexus.cpp | 16 +- Framework/DataHandling/src/LoadBBY.cpp | 14 +- Framework/DataHandling/src/LoadEventNexus.cpp | 16 +- .../DataHandling/src/LoadEventPreNexus2.cpp | 13 +- .../src/LoadFullprofResolution.cpp | 2 +- .../DataHandling/src/LoadIDFFromNexus.cpp | 44 +- .../DataHandling/src/LoadILLDiffraction.cpp | 46 +- Framework/DataHandling/src/LoadLog.cpp | 3 +- Framework/DataHandling/src/LoadMuonNexus2.cpp | 4 +- Framework/DataHandling/src/LoadNexusLogs.cpp | 87 +-- .../DataHandling/src/LoadNexusMonitors2.cpp | 11 +- .../DataHandling/src/LoadNexusProcessed.cpp | 7 +- Framework/DataHandling/src/LoadRawHelper.cpp | 44 +- Framework/DataHandling/src/LoadSpice2D.cpp | 28 +- Framework/DataHandling/src/LoadSpiceAscii.cpp | 22 +- .../DataHandling/src/LoadSpiceXML2DDet.cpp | 4 +- Framework/DataHandling/src/LoadSwans.cpp | 13 +- Framework/DataHandling/src/MergeLogs.cpp | 6 +- .../DataHandling/src/ProcessBankData.cpp | 5 +- Framework/DataHandling/src/RenameLog.cpp | 2 +- Framework/DataHandling/src/SaveCalFile.cpp | 10 +- Framework/DataHandling/src/SaveIsawDetCal.cpp | 2 +- Framework/DataHandling/src/SaveNexus.cpp | 2 +- .../DataHandling/src/SaveNexusProcessed.cpp | 2 +- .../StartAndEndTimeFromNexusFileExtractor.cpp | 51 +- .../DataHandling/test/GroupDetectors2Test.h | 6 +- .../DataHandling/test/LoadEventNexusTest.h | 13 +- .../test/LoadEventPreNexus2Test.h | 9 +- .../DataHandling/test/LoadInstrumentTest.h | 12 +- Framework/DataHandling/test/LoadLogTest.h | 3 +- .../DataHandling/test/LoadMuonNexus2Test.h | 2 +- .../DataHandling/test/LoadNexusLogsTest.h | 15 +- Framework/DataHandling/test/LoadRaw3Test.h | 6 +- .../DataHandling/test/MaskDetectorsTest.h | 2 +- Framework/DataHandling/test/MergeLogsTest.h | 12 +- Framework/DataHandling/test/RemoveLogsTest.h | 20 +- Framework/DataHandling/test/RenameLogTest.h | 6 +- ...tartAndEndTimeFromNexusFileExtractorTest.h | 8 +- .../inc/MantidDataObjects/EventList.h | 60 +- .../inc/MantidDataObjects/EventWorkspace.h | 12 +- .../inc/MantidDataObjects/Events.h | 26 +- .../inc/MantidDataObjects/PeaksWorkspace.h | 2 +- .../ScanningWorkspaceBuilder.h | 8 +- Framework/DataObjects/src/EventList.cpp | 22 +- Framework/DataObjects/src/EventWorkspace.cpp | 16 +- Framework/DataObjects/src/Events.cpp | 13 +- Framework/DataObjects/src/PeaksWorkspace.cpp | 2 +- .../src/ScanningWorkspaceBuilder.cpp | 10 +- .../DataObjects/src/SplittersWorkspace.cpp | 4 +- Framework/DataObjects/test/CMakeLists.txt | 1 - Framework/DataObjects/test/EventListTest.h | 9 +- .../DataObjects/test/EventWorkspaceTest.h | 26 +- Framework/DataObjects/test/EventsTest.h | 23 +- .../test/ScanningWorkspaceBuilderTest.h | 2 +- .../DataObjects/test/SplittersWorkspaceTest.h | 36 +- .../test/WeightedEventNoTimeTest.h | 2 +- .../DataObjects/test/WeightedEventTest.h | 2 +- .../Geometry/inc/MantidGeometry/Instrument.h | 14 +- .../MantidGeometry/Instrument/DetectorInfo.h | 8 +- .../inc/MantidGeometry/PrecompiledHeader.h | 2 +- Framework/Geometry/src/Instrument.cpp | 127 ++-- .../Geometry/src/Instrument/DetectorInfo.cpp | 10 +- .../Instrument/InstrumentDefinitionParser.cpp | 7 +- .../Geometry/src/Instrument/ParameterMap.cpp | 2 +- Framework/Geometry/test/InstrumentTest.h | 27 +- .../ICat/inc/MantidICat/ICat4/ICat4Catalog.h | 1 - Framework/ICat/src/CatalogKeepAlive.cpp | 10 +- Framework/ICat/src/CatalogSearchParam.cpp | 9 +- Framework/ICat/src/ICat4/ICat4Catalog.cpp | 16 +- .../inc/MantidKernel/DateAndTimeHelpers.h | 2 +- .../inc/MantidKernel/IPropertyManager.h | 176 ++--- .../inc/MantidKernel/ITimeSeriesProperty.h | 4 +- Framework/Kernel/inc/MantidKernel/LogParser.h | 12 +- Framework/Kernel/inc/MantidKernel/Property.h | 15 +- .../Kernel/inc/MantidKernel/PropertyManager.h | 4 +- .../inc/MantidKernel/PropertyManagerOwner.h | 4 +- .../inc/MantidKernel/TimeSeriesProperty.h | 56 +- .../Kernel/inc/MantidKernel/TimeSplitter.h | 28 +- Framework/Kernel/src/ConfigService.cpp | 101 ++- Framework/Kernel/src/DateAndTimeHelpers.cpp | 4 +- Framework/Kernel/src/DateTimeValidator.cpp | 2 +- Framework/Kernel/src/GitHubApiHelper.cpp | 17 +- Framework/Kernel/src/InternetHelper.cpp | 129 ++-- Framework/Kernel/src/LogFilter.cpp | 1 - Framework/Kernel/src/LogParser.cpp | 44 +- Framework/Kernel/src/Property.cpp | 6 +- Framework/Kernel/src/PropertyManager.cpp | 4 +- Framework/Kernel/src/PropertyNexus.cpp | 32 +- Framework/Kernel/src/TimeSeriesProperty.cpp | 151 ++-- Framework/Kernel/src/TimeSplitter.cpp | 9 +- Framework/Kernel/src/UsageService.cpp | 29 +- Framework/Kernel/test/CMakeLists.txt | 2 +- .../test/FilteredTimeSeriesPropertyTest.h | 1 - Framework/Kernel/test/LogFilterTest.h | 1 - Framework/Kernel/test/LogParserTest.h | 117 ++- Framework/Kernel/test/PropertyNexusTest.h | 29 +- .../Kernel/test/TimeSeriesPropertyTest.h | 709 +++++++----------- Framework/Kernel/test/TimeSplitterTest.h | 316 ++++---- .../MantidLiveData/FakeEventDataListener.h | 6 +- .../MantidLiveData/FileEventDataListener.h | 2 +- .../ISIS/ISISHistoDataListener.h | 2 +- .../ISIS/ISISLiveEventDataListener.h | 6 +- .../MantidLiveData/Kafka/KafkaEventListener.h | 2 +- .../Kafka/KafkaEventStreamDecoder.h | 2 +- .../inc/MantidLiveData/LiveDataAlgorithm.h | 4 +- .../MantidLiveData/SNSLiveEventDataListener.h | 10 +- .../TOPAZLiveEventDataListener.h | 4 +- .../LiveData/src/FakeEventDataListener.cpp | 17 +- .../LiveData/src/FileEventDataListener.cpp | 2 +- .../src/ISIS/ISISHistoDataListener.cpp | 2 +- .../src/ISIS/ISISLiveEventDataListener.cpp | 46 +- .../LiveData/src/Kafka/KafkaEventListener.cpp | 2 +- .../src/Kafka/KafkaEventStreamDecoder.cpp | 5 +- Framework/LiveData/src/LiveDataAlgorithm.cpp | 9 +- Framework/LiveData/src/LoadLiveData.cpp | 7 +- Framework/LiveData/src/MonitorLiveData.cpp | 11 +- .../LiveData/src/SNSLiveEventDataListener.cpp | 34 +- Framework/LiveData/src/StartLiveData.cpp | 10 +- .../src/TOPAZLiveEventDataListener.cpp | 26 +- Framework/LiveData/test/KafkaTesting.h | 2 +- Framework/LiveData/test/TestDataListener.cpp | 6 +- Framework/LiveData/test/TestDataListener.h | 4 +- .../LiveData/test/TestGroupDataListener.cpp | 2 +- .../LiveData/test/TestGroupDataListener.h | 3 +- .../ConvertSpiceDataToRealSpace.h | 8 +- .../MDAlgorithms/src/ConvToMDEventsWS.cpp | 4 +- .../src/ConvertSpiceDataToRealSpace.cpp | 22 +- .../src/ConvertToDetectorFaceMD.cpp | 2 +- .../src/ConvertToDiffractionMDWorkspace.cpp | 2 +- Framework/MDAlgorithms/src/IntegrateFlux.cpp | 3 +- .../MDAlgorithms/src/SaveIsawQvector.cpp | 2 +- .../test/ConvertCWPDMDToSpectraTest.h | 5 +- .../test/ConvertSpiceDataToRealSpaceTest.h | 3 +- .../test/IntegrateEllipsoidsTest.h | 2 +- .../Nexus/inc/MantidNexus/NexusClasses.h | 2 +- Framework/Nexus/inc/MantidNexus/NexusFileIO.h | 10 +- .../PythonInterface/mantid/api/CMakeLists.txt | 2 +- .../mantid/dataobjects/CMakeLists.txt | 2 +- .../dataobjects/src/Exports/EventList.cpp | 4 +- .../mantid/kernel/src/Exports/DateAndTime.cpp | 14 +- .../kernel/src/Exports/StlContainers.cpp | 4 +- .../kernel/src/Exports/TimeSeriesProperty.cpp | 2 +- .../PythonInterface/test/cpp/CMakeLists.txt | 1 - .../test/testhelpers/CMakeLists.txt | 2 +- .../src/MantidWebServiceAPIJobManager.cpp | 28 +- .../RemoteJobManagers/test/CMakeLists.txt | 2 +- .../SINQ/inc/MantidSINQ/SINQHMListener.h | 4 +- Framework/SINQ/src/SINQHMListener.cpp | 2 +- .../ScriptRepositoryImpl.h | 22 +- .../src/ScriptRepositoryImpl.cpp | 83 +- .../ScriptRepository/test/CMakeLists.txt | 2 +- .../test/ScriptRepositoryTestImpl.h | 39 +- .../MantidTestHelpers/MDEventsTestHelper.h | 2 +- .../WorkspaceCreationHelper.h | 12 +- .../src/ComponentCreationHelper.cpp | 2 +- .../TestHelpers/src/MDEventsTestHelper.cpp | 27 +- .../SingleCrystalDiffractionTestHelper.cpp | 2 +- .../src/WorkspaceCreationHelper.cpp | 67 +- Framework/Types/CMakeLists.txt | 22 +- .../inc/MantidTypes/{ => Core}/DateAndTime.h | 33 +- Framework/Types/inc/MantidTypes/DllConfig.h | 5 +- .../inc/MantidTypes/{ => Event}/TofEvent.h | 58 +- .../Types/src/{ => Core}/DateAndTime.cpp | 48 +- Framework/Types/src/{ => Event}/TofEvent.cpp | 6 +- Framework/Types/test/CMakeLists.txt | 3 +- Framework/Types/test/DateAndTimeTest.h | 266 ++++++- Framework/Types/test/TofEventTest.h | 9 +- .../src/AlignAndFocusPowder.cpp | 30 +- .../src/Mantid/AlgorithmHistoryWindow.cpp | 6 +- .../src/Mantid/AlgorithmHistoryWindow.h | 4 +- MantidPlot/src/Mantid/MantidUI.cpp | 391 +++++----- MantidPlot/src/Mantid/MantidUI.h | 4 +- .../Indirect/IndirectDataReductionTab.cpp | 2 +- .../Indirect/IndirectTab.cpp | 2 +- .../Indirect/IndirectTab.h | 6 +- .../Muon/MuonAnalysisHelper.cpp | 37 +- .../Muon/MuonAnalysisHelper.h | 2 +- .../Muon/MuonAnalysisResultTableTab.cpp | 92 ++- .../test/ALCLatestFileFinderTest.h | 34 +- .../test/MDFLogValueFinderTest.h | 11 +- .../test/MuonAnalysisHelperTest.h | 65 +- .../Common/MantidTreeWidgetItem.h | 4 +- qt/widgets/common/src/AlgorithmDialog.cpp | 1 + qt/widgets/common/src/CatalogHelper.cpp | 9 +- .../common/src/MantidTreeWidgetItem.cpp | 26 +- qt/widgets/common/src/SlitCalculator.cpp | 2 +- .../src/StartLiveDataDialog.cpp | 4 +- 308 files changed, 3382 insertions(+), 3578 deletions(-) rename Framework/Types/inc/MantidTypes/{ => Core}/DateAndTime.h (79%) rename Framework/Types/inc/MantidTypes/{ => Event}/TofEvent.h (67%) rename Framework/Types/src/{ => Core}/DateAndTime.cpp (97%) rename Framework/Types/src/{ => Event}/TofEvent.cpp (96%) diff --git a/Framework/API/inc/MantidAPI/Algorithm.h b/Framework/API/inc/MantidAPI/Algorithm.h index 5a8e442e15a..60387968fa8 100644 --- a/Framework/API/inc/MantidAPI/Algorithm.h +++ b/Framework/API/inc/MantidAPI/Algorithm.h @@ -423,7 +423,7 @@ private: bool executeAsyncImpl(const Poco::Void &i); - bool doCallProcessGroups(Mantid::Types::DateAndTime &start_time); + bool doCallProcessGroups(Mantid::Types::Core::DateAndTime &start_time); // Report that the algorithm has completed. void reportCompleted(const double &duration, diff --git a/Framework/API/inc/MantidAPI/AlgorithmHistory.h b/Framework/API/inc/MantidAPI/AlgorithmHistory.h index 8e3ea8e5fd4..862bbd41670 100644 --- a/Framework/API/inc/MantidAPI/AlgorithmHistory.h +++ b/Framework/API/inc/MantidAPI/AlgorithmHistory.h @@ -6,7 +6,7 @@ //---------------------------------------------------------------------- #include "MantidAPI/DllConfig.h" #include "MantidKernel/PropertyHistory.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include <nexus/NeXusFile.hpp> #include <boost/bind.hpp> @@ -74,19 +74,19 @@ class MANTID_API_DLL AlgorithmHistory { public: /// History container - /// The date-and-time will be stored as the Mantid::Types::DateAndTime type + /// The date-and-time will be stored as the Mantid::Types::Core::DateAndTime type explicit AlgorithmHistory( const Algorithm *const alg, - const Mantid::Types::DateAndTime &start = Mantid::Types::DateAndTime::getCurrentTime(), + const Types::Core::DateAndTime &start = Types::Core::DateAndTime::getCurrentTime(), const double &duration = -1.0, std::size_t uexeccount = 0); ~AlgorithmHistory(); AlgorithmHistory &operator=(const AlgorithmHistory &); AlgorithmHistory(const AlgorithmHistory &); AlgorithmHistory( const std::string &name, int vers, - const Mantid::Types::DateAndTime &start = Mantid::Types::DateAndTime::getCurrentTime(), + const Types::Core::DateAndTime &start = Types::Core::DateAndTime::getCurrentTime(), const double &duration = -1.0, std::size_t uexeccount = 0); - void addExecutionInfo(const Mantid::Types::DateAndTime &start, + void addExecutionInfo(const Types::Core::DateAndTime &start, const double &duration); void addProperty(const std::string &name, const std::string &value, bool isdefault, const unsigned int &direction = 99); @@ -101,7 +101,7 @@ public: /// get execution duration double executionDuration() const { return m_executionDuration; } /// get execution date - Mantid::Types::DateAndTime executionDate() const { return m_executionDate; } + Mantid::Types::Core::DateAndTime executionDate() const { return m_executionDate; } /// get the execution count const std::size_t &execCount() const { return m_execCount; } /// get parameter list of algorithm in history const @@ -141,7 +141,7 @@ public: void setExecCount(std::size_t execCount) { m_execCount = execCount; } /// Set data on history after it is created void fillAlgorithmHistory(const Algorithm *const alg, - const Mantid::Types::DateAndTime &start, + const Types::Core::DateAndTime &start, const double &duration, std::size_t uexeccount); // Allow Algorithm::execute to change the exec count & duration after the // algorithm was executed @@ -157,7 +157,7 @@ private: /// The version of the algorithm int m_version{-1}; /// The execution date of the algorithm - Mantid::Types::DateAndTime m_executionDate; + Mantid::Types::Core::DateAndTime m_executionDate; /// The execution duration of the algorithm double m_executionDuration{-1.0}; /// The PropertyHistory's defined for the algorithm diff --git a/Framework/API/inc/MantidAPI/HistoryView.h b/Framework/API/inc/MantidAPI/HistoryView.h index 2021417d836..6e5bf7cc90b 100644 --- a/Framework/API/inc/MantidAPI/HistoryView.h +++ b/Framework/API/inc/MantidAPI/HistoryView.h @@ -7,7 +7,7 @@ #include "MantidAPI/DllConfig.h" #include "MantidAPI/HistoryItem.h" #include "MantidAPI/WorkspaceHistory.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include <list> #include <vector> @@ -53,9 +53,9 @@ public: void unrollAll(); void roll(size_t index); void rollAll(); - void filterBetweenExecDate(Mantid::Types::DateAndTime start, - Mantid::Types::DateAndTime end = - Mantid::Types::DateAndTime::getCurrentTime()); + void filterBetweenExecDate(Mantid::Types::Core::DateAndTime start, + Mantid::Types::Core::DateAndTime end = + Mantid::Types::Core::DateAndTime::getCurrentTime()); /** * Get the list of History Items for this view. * diff --git a/Framework/API/inc/MantidAPI/IEventList.h b/Framework/API/inc/MantidAPI/IEventList.h index 6e591fb1f95..748aef66264 100644 --- a/Framework/API/inc/MantidAPI/IEventList.h +++ b/Framework/API/inc/MantidAPI/IEventList.h @@ -1,7 +1,7 @@ #ifndef MANTID_API_IEVENTLIST_H_ #define MANTID_API_IEVENTLIST_H_ #include "MantidAPI/DllConfig.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidAPI/MatrixWorkspace_fwd.h" #include "MantidAPI/ISpectrum.h" #include <functional> @@ -84,21 +84,21 @@ public: /// Return the list of event weight error values virtual void getWeightErrors(std::vector<double> &weightErrors) const = 0; /// Return the list of pulse time values - virtual std::vector<Mantid::Types::DateAndTime> getPulseTimes() const = 0; + virtual std::vector<Mantid::Types::Core::DateAndTime> getPulseTimes() const = 0; /// Get the minimum TOF from the list virtual double getTofMin() const = 0; /// Get the maximum TOF from the list virtual double getTofMax() const = 0; /// Get the minimum pulse time from the list - virtual Mantid::Types::DateAndTime getPulseTimeMin() const = 0; + virtual Mantid::Types::Core::DateAndTime getPulseTimeMin() const = 0; /// Get the maximum pulse time from the list - virtual Mantid::Types::DateAndTime getPulseTimeMax() const = 0; + virtual Mantid::Types::Core::DateAndTime getPulseTimeMax() const = 0; /// Get the maximum time at sample. - virtual Mantid::Types::DateAndTime + virtual Mantid::Types::Core::DateAndTime getTimeAtSampleMax(const double &tofFactor, const double &tofOffset) const = 0; /// Get the minimum time at sample - virtual Mantid::Types::DateAndTime + virtual Mantid::Types::Core::DateAndTime getTimeAtSampleMin(const double &tofFactor, const double &tofOffset) const = 0; /// Set the TOFs from the given list diff --git a/Framework/API/inc/MantidAPI/IEventWorkspace.h b/Framework/API/inc/MantidAPI/IEventWorkspace.h index a7506ec4543..f272cdeab72 100644 --- a/Framework/API/inc/MantidAPI/IEventWorkspace.h +++ b/Framework/API/inc/MantidAPI/IEventWorkspace.h @@ -56,11 +56,11 @@ public: virtual std::size_t getNumberEvents() const = 0; virtual double getTofMin() const = 0; virtual double getTofMax() const = 0; - virtual Mantid::Types::DateAndTime getPulseTimeMax() const = 0; - virtual Mantid::Types::DateAndTime getPulseTimeMin() const = 0; - virtual Mantid::Types::DateAndTime + virtual Mantid::Types::Core::DateAndTime getPulseTimeMax() const = 0; + virtual Mantid::Types::Core::DateAndTime getPulseTimeMin() const = 0; + virtual Mantid::Types::Core::DateAndTime getTimeAtSampleMax(double tofOffset = 0) const = 0; - virtual Mantid::Types::DateAndTime + virtual Mantid::Types::Core::DateAndTime getTimeAtSampleMin(double tofOffset = 0) const = 0; virtual EventType getEventType() const = 0; void generateHistogram(const std::size_t index, const MantidVec &X, diff --git a/Framework/API/inc/MantidAPI/ILiveListener.h b/Framework/API/inc/MantidAPI/ILiveListener.h index 195580b8bb2..65550d60381 100644 --- a/Framework/API/inc/MantidAPI/ILiveListener.h +++ b/Framework/API/inc/MantidAPI/ILiveListener.h @@ -6,7 +6,7 @@ //---------------------------------------------------------------------- #include "MantidAPI/DllConfig.h" #include "MantidGeometry/IDTypes.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/PropertyManager.h" #include <Poco/Net/SocketAddress.h> #include <string> @@ -78,7 +78,7 @@ public: * The value of 'start of run' is 1 second * for compatibility with the SNS live stream and ISIS Kafka live stream. */ - virtual void start(Mantid::Types::DateAndTime startTime = Mantid::Types::DateAndTime()) = 0; + virtual void start(Types::Core::DateAndTime startTime = Types::Core::DateAndTime()) = 0; /** Get the data that's been buffered since the last call to this method * (or since start() was called). diff --git a/Framework/API/inc/MantidAPI/IRemoteJobManager.h b/Framework/API/inc/MantidAPI/IRemoteJobManager.h index f69d252586c..3abb44a3d1c 100644 --- a/Framework/API/inc/MantidAPI/IRemoteJobManager.h +++ b/Framework/API/inc/MantidAPI/IRemoteJobManager.h @@ -2,7 +2,7 @@ #define MANTID_KERNEL_IREMOTEJOBMANAGER_H #include "MantidAPI/DllConfig.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" namespace Mantid { namespace API { @@ -91,13 +91,13 @@ public: /// Date-time of submission. No particular format can be assumed /// from the specific remote job managers, and some of them may /// not provide this info - Mantid::Types::DateAndTime submitDate; + Mantid::Types::Core::DateAndTime submitDate; /// Date-time the job actually started running. No particular /// format can be assumed - Mantid::Types::DateAndTime startDate; + Mantid::Types::Core::DateAndTime startDate; /// Date-time the job finished. No particular format can be /// assumed - Mantid::Types::DateAndTime completionTime; + Mantid::Types::Core::DateAndTime completionTime; /// Command line for this job (when running a command ideally this /// would be provided by the underlying job scheduling /// mechanism). As examples, Platform LSF provides this. For the diff --git a/Framework/API/inc/MantidAPI/LogManager.h b/Framework/API/inc/MantidAPI/LogManager.h index 04631134509..384de831562 100644 --- a/Framework/API/inc/MantidAPI/LogManager.h +++ b/Framework/API/inc/MantidAPI/LogManager.h @@ -2,9 +2,9 @@ #define MANTID_API_LOGMANAGER_H_ #include "MantidAPI/DllConfig.h" +#include "MantidKernel/make_unique.h" #include "MantidKernel/PropertyWithValue.h" #include "MantidKernel/Statistics.h" -#include "MantidKernel/make_unique.h" #include <memory> #include <vector> @@ -14,15 +14,17 @@ class File; namespace Mantid { namespace Types { +namespace Core { class DateAndTime; } +} // namespace Types namespace Kernel { template <class KEYTYPE, class VALUETYPE> class Cache; template <typename TYPE> class TimeSeriesProperty; class SplittingInterval; typedef std::vector<SplittingInterval> TimeSplitterType; class PropertyManager; -} // namespace Kernel +} namespace API { @@ -65,17 +67,17 @@ public: //------------------------------------------------------------- /// Set the run start and end - void setStartAndEndTime(const Mantid::Types::DateAndTime &start, - const Mantid::Types::DateAndTime &end); + void setStartAndEndTime(const Types::Core::DateAndTime &start, + const Types::Core::DateAndTime &end); /// Return the run start time - const Mantid::Types::DateAndTime startTime() const; + const Types::Core::DateAndTime startTime() const; /// Return the run end time - const Mantid::Types::DateAndTime endTime() const; + const Types::Core::DateAndTime endTime() const; //------------------------------------------------------------- /// Filter the logs by time - virtual void filterByTime(const Mantid::Types::DateAndTime start, - const Mantid::Types::DateAndTime stop); + virtual void filterByTime(const Types::Core::DateAndTime start, + const Types::Core::DateAndTime stop); /// Split the logs based on the given intervals virtual void splitByTime(Kernel::TimeSplitterType &splitter, std::vector<LogManager *> outputs) const; @@ -243,7 +245,7 @@ void LogManager::addProperty(const std::string &name, const TYPE &value, newProp->setUnits(units); addProperty(std::move(newProp), overwrite); } -} // namespace API -} // namespace Mantid +} +} #endif // MANTID_API_LOGMANAGER_H_ diff --git a/Framework/API/inc/MantidAPI/MatrixWorkspace.h b/Framework/API/inc/MantidAPI/MatrixWorkspace.h index 08877250a84..cb938a09ee9 100644 --- a/Framework/API/inc/MantidAPI/MatrixWorkspace.h +++ b/Framework/API/inc/MantidAPI/MatrixWorkspace.h @@ -18,8 +18,10 @@ class IndexInfo; } namespace Types { +namespace Core { class DateAndTime; } +} namespace Geometry { class ParameterMap; @@ -153,8 +155,8 @@ public: /// Gets MatrixWorkspace title (same as Run object run_title property) const std::string getTitle() const override; - virtual Mantid::Types::DateAndTime getFirstPulseTime() const; - Mantid::Types::DateAndTime getLastPulseTime() const; + virtual Types::Core::DateAndTime getFirstPulseTime() const; + Types::Core::DateAndTime getLastPulseTime() const; /// Returns the bin index for a given X value of a given workspace index size_t binIndexOf(const double xValue, const std::size_t = 0) const; diff --git a/Framework/API/inc/MantidAPI/PrecompiledHeader.h b/Framework/API/inc/MantidAPI/PrecompiledHeader.h index 4bf00c115c0..4869d894bee 100644 --- a/Framework/API/inc/MantidAPI/PrecompiledHeader.h +++ b/Framework/API/inc/MantidAPI/PrecompiledHeader.h @@ -9,7 +9,7 @@ #include "MantidKernel/Exception.h" #include "MantidKernel/V3D.h" #include "MantidKernel/Quat.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/ArrayProperty.h" #include "MantidGeometry/IComponent.h" #include "MantidGeometry/IDetector.h" diff --git a/Framework/API/inc/MantidAPI/Run.h b/Framework/API/inc/MantidAPI/Run.h index 05395fa67bc..ebbbb23ece4 100644 --- a/Framework/API/inc/MantidAPI/Run.h +++ b/Framework/API/inc/MantidAPI/Run.h @@ -65,8 +65,8 @@ public: Run &operator+=(const Run &rhs); /// Filter the logs by time - void filterByTime(const Mantid::Types::DateAndTime start, - const Mantid::Types::DateAndTime stop) override; + void filterByTime(const Types::Core::DateAndTime start, + const Types::Core::DateAndTime stop) override; /// Split the logs based on the given intervals void splitByTime(Kernel::TimeSplitterType &splitter, std::vector<LogManager *> outputs) const override; diff --git a/Framework/API/inc/MantidAPI/ScriptRepository.h b/Framework/API/inc/MantidAPI/ScriptRepository.h index 9266e8251f9..e41d02288b9 100644 --- a/Framework/API/inc/MantidAPI/ScriptRepository.h +++ b/Framework/API/inc/MantidAPI/ScriptRepository.h @@ -4,7 +4,7 @@ #include <string> #include <vector> -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidAPI/DllConfig.h" #include <vector> @@ -16,7 +16,7 @@ struct ScriptInfo { /// Identification of the author of the script. std::string author; /// Time of the last update of this file (remotelly) - Mantid::Types::DateAndTime pub_date; + Types::Core::DateAndTime pub_date; /// Marked for auto update bool auto_update; /// Directory Flag to indicate if the entry is a directory. diff --git a/Framework/API/src/Algorithm.cpp b/Framework/API/src/Algorithm.cpp index d1bb2f3514a..284457c7b42 100644 --- a/Framework/API/src/Algorithm.cpp +++ b/Framework/API/src/Algorithm.cpp @@ -9,7 +9,7 @@ #include "MantidAPI/WorkspaceHistory.h" #include "MantidKernel/ConfigService.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/EmptyValues.h" #include "MantidKernel/MultiThreaded.h" #include "MantidKernel/Strings.h" @@ -437,7 +437,7 @@ bool Algorithm::execute() { } notificationCenter().postNotification(new StartedNotification(this)); - Mantid::Types::DateAndTime startTime; + Mantid::Types::Core::DateAndTime startTime; // Return a failure if the algorithm hasn't been initialized if (!isInitialized()) { @@ -549,7 +549,7 @@ bool Algorithm::execute() { m_running = true; } - startTime = Mantid::Types::DateAndTime::getCurrentTime(); + startTime = Mantid::Types::Core::DateAndTime::getCurrentTime(); // Start a timer Timer timer; // Call the concrete algorithm's exec method @@ -1205,13 +1205,13 @@ bool Algorithm::checkGroups() { * * @return whether processGroups succeeds. */ -bool Algorithm::doCallProcessGroups(Mantid::Types::DateAndTime &startTime) { +bool Algorithm::doCallProcessGroups(Mantid::Types::Core::DateAndTime &startTime) { // In the base implementation of processGroups, this normally calls // this->execute() again on each member of the group. Other algorithms may // choose to override that behavior (examples: CompareWorkspaces, // CheckWorkspacesMatch, RenameWorkspace) - startTime = Mantid::Types::DateAndTime::getCurrentTime(); + startTime = Mantid::Types::Core::DateAndTime::getCurrentTime(); // Start a timer Timer timer; diff --git a/Framework/API/src/AlgorithmHistory.cpp b/Framework/API/src/AlgorithmHistory.cpp index c3a6e29e057..d4d3e5d3e40 100644 --- a/Framework/API/src/AlgorithmHistory.cpp +++ b/Framework/API/src/AlgorithmHistory.cpp @@ -9,7 +9,7 @@ namespace Mantid { namespace API { using Kernel::Property; -using Mantid::Types::DateAndTime; +using Types::Core::DateAndTime; using Kernel::PropertyHistory; using Kernel::PropertyHistory_sptr; using Kernel::PropertyHistory_const_sptr; @@ -24,7 +24,7 @@ using Kernel::PropertyHistories; * @param uexeccount :: an unsigned int for algorithm execution order */ AlgorithmHistory::AlgorithmHistory(const Algorithm *const alg, - const Mantid::Types::DateAndTime &start, + const Types::Core::DateAndTime &start, const double &duration, std::size_t uexeccount) : m_name(alg->name()), m_version(alg->version()), m_executionDate(start), @@ -49,7 +49,7 @@ AlgorithmHistory::~AlgorithmHistory() = default; @param uexeccount :: an unsigned int for algorithm execution order */ AlgorithmHistory::AlgorithmHistory(const std::string &name, int vers, - const Mantid::Types::DateAndTime &start, + const Types::Core::DateAndTime &start, const double &duration, std::size_t uexeccount) : m_name(name), m_version(vers), m_executionDate(start), @@ -83,7 +83,7 @@ void AlgorithmHistory::setProperties(const Algorithm *const alg) { * @param uexeccount :: an unsigned int for algorithm execution order */ void AlgorithmHistory::fillAlgorithmHistory(const Algorithm *const alg, - const Mantid::Types::DateAndTime &start, + const Types::Core::DateAndTime &start, const double &duration, std::size_t uexeccount) { m_name = alg->name(); diff --git a/Framework/API/src/ExperimentInfo.cpp b/Framework/API/src/ExperimentInfo.cpp index fd571cbd06a..156460e959a 100644 --- a/Framework/API/src/ExperimentInfo.cpp +++ b/Framework/API/src/ExperimentInfo.cpp @@ -15,9 +15,9 @@ #include "MantidGeometry/Instrument/Detector.h" #include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidGeometry/Instrument/InstrumentDefinitionParser.h" -#include "MantidGeometry/Instrument/ParComponentFactory.h" #include "MantidGeometry/Instrument/ParameterFactory.h" #include "MantidGeometry/Instrument/ParameterMap.h" +#include "MantidGeometry/Instrument/ParComponentFactory.h" #include "MantidGeometry/Instrument/RectangularDetector.h" #include "MantidGeometry/Instrument/XMLInstrumentParameter.h" @@ -26,13 +26,13 @@ #include "MantidBeamline/SpectrumInfo.h" #include "MantidKernel/ConfigService.h" -#include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/EigenConversionHelpers.h" -#include "MantidKernel/IPropertyManager.h" #include "MantidKernel/InstrumentInfo.h" +#include "MantidKernel/IPropertyManager.h" #include "MantidKernel/Property.h" -#include "MantidKernel/StringTokenizer.h" #include "MantidKernel/Strings.h" +#include "MantidKernel/StringTokenizer.h" #include "MantidKernel/make_unique.h" #include "MantidTypes/SpectrumDefinition.h" @@ -52,8 +52,8 @@ using namespace Mantid::Geometry; using namespace Mantid::Kernel; +using namespace Mantid::Types::Core; using namespace Poco::XML; -using namespace Mantid::Types; namespace Mantid { @@ -61,7 +61,7 @@ namespace API { namespace { /// static logger object Kernel::Logger g_log("ExperimentInfo"); -} // namespace +} /** Constructor */ @@ -182,11 +182,11 @@ void checkDetectorInfoSize(const Instrument &instr, "DetectorInfo and number of detectors in " "instrument"); } -} // namespace +} /** Set the instrument - * @param instr :: Shared pointer to an instrument. - */ +* @param instr :: Shared pointer to an instrument. +*/ void ExperimentInfo::setInstrument(const Instrument_const_sptr &instr) { m_spectrumInfoWrapper = nullptr; if (instr->isParametrized()) { @@ -209,10 +209,10 @@ void ExperimentInfo::setInstrument(const Instrument_const_sptr &instr) { } /** Get a shared pointer to the parametrized instrument associated with this - *workspace - * - * @return The instrument class - */ +*workspace +* +* @return The instrument class +*/ Instrument_const_sptr ExperimentInfo::getInstrument() const { populateIfNotLoaded(); checkDetectorInfoSize(*sptr_instrument, detectorInfo()); @@ -221,24 +221,24 @@ Instrument_const_sptr ExperimentInfo::getInstrument() const { } /** Returns a new copy of the instrument parameters - * @return a (new) copy of the instruments parameter map - */ +* @return a (new) copy of the instruments parameter map +*/ Geometry::ParameterMap &ExperimentInfo::instrumentParameters() { populateIfNotLoaded(); return *m_parmap; } /** Returns a const reference to the instrument parameters. - * @return a const reference to the instrument ParameterMap. - */ +* @return a const reference to the instrument ParameterMap. +*/ const Geometry::ParameterMap &ExperimentInfo::instrumentParameters() const { populateIfNotLoaded(); return *m_parmap; } /** Returns a const reference to the instrument parameters. - * @return a const reference to the instrument ParameterMap. - */ +* @return a const reference to the instrument ParameterMap. +*/ const Geometry::ParameterMap & ExperimentInfo::constInstrumentParameters() const { populateIfNotLoaded(); @@ -284,7 +284,7 @@ struct ParameterValue { const Run &runData; }; ///@endcond -} // namespace +} namespace { bool isPositionParameter(const std::string &name) { @@ -351,14 +351,14 @@ void adjustPositionsFromScaleFactor(ComponentInfo &componentInfo, applyRectangularDetectorScaleToComponentInfo( componentInfo, component->getComponentID(), ScaleX, ScaleY); } -} // namespace +} /** Add parameters to the instrument parameter map that are defined in - * instrument - * definition file or parameter file, which may contain parameters that - * require logfile data to be available. Logs must be loaded before running this - * method. - */ +* instrument +* definition file or parameter file, which may contain parameters that require +* logfile data to be available. Logs must be loaded before running this +* method. +*/ void ExperimentInfo::populateInstrumentParameters() { populateIfNotLoaded(); @@ -592,8 +592,8 @@ ChopperModel &ExperimentInfo::chopperModel(const size_t index) const { } /** Get a constant reference to the Sample associated with this workspace. - * @return const reference to Sample object - */ +* @return const reference to Sample object +*/ const Sample &ExperimentInfo::sample() const { populateIfNotLoaded(); std::lock_guard<std::recursive_mutex> lock(m_mutex); @@ -601,11 +601,11 @@ const Sample &ExperimentInfo::sample() const { } /** Get a reference to the Sample associated with this workspace. - * This non-const method will copy the sample if it is shared between - * more than one workspace, and the reference returned will be to the copy. - * Can ONLY be taken by reference! - * @return reference to sample object - */ +* This non-const method will copy the sample if it is shared between +* more than one workspace, and the reference returned will be to the copy. +* Can ONLY be taken by reference! +* @return reference to sample object +*/ Sample &ExperimentInfo::mutableSample() { populateIfNotLoaded(); // Use a double-check for sharing so that we only @@ -623,8 +623,8 @@ Sample &ExperimentInfo::mutableSample() { } /** Get a constant reference to the Run object associated with this workspace. - * @return const reference to run object - */ +* @return const reference to run object +*/ const Run &ExperimentInfo::run() const { populateIfNotLoaded(); std::lock_guard<std::recursive_mutex> lock(m_mutex); @@ -632,11 +632,11 @@ const Run &ExperimentInfo::run() const { } /** Get a reference to the Run object associated with this workspace. - * This non-const method will copy the Run object if it is shared between - * more than one workspace, and the reference returned will be to the copy. - * Can ONLY be taken by reference! - * @return reference to Run object - */ +* This non-const method will copy the Run object if it is shared between +* more than one workspace, and the reference returned will be to the copy. +* Can ONLY be taken by reference! +* @return reference to Run object +*/ Run &ExperimentInfo::mutableRun() { populateIfNotLoaded(); // Use a double-check for sharing so that we only @@ -750,8 +750,9 @@ Kernel::DeltaEMode::Type ExperimentInfo::getEMode() const { std::string emodeStr; if (run().hasProperty(emodeTag)) { emodeStr = run().getPropertyValueAsType<std::string>(emodeTag); - } else if (sptr_instrument && constInstrumentParameters().contains( - sptr_instrument.get(), emodeTag)) { + } else if (sptr_instrument && + constInstrumentParameters().contains(sptr_instrument.get(), + emodeTag)) { Geometry::Parameter_sptr param = constInstrumentParameters().get(sptr_instrument.get(), emodeTag); emodeStr = param->asString(); @@ -865,11 +866,11 @@ class myContentHandler : public Poco::XML::ContentHandler { }; /** Return from an IDF the values of the valid-from and valid-to attributes - * - * @param IDFfilename :: Full path of an IDF - * @param[out] outValidFrom :: Used to return valid-from date - * @param[out] outValidTo :: Used to return valid-to date - */ +* +* @param IDFfilename :: Full path of an IDF +* @param[out] outValidFrom :: Used to return valid-from date +* @param[out] outValidTo :: Used to return valid-to date +*/ void ExperimentInfo::getValidFromTo(const std::string &IDFfilename, std::string &outValidFrom, std::string &outValidTo) { @@ -890,13 +891,13 @@ void ExperimentInfo::getValidFromTo(const std::string &IDFfilename, } /** Return workspace start date as an ISO 8601 string. If this info not stored - *in workspace the - * method returns current date. This date is used for example to retrieve the - *instrument file. - * - * @return workspace start date as a string (current time if start date not - *available) - */ +*in workspace the +* method returns current date. This date is used for example to retrieve the +*instrument file. +* +* @return workspace start date as a string (current time if start date not +*available) +*/ std::string ExperimentInfo::getWorkspaceStartDate() const { populateIfNotLoaded(); std::string date; @@ -905,13 +906,13 @@ std::string ExperimentInfo::getWorkspaceStartDate() const { } catch (std::runtime_error &) { g_log.information("run_start/start_time not stored in workspace. Default " "to current date."); - date = Mantid::Types::DateAndTime::getCurrentTime().toISO8601String(); + date = Types::Core::DateAndTime::getCurrentTime().toISO8601String(); } return date; } /** Return workspace start date as a formatted string (strftime, as - * returned by Mantid::Types::DateAndTime) string, if available. If + * returned by Types::Core::DateAndTime) string, if available. If * unavailable, an empty string is returned * * @return workspace start date as a string (empty if no date available) @@ -945,24 +946,24 @@ std::string ExperimentInfo::getAvailableWorkspaceEndDate() const { } /** A given instrument may have multiple IDFs associated with it. This method - *return an identifier which identify a given IDF for a given instrument. - * An IDF filename is required to be of the form IDFname + _Definition + - *Identifier + .xml, the identifier then is the part of a filename that - *identifies the IDF valid at a given date. - * - * If several IDF files are valid at the given date the file with the most - *recent from date is selected. If no such files are found the file with the - *latest from date is selected. - * - * If no file is found for the given instrument, an empty string is returned. - * - * @param instrumentName :: Instrument name e.g. GEM, TOPAS or BIOSANS - * @param date :: ISO 8601 date - * @return full path of IDF - * - * @throws Exception::NotFoundError If no valid instrument definition filename - *is found - */ +*return an identifier which identify a given IDF for a given instrument. +* An IDF filename is required to be of the form IDFname + _Definition + +*Identifier + .xml, the identifier then is the part of a filename that +*identifies the IDF valid at a given date. +* +* If several IDF files are valid at the given date the file with the most +*recent from date is selected. If no such files are found the file with the +*latest from date is selected. +* +* If no file is found for the given instrument, an empty string is returned. +* +* @param instrumentName :: Instrument name e.g. GEM, TOPAS or BIOSANS +* @param date :: ISO 8601 date +* @return full path of IDF +* +* @throws Exception::NotFoundError If no valid instrument definition filename is +* found +*/ std::string ExperimentInfo::getInstrumentFilename(const std::string &instrumentName, const std::string &date) { @@ -970,7 +971,7 @@ ExperimentInfo::getInstrumentFilename(const std::string &instrumentName, // Just use the current date g_log.debug() << "No date specified, using current date and time.\n"; const std::string now = - Mantid::Types::DateAndTime::getCurrentTime().toISO8601String(); + Types::Core::DateAndTime::getCurrentTime().toISO8601String(); // Recursively call this method, but with both parameters. return ExperimentInfo::getInstrumentFilename(instrumentName, now); } @@ -988,19 +989,17 @@ ExperimentInfo::getInstrumentFilename(const std::string &instrumentName, boost::regex regex(instrument + "_Definition.*\\.xml", boost::regex_constants::icase); Poco::DirectoryIterator end_iter; - DateAndTime d = DateAndTimeHelpers::createFromISO8601(date); + DateAndTime d(date); bool foundGoodFile = false; // True if we have found a matching file (valid at the given date) std::string mostRecentIDF; // store most recently starting matching IDF if // found, else most recently starting IDF. - DateAndTime refDate = DateAndTimeHelpers::createFromISO8601( - "1900-01-31 23:59:00"); // used to help determine the most - // recently starting IDF, if none - // match - DateAndTime refDateGoodFile = DateAndTimeHelpers::createFromISO8601( - "1900-01-31 23:59:00"); // used to help determine - // the most recently - // starting matching IDF + DateAndTime refDate("1900-01-31 23:59:00"); // used to help determine the most + // recently starting IDF, if none + // match + DateAndTime refDateGoodFile("1900-01-31 23:59:00"); // used to help determine + // the most recently + // starting matching IDF for (const auto &directoryName : directoryNames) { // This will iterate around the directories from user ->etc ->install, and // find the first beat file @@ -1019,13 +1018,13 @@ ExperimentInfo::getInstrumentFilename(const std::string &instrumentName, getValidFromTo(pathName, validFrom, validTo); g_log.debug() << "File '" << pathName << " valid dates: from '" << validFrom << "' to '" << validTo << "'\n"; - DateAndTime from = DateAndTimeHelpers::createFromISO8601(validFrom); + DateAndTime from(validFrom); // Use a default valid-to date if none was found. DateAndTime to; if (validTo.length() > 0) - DateAndTimeHelpers::setFromISO8601(to, validTo); + to.setFromISO8601(validTo); else - DateAndTimeHelpers::setFromISO8601(to, "2100-01-01T00:00:00"); + to.setFromISO8601("2100-01-01T00:00:00"); if (from <= d && d <= to) { if (from > refDateGoodFile) { // We'd found a matching file more diff --git a/Framework/API/src/HistoryView.cpp b/Framework/API/src/HistoryView.cpp index 0acee9992b5..6dd1c8b1261 100644 --- a/Framework/API/src/HistoryView.cpp +++ b/Framework/API/src/HistoryView.cpp @@ -193,12 +193,12 @@ void HistoryView::roll(std::vector<HistoryItem>::iterator &it) { * @param start Start of time range * @param end End of time range */ -void HistoryView::filterBetweenExecDate(Mantid::Types::DateAndTime start, - Mantid::Types::DateAndTime end) { +void HistoryView::filterBetweenExecDate(Mantid::Types::Core::DateAndTime start, + Mantid::Types::Core::DateAndTime end) { auto lastItem = std::remove_if( m_historyItems.begin(), m_historyItems.end(), [&start, &end](const HistoryItem &item) { - Mantid::Types::DateAndTime algExecutionDate = + Mantid::Types::Core::DateAndTime algExecutionDate = item.getAlgorithmHistory()->executionDate(); return algExecutionDate < start || algExecutionDate > end; }); diff --git a/Framework/API/src/LogManager.cpp b/Framework/API/src/LogManager.cpp index f9b8f6ef751..8f0df464c22 100644 --- a/Framework/API/src/LogManager.cpp +++ b/Framework/API/src/LogManager.cpp @@ -3,16 +3,14 @@ #include "MantidKernel/PropertyManager.h" #include "MantidKernel/PropertyNexus.h" #include "MantidKernel/TimeSeriesProperty.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include <nexus/NeXusFile.hpp> -using namespace Mantid::Types; - namespace Mantid { namespace API { using namespace Kernel; +using namespace Types::Core; namespace { /// static logger @@ -86,7 +84,7 @@ bool convertPropertyToDouble(const Property *property, double &value, convertPropertyToDouble<uint64_t>(property, value, function) || convertPropertyToDouble<float>(property, value, function); } -} // namespace +} /// Name of the log entry containing the proton charge when retrieved using /// getProtonCharge @@ -98,17 +96,14 @@ const char *LogManager::PROTON_CHARGE_LOG_NAME = "gd_prtn_chrg"; LogManager::LogManager() : m_manager(Kernel::make_unique<Kernel::PropertyManager>()), - m_singleValueCache( - Kernel::make_unique<Kernel::Cache< - std::pair<std::string, Kernel::Math::StatisticType>, double>>()) { -} + m_singleValueCache(Kernel::make_unique<Kernel::Cache< + std::pair<std::string, Kernel::Math::StatisticType>, double>>()) {} LogManager::LogManager(const LogManager &other) : m_manager(Kernel::make_unique<Kernel::PropertyManager>(*other.m_manager)), - m_singleValueCache( - Kernel::make_unique<Kernel::Cache< - std::pair<std::string, Kernel::Math::StatisticType>, double>>( - *other.m_singleValueCache)) {} + m_singleValueCache(Kernel::make_unique<Kernel::Cache< + std::pair<std::string, Kernel::Math::StatisticType>, double>>( + *other.m_singleValueCache)) {} // Defined as default in source for forward declaration with std::unique_ptr. LogManager::~LogManager() = default; @@ -122,12 +117,12 @@ LogManager &LogManager::operator=(const LogManager &other) { } /** - * Set the run start and end - * @param start :: The run start - * @param end :: The run end - */ -void LogManager::setStartAndEndTime(const Mantid::Types::DateAndTime &start, - const Mantid::Types::DateAndTime &end) { +* Set the run start and end +* @param start :: The run start +* @param end :: The run end +*/ +void LogManager::setStartAndEndTime(const Types::Core::DateAndTime &start, + const Types::Core::DateAndTime &end) { this->addProperty<std::string>("start_time", start.toISO8601String(), true); this->addProperty<std::string>("end_time", end.toISO8601String(), true); } @@ -139,12 +134,12 @@ void LogManager::setStartAndEndTime(const Mantid::Types::DateAndTime &start, * @returns The start time of the run * @throws std::runtime_error if neither property is defined */ -const Mantid::Types::DateAndTime LogManager::startTime() const { +const Types::Core::DateAndTime LogManager::startTime() const { const std::string start_prop("start_time"); if (hasProperty(start_prop)) { try { - DateAndTime start_time = DateAndTimeHelpers::createFromISO8601(getProperty(start_prop)->value()); - if (start_time != DateAndTimeHelpers::GPS_EPOCH) { + DateAndTime start_time(getProperty(start_prop)->value()); + if (start_time != DateAndTime::GPS_EPOCH()) { return start_time; } } catch (std::invalid_argument &) { /*Swallow and move on*/ @@ -154,8 +149,8 @@ const Mantid::Types::DateAndTime LogManager::startTime() const { const std::string run_start_prop("run_start"); if (hasProperty(run_start_prop)) { try { - DateAndTime start_time = DateAndTimeHelpers::createFromISO8601(getProperty(run_start_prop)->value()); - if (start_time != DateAndTimeHelpers::GPS_EPOCH) { + DateAndTime start_time(getProperty(run_start_prop)->value()); + if (start_time != DateAndTime::GPS_EPOCH()) { return start_time; } } catch (std::invalid_argument &) { /*Swallow and move on*/ @@ -171,11 +166,11 @@ const Mantid::Types::DateAndTime LogManager::startTime() const { * @returns The end time of the run * @throws std::runtime_error if neither property is defined */ -const Mantid::Types::DateAndTime LogManager::endTime() const { +const Types::Core::DateAndTime LogManager::endTime() const { const std::string end_prop("end_time"); if (hasProperty(end_prop)) { try { - return DateAndTimeHelpers::createFromISO8601(getProperty(end_prop)->value()); + return DateAndTime(getProperty(end_prop)->value()); } catch (std::invalid_argument &) { /*Swallow and move on*/ } } @@ -183,7 +178,7 @@ const Mantid::Types::DateAndTime LogManager::endTime() const { const std::string run_end_prop("run_end"); if (hasProperty(run_end_prop)) { try { - return DateAndTimeHelpers::createFromISO8601(getProperty(run_end_prop)->value()); + return DateAndTime(getProperty(run_end_prop)->value()); } catch (std::invalid_argument &) { /*Swallow and move on*/ } } @@ -202,8 +197,8 @@ const Mantid::Types::DateAndTime LogManager::endTime() const { * @param stop :: Absolute stop time. Any log entries at times < than this time *are kept. */ -void LogManager::filterByTime(const Mantid::Types::DateAndTime start, - const Mantid::Types::DateAndTime stop) { +void LogManager::filterByTime(const Types::Core::DateAndTime start, + const Types::Core::DateAndTime stop) { // The propery manager operator will make all timeseriesproperties filter. m_manager->filterByTime(start, stop); } @@ -245,13 +240,13 @@ void LogManager::filterByLog(const Kernel::TimeSeriesProperty<bool> &filter) { //----------------------------------------------------------------------------------------------- /** - * Add data to the object in the form of a property - * @param prop :: A pointer to a property whose ownership is transferred to + * Add data to the object in the form of a property + * @param prop :: A pointer to a property whose ownership is transferred to * this - * object - * @param overwrite :: If true, a current value is overwritten. (Default: + * object + * @param overwrite :: If true, a current value is overwritten. (Default: * False) - */ + */ void LogManager::addProperty(std::unique_ptr<Kernel::Property> prop, bool overwrite) { // Make an exception for the proton charge @@ -543,10 +538,10 @@ void LogManager::clearLogs() { m_manager->clear(); } /** @cond */ /// Macro to instantiate concrete template members #define INSTANTIATE(TYPE) \ - template MANTID_API_DLL Kernel::TimeSeriesProperty<TYPE> \ - *LogManager::getTimeSeriesProperty(const std::string &) const; \ - template MANTID_API_DLL TYPE LogManager::getPropertyValueAsType( \ - const std::string &) const; + template MANTID_API_DLL Kernel::TimeSeriesProperty<TYPE> * \ + LogManager::getTimeSeriesProperty(const std::string &) const; \ + template MANTID_API_DLL TYPE \ + LogManager::getPropertyValueAsType(const std::string &) const; INSTANTIATE(double) INSTANTIATE(int32_t) @@ -568,5 +563,5 @@ template MANTID_API_DLL std::vector<long> LogManager::getPropertyValueAsType(const std::string &) const; /** @endcond */ -} // namespace API -} // namespace Mantid +} // API namespace +} diff --git a/Framework/API/src/MatrixWorkspace.cpp b/Framework/API/src/MatrixWorkspace.cpp index 1c122d26300..5355e10f6ad 100644 --- a/Framework/API/src/MatrixWorkspace.cpp +++ b/Framework/API/src/MatrixWorkspace.cpp @@ -18,7 +18,6 @@ #include "MantidKernel/MDUnit.h" #include "MantidKernel/Strings.h" #include "MantidKernel/TimeSeriesProperty.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/make_unique.h" #include "MantidKernel/VectorHelper.h" #include "MantidParallel/Communicator.h" @@ -29,7 +28,7 @@ #include <functional> #include <numeric> -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; using Mantid::Kernel::TimeSeriesProperty; using Mantid::Kernel::Strings::toString; @@ -1159,12 +1158,12 @@ size_t MatrixWorkspace::getMemorySizeForXAxes() const { * @throw invalid_argument if the log is not a double TimeSeriesProperty (should *be impossible) */ -Mantid::Types::DateAndTime MatrixWorkspace::getFirstPulseTime() const { +Types::Core::DateAndTime MatrixWorkspace::getFirstPulseTime() const { TimeSeriesProperty<double> *log = this->run().getTimeSeriesProperty<double>("proton_charge"); DateAndTime startDate = log->firstTime(); - DateAndTime reference = DateAndTimeHelpers::createFromISO8601("1991-01-01T00:00:00"); + DateAndTime reference("1991-01-01T00:00:00"); int i = 0; // Find the first pulse after 1991 @@ -1185,7 +1184,7 @@ Mantid::Types::DateAndTime MatrixWorkspace::getFirstPulseTime() const { * @throw invalid_argument if the log is not a double TimeSeriesProperty (should *be impossible) */ -Mantid::Types::DateAndTime MatrixWorkspace::getLastPulseTime() const { +Types::Core::DateAndTime MatrixWorkspace::getLastPulseTime() const { TimeSeriesProperty<double> *log = this->run().getTimeSeriesProperty<double>("proton_charge"); return log->lastTime(); diff --git a/Framework/API/src/Run.cpp b/Framework/API/src/Run.cpp index b4a215c0aed..4197729d4cb 100644 --- a/Framework/API/src/Run.cpp +++ b/Framework/API/src/Run.cpp @@ -1,6 +1,6 @@ #include "MantidAPI/Run.h" #include "MantidGeometry/Instrument/Goniometer.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/Matrix.h" #include "MantidKernel/PropertyManager.h" #include "MantidKernel/TimeSeriesProperty.h" @@ -81,8 +81,8 @@ boost::shared_ptr<Run> Run::clone() { * @param stop :: Absolute stop time. Any log entries at times < than this time *are kept. */ -void Run::filterByTime(const Mantid::Types::DateAndTime start, - const Mantid::Types::DateAndTime stop) { +void Run::filterByTime(const Types::Core::DateAndTime start, + const Types::Core::DateAndTime stop) { LogManager::filterByTime(start, stop); // Re-integrate proton charge this->integrateProtonCharge(); diff --git a/Framework/API/src/WorkspaceHistory.cpp b/Framework/API/src/WorkspaceHistory.cpp index c87a77a9656..a7c6438f82b 100644 --- a/Framework/API/src/WorkspaceHistory.cpp +++ b/Framework/API/src/WorkspaceHistory.cpp @@ -1,11 +1,10 @@ -#include "MantidAPI/WorkspaceHistory.h" #include "MantidAPI/Algorithm.h" #include "MantidAPI/AlgorithmHistory.h" #include "MantidAPI/HistoryView.h" -#include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidAPI/WorkspaceHistory.h" #include "MantidKernel/EnvironmentHistory.h" -#include "MantidKernel/StringTokenizer.h" #include "MantidKernel/Strings.h" +#include "MantidKernel/StringTokenizer.h" #include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/split.hpp> @@ -21,7 +20,7 @@ namespace API { namespace { /// static logger object Kernel::Logger g_log("WorkspaceHistory"); -} // namespace +} /// Default Constructor WorkspaceHistory::WorkspaceHistory() : m_environment() {} @@ -360,12 +359,12 @@ WorkspaceHistory::parseAlgorithmHistory(const std::string &rawData) { Poco::DateTime start_timedate; // This is needed by the Poco parsing function int tzdiff(-1); - Mantid::Types::DateAndTime utc_start; + Mantid::Types::Core::DateAndTime utc_start; if (!Poco::DateTimeParser::tryParse("%Y-%b-%d %H:%M:%S", date + " " + time, start_timedate, tzdiff)) { g_log.warning() << "Error parsing start time in algorithm history entry." << "\n"; - utc_start = Mantid::Types::DateAndTimeHelpers::defaultTime(); + utc_start = Types::Core::DateAndTime::defaultTime(); } // Get the duration getWordsInString(info[EXEC_DUR], dummy, dummy, temp, dummy); diff --git a/Framework/API/test/AlgorithmHistoryTest.h b/Framework/API/test/AlgorithmHistoryTest.h index 04f8d2c7320..68e3e53362e 100644 --- a/Framework/API/test/AlgorithmHistoryTest.h +++ b/Framework/API/test/AlgorithmHistoryTest.h @@ -203,9 +203,9 @@ private: timeinfo->tm_min = 54; timeinfo->tm_sec = 49; // Convert to time_t but assuming the tm is specified in UTC time. - std::time_t execTime_t = Mantid::Kernel::DateAndTime::utc_mktime(timeinfo); + std::time_t execTime_t = Mantid::Types::Core::DateAndTime::utc_mktime(timeinfo); // Create a UTC datetime from it - Mantid::Types::DateAndTime execTime; + Mantid::Types::Core::DateAndTime execTime; execTime.set_from_time_t(execTime_t); // Not really much to test diff --git a/Framework/API/test/CMakeLists.txt b/Framework/API/test/CMakeLists.txt index 4a56bbed221..5bfdb4dd813 100644 --- a/Framework/API/test/CMakeLists.txt +++ b/Framework/API/test/CMakeLists.txt @@ -14,6 +14,7 @@ if ( CXXTEST_FOUND ) ) cxxtest_add_test ( APITest ${TEST_FILES} ${GMOCK_TEST_FILES}) target_link_libraries( APITest LINK_PRIVATE ${TCMALLOC_LIBRARIES_LINKTIME} ${MANTIDLIBS} + Types API Nexus ${JSONCPP_LIBRARIES} diff --git a/Framework/API/test/ExperimentInfoTest.h b/Framework/API/test/ExperimentInfoTest.h index 289d016b079..49d6203bcf1 100644 --- a/Framework/API/test/ExperimentInfoTest.h +++ b/Framework/API/test/ExperimentInfoTest.h @@ -1,34 +1,33 @@ #ifndef MANTID_API_EXPERIMENTINFOTEST_H_ #define MANTID_API_EXPERIMENTINFOTEST_H_ -#include "MantidAPI/ChopperModel.h" #include "MantidAPI/ExperimentInfo.h" +#include "MantidAPI/ChopperModel.h" #include "MantidAPI/ModeratorModel.h" #include "MantidAPI/Run.h" #include "MantidAPI/Sample.h" #include "MantidAPI/SpectrumInfo.h" #include "MantidGeometry/Crystal/OrientedLattice.h" #include "MantidGeometry/Instrument/ComponentInfo.h" -#include "MantidGeometry/Instrument/Detector.h" #include "MantidGeometry/Instrument/DetectorGroup.h" +#include "MantidGeometry/Instrument/Detector.h" #include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidKernel/ConfigService.h" -#include "MantidKernel/DateAndTimeHelpers.h" -#include "MantidKernel/Matrix.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/SingletonHolder.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/Matrix.h" #include "MantidAPI/FileFinder.h" #include "MantidTestHelpers/ComponentCreationHelper.h" #include "MantidTestHelpers/NexusTestHelper.h" #include "PropertyManagerHelper.h" -#include <nexus/NeXusException.hpp> #include <nexus/NeXusFile.hpp> +#include <nexus/NeXusException.hpp> -#include <Poco/DirectoryIterator.h> -#include <boost/regex.hpp> #include <cxxtest/TestSuite.h> +#include <boost/regex.hpp> +#include <Poco/DirectoryIterator.h> #include <set> #include <unordered_map> @@ -37,7 +36,7 @@ using namespace Mantid::API; using namespace Mantid::Kernel; using namespace Mantid::Geometry; using namespace NeXus; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; class FakeChopper : public Mantid::API::ChopperModel { public: @@ -508,12 +507,12 @@ public: found = l_filenamePart.find("_Definition"); fromToEntry ft; ft.path = dir_itr->path(); - DateAndTimeHelpers::setFromISO8601(ft.from, validFrom); + ft.from.setFromISO8601(validFrom); // Valid TO is optional if (validTo.length() > 0) - DateAndTimeHelpers::setFromISO8601(ft.to, validTo); + ft.to.setFromISO8601(validTo); else - DateAndTimeHelpers::setFromISO8601(ft.to, "2100-01-01T00:00:00"); + ft.to.setFromISO8601("2100-01-01T00:00:00"); idfFiles.emplace(l_filenamePart.substr(0, found), ft); idfIdentifiers.insert(l_filenamePart.substr(0, found)); @@ -523,8 +522,7 @@ public: // iterator to browse through the multimap: paramInfoFromIDF std::unordered_multimap<std::string, fromToEntry>::const_iterator it1, it2; std::pair<std::unordered_multimap<std::string, fromToEntry>::iterator, - std::unordered_multimap<std::string, fromToEntry>::iterator> - ret; + std::unordered_multimap<std::string, fromToEntry>::iterator> ret; for (auto setIt = idfIdentifiers.begin(); setIt != idfIdentifiers.end(); setIt++) { @@ -715,9 +713,9 @@ public: } /** - * Test declaring an ExperimentInfo property and retrieving as const or - * non-const - */ + * Test declaring an ExperimentInfo property and retrieving as const or + * non-const + */ void testGetProperty_const_sptr() { const std::string eiName = "InputEi"; ExperimentInfo_sptr eiInput(new ExperimentInfo()); diff --git a/Framework/API/test/HistoryViewTest.h b/Framework/API/test/HistoryViewTest.h index c9bc2627fd5..b1e07a47aff 100644 --- a/Framework/API/test/HistoryViewTest.h +++ b/Framework/API/test/HistoryViewTest.h @@ -4,11 +4,10 @@ #include <cxxtest/TestSuite.h> #include "MantidAPI/Algorithm.h" #include "MantidAPI/HistoryView.h" -#include "MantidKernel/DateAndTimeHelpers.h" using namespace Mantid::API; using namespace Mantid::Kernel; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; class HistoryViewTest : public CxxTest::TestSuite { @@ -45,7 +44,7 @@ private: private: AlgorithmHistory_sptr createFromTestAlg(const std::string &name, - DateAndTime execTime = DateAndTimeHelpers::defaultTime()) { + DateAndTime execTime = DateAndTime::defaultTime()) { testalg alg; alg.initialize(); alg.setPropertyValue("name", name); diff --git a/Framework/API/test/LiveListenerTest.h b/Framework/API/test/LiveListenerTest.h index 4e02e933e12..e666b76a062 100644 --- a/Framework/API/test/LiveListenerTest.h +++ b/Framework/API/test/LiveListenerTest.h @@ -19,7 +19,7 @@ public: MOCK_CONST_METHOD0(supportsHistory, bool()); MOCK_CONST_METHOD0(buffersEvents, bool()); MOCK_METHOD1(connect, bool(const Poco::Net::SocketAddress &)); - MOCK_METHOD1(start, void(Mantid::Types::DateAndTime)); + MOCK_METHOD1(start, void(Mantid::Types::Core::DateAndTime)); MOCK_METHOD0(extractData, boost::shared_ptr<Mantid::API::Workspace>()); MOCK_METHOD0(isConnected, bool()); MOCK_METHOD0(runStatus, RunStatus()); diff --git a/Framework/API/test/LogFilterGeneratorTest.h b/Framework/API/test/LogFilterGeneratorTest.h index 0fd7dcd4669..daa86942393 100644 --- a/Framework/API/test/LogFilterGeneratorTest.h +++ b/Framework/API/test/LogFilterGeneratorTest.h @@ -6,20 +6,18 @@ #include "MantidAPI/LogFilterGenerator.h" #include "MantidAPI/Run.h" #include "MantidAPI/WorkspaceFactory.h" -#include "MantidKernel/DateAndTimeHelpers.h" -#include "MantidKernel/TimeSeriesProperty.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/make_unique.h" +#include "MantidKernel/TimeSeriesProperty.h" #include "MantidTestHelpers/FakeObjects.h" -#include "MantidTypes/DateAndTime.h" #include <numeric> -using Mantid::API::LogFilterGenerator; using Mantid::API::MatrixWorkspace_sptr; +using Mantid::API::LogFilterGenerator; +using Mantid::Types::Core::DateAndTime; using Mantid::Kernel::LogFilter; using Mantid::Kernel::TimeSeriesProperty; -using Mantid::Types::DateAndTime; -using namespace Mantid::Types; class LogFilterGeneratorTest : public CxxTest::TestSuite { public: @@ -67,12 +65,9 @@ public: TS_ASSERT(filter->filter()); const auto &resultMap = filter->filter()->valueAsCorrectMap(); std::map<DateAndTime, bool> expected; - expected.emplace( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"), true); - expected.emplace( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30"), false); - expected.emplace( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:00"), true); + expected.emplace(DateAndTime("2007-11-30T16:17:00"), true); + expected.emplace(DateAndTime("2007-11-30T16:17:30"), false); + expected.emplace(DateAndTime("2007-11-30T16:18:00"), true); TS_ASSERT_EQUALS(resultMap.size(), 3); TS_ASSERT_EQUALS(resultMap, expected); } @@ -94,10 +89,8 @@ public: const auto &values = filter->filter()->valueAsCorrectMap(); TS_ASSERT(!values.empty()); std::map<DateAndTime, bool> expected; - expected.emplace( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:20"), true); - expected.emplace( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:50"), false); + expected.emplace(DateAndTime("2007-11-30T16:18:20"), true); + expected.emplace(DateAndTime("2007-11-30T16:18:50"), false); TS_ASSERT_EQUALS(expected, values); } @@ -118,16 +111,11 @@ public: // 16:18:00 T F F // 16:18:20 T T T // 16:18:50 T F F - expected.emplace( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"), false); - expected.emplace( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30"), false); - expected.emplace( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:00"), false); - expected.emplace( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:20"), true); - expected.emplace( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:50"), false); + expected.emplace(DateAndTime("2007-11-30T16:17:00"), false); + expected.emplace(DateAndTime("2007-11-30T16:17:30"), false); + expected.emplace(DateAndTime("2007-11-30T16:18:00"), false); + expected.emplace(DateAndTime("2007-11-30T16:18:20"), true); + expected.emplace(DateAndTime("2007-11-30T16:18:50"), false); TS_ASSERT_EQUALS(expected, values); } @@ -154,8 +142,7 @@ private: auto log = Mantid::Kernel::make_unique<TimeSeriesProperty<double>>("TestLog"); constexpr size_t logSize(12); - const DateAndTime initialTime = - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); + const DateAndTime initialTime("2007-11-30T16:17:00"); std::vector<DateAndTime> times; std::vector<double> values; times.reserve(logSize); diff --git a/Framework/API/test/LogManagerTest.h b/Framework/API/test/LogManagerTest.h index 208688e90ec..25af1b11eb3 100644 --- a/Framework/API/test/LogManagerTest.h +++ b/Framework/API/test/LogManagerTest.h @@ -2,21 +2,20 @@ #define LOG_MANAGER_TEST_H_ #include "MantidAPI/LogManager.h" -#include "MantidGeometry/Instrument/Goniometer.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/Exception.h" #include "MantidKernel/Matrix.h" #include "MantidKernel/Property.h" #include "MantidKernel/TimeSeriesProperty.h" #include "MantidKernel/V3D.h" +#include <cxxtest/TestSuite.h> #include "MantidTestHelpers/NexusTestHelper.h" +#include "MantidGeometry/Instrument/Goniometer.h" #include <cmath> -#include <cxxtest/TestSuite.h> using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::Geometry; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; // Helper class namespace { @@ -54,7 +53,7 @@ void addTestTimeSeries(LogManager &run, const std::string &name) { timeSeries->addValue("2012-07-19T16:19:20", 24); run.addProperty(timeSeries); } -} // namespace +} void addTimeSeriesEntry(LogManager &runInfo, std::string name, double val) { TimeSeriesProperty<double> *tsp; @@ -104,20 +103,17 @@ public: auto run_start_prop = new PropertyWithValue<std::string>("run_start", run_start); runInfo.addProperty(run_start_prop); - TS_ASSERT_EQUALS(runInfo.startTime(), - DateAndTimeHelpers::createFromISO8601(run_start)); + TS_ASSERT_EQUALS(runInfo.startTime(), DateAndTime(run_start)); // Add start_time and see that get picked up in preference const std::string start_time("2013-12-19T13:40:00"); auto start_time_prop = new PropertyWithValue<std::string>("start_time", start_time); runInfo.addProperty(start_time_prop); - TS_ASSERT_EQUALS(runInfo.startTime(), - DateAndTimeHelpers::createFromISO8601(start_time)); + TS_ASSERT_EQUALS(runInfo.startTime(), DateAndTime(start_time)); // But get back run_start again if start_time is equal to the epoch const std::string epoch("1990-01-01T00:00:00"); start_time_prop->setValue(epoch); - TS_ASSERT_EQUALS(runInfo.startTime(), - DateAndTimeHelpers::createFromISO8601(run_start)); + TS_ASSERT_EQUALS(runInfo.startTime(), DateAndTime(run_start)); // And back to failure if they're both that run_start_prop->setValue(epoch); TS_ASSERT_THROWS(runInfo.startTime(), std::runtime_error); @@ -125,13 +121,11 @@ public: // Set run_start back to valid value and make start_time contain nonsense run_start_prop->setValue(run_start); start_time_prop->setValue("__"); - TS_ASSERT_EQUALS(runInfo.startTime(), - DateAndTimeHelpers::createFromISO8601(run_start)); + TS_ASSERT_EQUALS(runInfo.startTime(), DateAndTime(run_start)); // Now make start_time a completely different property type runInfo.removeProperty("start_time"); runInfo.addProperty(new PropertyWithValue<double>("start_time", 3.33)); - TS_ASSERT_EQUALS(runInfo.startTime(), - DateAndTimeHelpers::createFromISO8601(run_start)); + TS_ASSERT_EQUALS(runInfo.startTime(), DateAndTime(run_start)); // Now make run_start something invalid run_start_prop->setValue("notADate"); TS_ASSERT_THROWS(runInfo.startTime(), std::runtime_error); @@ -149,26 +143,22 @@ public: const std::string run_end("2013-12-19T13:38:00"); auto run_end_prop = new PropertyWithValue<std::string>("run_end", run_end); runInfo.addProperty(run_end_prop); - TS_ASSERT_EQUALS(runInfo.endTime(), - DateAndTimeHelpers::createFromISO8601(run_end)); + TS_ASSERT_EQUALS(runInfo.endTime(), DateAndTime(run_end)); // Add end_time and see that get picked up in preference const std::string end_time("2013-12-19T13:40:00"); auto end_time_prop = new PropertyWithValue<std::string>("end_time", end_time); runInfo.addProperty(end_time_prop); - TS_ASSERT_EQUALS(runInfo.endTime(), - DateAndTimeHelpers::createFromISO8601(end_time)); + TS_ASSERT_EQUALS(runInfo.endTime(), DateAndTime(end_time)); // Set run_end back to valid value and make end_time contain nonsense run_end_prop->setValue(run_end); end_time_prop->setValue("__"); - TS_ASSERT_EQUALS(runInfo.endTime(), - DateAndTimeHelpers::createFromISO8601(run_end)); + TS_ASSERT_EQUALS(runInfo.endTime(), DateAndTime(run_end)); // Now make end_time a completely different property type runInfo.removeProperty("end_time"); runInfo.addProperty(new PropertyWithValue<double>("end_time", 3.33)); - TS_ASSERT_EQUALS(runInfo.endTime(), - DateAndTimeHelpers::createFromISO8601(run_end)); + TS_ASSERT_EQUALS(runInfo.endTime(), DateAndTime(run_end)); // Now make run_end something invalid run_end_prop->setValue("notADate"); TS_ASSERT_THROWS(runInfo.endTime(), std::runtime_error); diff --git a/Framework/API/test/MatrixWorkspaceTest.h b/Framework/API/test/MatrixWorkspaceTest.h index 063ec2b844c..e0e0abfdd14 100644 --- a/Framework/API/test/MatrixWorkspaceTest.h +++ b/Framework/API/test/MatrixWorkspaceTest.h @@ -9,21 +9,20 @@ #include "MantidAPI/SpectrumDetectorMapping.h" #include "MantidAPI/SpectrumInfo.h" #include "MantidAPI/WorkspaceFactory.h" -#include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/ComponentInfo.h" #include "MantidGeometry/Instrument/Detector.h" #include "MantidGeometry/Instrument/DetectorInfo.h" -#include "MantidIndexing/IndexInfo.h" -#include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidGeometry/Instrument.h" +#include "MantidKernel/make_cow.h" #include "MantidKernel/TimeSeriesProperty.h" #include "MantidKernel/VMD.h" -#include "MantidKernel/make_cow.h" -#include "MantidTestHelpers/ComponentCreationHelper.h" +#include "MantidTypes/SpectrumDefinition.h" +#include "MantidIndexing/IndexInfo.h" #include "MantidTestHelpers/FakeObjects.h" #include "MantidTestHelpers/InstrumentCreationHelper.h" +#include "MantidTestHelpers/ComponentCreationHelper.h" #include "MantidTestHelpers/NexusTestHelper.h" #include "MantidTestHelpers/ParallelRunner.h" -#include "MantidTypes/SpectrumDefinition.h" #include "PropertyManagerHelper.h" #include <cxxtest/TestSuite.h> @@ -42,7 +41,7 @@ using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::Geometry; using Mantid::Indexing::IndexInfo; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; // Declare into the factory. DECLARE_WORKSPACE(WorkspaceTester) @@ -100,7 +99,7 @@ void run_legacy_setting_spectrum_numbers_with_MPI( } } } -} // namespace +} class MatrixWorkspaceTest : public CxxTest::TestSuite { public: @@ -1013,8 +1012,7 @@ public: void test_getFirstPulseTime_getLastPulseTime() { WorkspaceTester ws; auto proton_charge = new TimeSeriesProperty<double>("proton_charge"); - DateAndTime startTime = - DateAndTimeHelpers::createFromISO8601("2013-04-21T10:40:00"); + DateAndTime startTime("2013-04-21T10:40:00"); proton_charge->addValue(startTime, 1.0E-7); proton_charge->addValue(startTime + 1.0, 2.0E-7); proton_charge->addValue(startTime + 2.0, 3.0E-7); @@ -1028,8 +1026,7 @@ public: void test_getFirstPulseTime_getLastPulseTime_SNS1990bug() { WorkspaceTester ws; auto proton_charge = new TimeSeriesProperty<double>("proton_charge"); - DateAndTime startTime = - DateAndTimeHelpers::createFromISO8601("1990-12-31T23:59:00"); + DateAndTime startTime("1990-12-31T23:59:00"); proton_charge->addValue(startTime, 1.0E-7); proton_charge->addValue(startTime + 1.0, 2.0E-7); ws.mutableRun().addLogData(proton_charge); @@ -1041,9 +1038,8 @@ public: for (int i = 2; i < 62; ++i) { proton_charge->addValue(startTime + static_cast<double>(i), 1.0E-7); } - TS_ASSERT_EQUALS( - ws.getFirstPulseTime(), - DateAndTimeHelpers::createFromISO8601("1991-01-01T00:00:00")); + TS_ASSERT_EQUALS(ws.getFirstPulseTime(), + DateAndTime("1991-01-01T00:00:00")); } void @@ -1536,8 +1532,8 @@ public: } /** - * Test declaring an input workspace and retrieving as const_sptr or sptr - */ + * Test declaring an input workspace and retrieving as const_sptr or sptr + */ void testGetProperty_const_sptr() { const std::string wsName = "InputWorkspace"; MatrixWorkspace_sptr wsInput = boost::make_shared<WorkspaceTester>(); @@ -1592,9 +1588,8 @@ public: ws.setSharedDx(workspaceIndexWithDx[2], dxSpec2); // Assert - auto compareValue = [&values](double data, size_t index) { - return data == values[index]; - }; + auto compareValue = + [&values](double data, size_t index) { return data == values[index]; }; for (auto &index : workspaceIndexWithDx) { TSM_ASSERT("Should have x resolution values", ws.hasDx(index)); TSM_ASSERT_EQUALS("Should have a length of 3", ws.dataDx(index).size(), diff --git a/Framework/API/test/WorkspaceHistoryIOTest.h b/Framework/API/test/WorkspaceHistoryIOTest.h index a06d58d7946..3df00e12e13 100644 --- a/Framework/API/test/WorkspaceHistoryIOTest.h +++ b/Framework/API/test/WorkspaceHistoryIOTest.h @@ -1,20 +1,19 @@ #ifndef WORKSPACEHISTORYIOTEST_H_ #define WORKSPACEHISTORYIOTEST_H_ +#include <cxxtest/TestSuite.h> +#include "MantidAPI/WorkspaceHistory.h" +#include "MantidAPI/AlgorithmHistory.h" #include "MantidAPI/Algorithm.h" #include "MantidAPI/AlgorithmFactory.h" -#include "MantidAPI/AlgorithmHistory.h" #include "MantidAPI/FileFinder.h" -#include "MantidAPI/WorkspaceHistory.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/Property.h" #include "MantidTestHelpers/NexusTestHelper.h" #include "Poco/File.h" -#include <cxxtest/TestSuite.h> using namespace Mantid::API; using namespace Mantid::Kernel; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; class WorkspaceHistoryIOTest : public CxxTest::TestSuite { private: @@ -207,7 +206,7 @@ public: WorkspaceHistory testHistory; for (int i = 1; i < 5; i++) { AlgorithmHistory algHist("History" + boost::lexical_cast<std::string>(i), - 1, DateAndTimeHelpers::defaultTime(), -1.0, i); + 1, DateAndTime::defaultTime(), -1.0, i); testHistory.addHistory(boost::make_shared<AlgorithmHistory>(algHist)); } @@ -243,10 +242,10 @@ public: void test_SaveNexus_NestedHistory() { WorkspaceHistory testHistory; - AlgorithmHistory algHist("ParentHistory", 1, - DateAndTimeHelpers::defaultTime(), -1.0, 0); - AlgorithmHistory childHist("ChildHistory", 1, - DateAndTimeHelpers::defaultTime(), -1.0, 1); + AlgorithmHistory algHist("ParentHistory", 1, DateAndTime::defaultTime(), + -1.0, 0); + AlgorithmHistory childHist("ChildHistory", 1, DateAndTime::defaultTime(), + -1.0, 1); algHist.addChildHistory(boost::make_shared<AlgorithmHistory>(childHist)); testHistory.addHistory(boost::make_shared<AlgorithmHistory>(algHist)); @@ -324,8 +323,7 @@ public: TS_ASSERT_EQUALS("LoadRaw", history->name()); TS_ASSERT_EQUALS(3, history->version()); - TS_ASSERT_EQUALS(Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2009-10-09T16:56:54"), + TS_ASSERT_EQUALS(DateAndTime("2009-10-09T16:56:54"), history->executionDate()); TS_ASSERT_EQUALS(2.3, history->executionDuration()); loadhandle->close(); diff --git a/Framework/API/test/WorkspaceHistoryTest.h b/Framework/API/test/WorkspaceHistoryTest.h index 36066b77165..79470ca6d26 100644 --- a/Framework/API/test/WorkspaceHistoryTest.h +++ b/Framework/API/test/WorkspaceHistoryTest.h @@ -1,16 +1,15 @@ #ifndef WORKSPACEHISTORYTEST_H_ #define WORKSPACEHISTORYTEST_H_ +#include <cxxtest/TestSuite.h> +#include "MantidAPI/WorkspaceHistory.h" +#include "MantidAPI/AlgorithmHistory.h" #include "MantidAPI/Algorithm.h" #include "MantidAPI/AlgorithmFactory.h" -#include "MantidAPI/AlgorithmHistory.h" #include "MantidAPI/FileFinder.h" -#include "MantidAPI/WorkspaceHistory.h" #include "MantidKernel/Property.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidTestHelpers/NexusTestHelper.h" #include "Poco/File.h" -#include <cxxtest/TestSuite.h> using namespace Mantid::API; using namespace Mantid::Kernel; @@ -101,10 +100,10 @@ public: simplesum2.execute(); WorkspaceHistory history; - AlgorithmHistory alg1( - &simplesum, Mantid::Types::DateAndTimeHelpers::defaultTime(), 1.0, 0); - AlgorithmHistory alg2( - &simplesum2, Mantid::Types::DateAndTimeHelpers::defaultTime(), 1.0, 1); + AlgorithmHistory alg1(&simplesum, + Mantid::Types::Core::DateAndTime::defaultTime(), 1.0, 0); + AlgorithmHistory alg2(&simplesum2, + Mantid::Types::Core::DateAndTime::defaultTime(), 1.0, 1); history.addHistory(boost::make_shared<AlgorithmHistory>(alg1)); history.addHistory(boost::make_shared<AlgorithmHistory>(alg2)); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/AddSampleLog.h b/Framework/Algorithms/inc/MantidAlgorithms/AddSampleLog.h index 9bd46a492a6..d9bbd403543 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/AddSampleLog.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/AddSampleLog.h @@ -85,7 +85,7 @@ private: bool value_is_int); /// get run start time - Mantid::Types::DateAndTime getRunStart(API::Run &run_obj); + Types::Core::DateAndTime getRunStart(API::Run &run_obj); /// get value vector of the integer TimeSeriesProperty entries std::vector<int> getIntValues(API::MatrixWorkspace_const_sptr dataws, @@ -96,7 +96,7 @@ private: int workspace_index); /// get the vector of times of the TimeSeriesProperty entries - std::vector<Mantid::Types::DateAndTime> + std::vector<Types::Core::DateAndTime> getTimes(API::MatrixWorkspace_const_sptr dataws, int workspace_index, bool is_epoch, bool is_second, API::Run &run_obj); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalculateCountRate.h b/Framework/Algorithms/inc/MantidAlgorithms/CalculateCountRate.h index 135d919fe5c..0c6a6270046 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CalculateCountRate.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CalculateCountRate.h @@ -79,7 +79,7 @@ protected: // for testing, actually private /// spurion search ranges (TOF or other units requested) double m_XRangeMin{0}, m_XRangeMax{0}; /// experiment time ranges: - Mantid::Types::DateAndTime m_TRangeMin{0}, m_TRangeMax{0}; + Types::Core::DateAndTime m_TRangeMin{0}, m_TRangeMax{0}; /// temporary workspace used to keep intermediate results DataObjects::EventWorkspace_sptr m_workingWS; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ChangeTimeZero.h b/Framework/Algorithms/inc/MantidAlgorithms/ChangeTimeZero.h index 518cf8225d5..db64e46e249 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ChangeTimeZero.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ChangeTimeZero.h @@ -42,7 +42,7 @@ private: void shiftTimeOfLogs(Mantid::API::MatrixWorkspace_sptr ws, double timeShift, double startProgress, double stopProgress); /// Get the date and time of the first good frame of a workspace - Mantid::Types::DateAndTime + Mantid::Types::Core::DateAndTime getStartTimeFromWorkspace(Mantid::API::MatrixWorkspace_sptr ws) const; /// Can the string be transformed to double bool checkForDouble(std::string val) const; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ExportTimeSeriesLog.h b/Framework/Algorithms/inc/MantidAlgorithms/ExportTimeSeriesLog.h index 601f656c918..e45369ac992 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ExportTimeSeriesLog.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ExportTimeSeriesLog.h @@ -58,16 +58,16 @@ private: std::vector<int64_t> mSETimes; std::vector<double> mSEValues; - Mantid::Types::DateAndTime mRunStartTime; - Mantid::Types::DateAndTime mFilterT0; - Mantid::Types::DateAndTime mFilterTf; + Types::Core::DateAndTime mRunStartTime; + Types::Core::DateAndTime mFilterT0; + Types::Core::DateAndTime mFilterTf; void init() override; void exec() override; bool - calculateTimeSeriesRangeByTime(std::vector<Mantid::Types::DateAndTime> &vec_times, + calculateTimeSeriesRangeByTime(std::vector<Types::Core::DateAndTime> &vec_times, const double &rel_start_time, size_t &i_start, const double &rel_stop_time, size_t &i_stop, const double &time_factor); @@ -79,11 +79,11 @@ private: void setupEventWorkspace(const size_t &start_index, const size_t &stop_index, int numentries, - std::vector<Mantid::Types::DateAndTime> ×, + std::vector<Types::Core::DateAndTime> ×, std::vector<double> values, const bool &epochtime); void setupWorkspace2D(const size_t &start_index, const size_t &stop_index, - int numentries, std::vector<Mantid::Types::DateAndTime> ×, + int numentries, std::vector<Types::Core::DateAndTime> ×, std::vector<double> values, const bool &epochtime, const double &timeunitfactor, size_t nspec); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FilterByTime2.h b/Framework/Algorithms/inc/MantidAlgorithms/FilterByTime2.h index 1def11c452d..241079a3abd 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FilterByTime2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FilterByTime2.h @@ -3,7 +3,7 @@ #include "MantidKernel/System.h" #include "MantidAPI/Algorithm.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" namespace Mantid { namespace Algorithms { diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FilterEvents.h b/Framework/Algorithms/inc/MantidAlgorithms/FilterEvents.h index 3c330436813..7ff09523013 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FilterEvents.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FilterEvents.h @@ -158,12 +158,12 @@ private: template <typename TYPE> void splitTimeSeriesProperty(Kernel::TimeSeriesProperty<TYPE> *tsp, - std::vector<Mantid::Types::DateAndTime> &split_datetime_vec, + std::vector<Types::Core::DateAndTime> &split_datetime_vec, const int max_target_index); void splitDoubleTimeSeriesLogs( const std::vector<Kernel::TimeSeriesProperty<double> *> &dbl_tsp_vector, - std::vector<Mantid::Types::DateAndTime> &split_datetime_vec, + std::vector<Types::Core::DateAndTime> &split_datetime_vec, const int max_target_index); void groupOutputWorkspace(); @@ -233,9 +233,9 @@ private: // Flag to have relative time in splitters workspace bool m_isSplittersRelativeTime; // Starting time for starting time of event filters - Mantid::Types::DateAndTime m_filterStartTime; + Types::Core::DateAndTime m_filterStartTime; // EventWorkspace (aka. run)'s starting time - Mantid::Types::DateAndTime m_runStartTime; + Types::Core::DateAndTime m_runStartTime; }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GenerateEventsFilter.h b/Framework/Algorithms/inc/MantidAlgorithms/GenerateEventsFilter.h index e0f13dfb583..7baace79966 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GenerateEventsFilter.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GenerateEventsFilter.h @@ -1,12 +1,12 @@ #ifndef MANTID_ALGORITHMS_GENERATEEVENTSFILTER_H_ #define MANTID_ALGORITHMS_GENERATEEVENTSFILTER_H_ +#include "MantidKernel/System.h" #include "MantidAPI/Algorithm.h" -#include "MantidAPI/ITableWorkspace_fwd.h" #include "MantidDataObjects/EventWorkspace.h" -#include "MantidDataObjects/SplittersWorkspace.h" -#include "MantidKernel/System.h" #include "MantidKernel/TimeSeriesProperty.h" +#include "MantidDataObjects/SplittersWorkspace.h" +#include "MantidAPI/ITableWorkspace_fwd.h" namespace Mantid { namespace Algorithms { @@ -101,55 +101,50 @@ private: void makeFilterBySingleValue(double min, double max, double TimeTolerance, bool centre, bool filterIncrease, bool filterDecrease, - Mantid::Types::DateAndTime startTime, - Mantid::Types::DateAndTime stopTime, - int wsindex); + Types::Core::DateAndTime startTime, + Types::Core::DateAndTime stopTime, int wsindex); /// Make multiple-log-value filters in serial void makeMultipleFiltersByValues(std::map<size_t, int> indexwsindexmap, std::vector<double> logvalueranges, bool centre, bool filterIncrease, bool filterDecrease, - Mantid::Types::DateAndTime startTime, - Mantid::Types::DateAndTime stopTime); + Types::Core::DateAndTime startTime, + Types::Core::DateAndTime stopTime); /// Make multiple-log-value filters in serial in parallel void makeMultipleFiltersByValuesParallel( std::map<size_t, int> indexwsindexmap, std::vector<double> logvalueranges, bool centre, bool filterIncrease, bool filterDecrease, - Mantid::Types::DateAndTime startTime, - Mantid::Types::DateAndTime stopTime); + Types::Core::DateAndTime startTime, Types::Core::DateAndTime stopTime); /// Generate event splitters for partial sample log (serial) void makeMultipleFiltersByValuesPartialLog( - int istart, int iend, - std::vector<Mantid::Types::DateAndTime> &vecSplitTime, + int istart, int iend, std::vector<Types::Core::DateAndTime> &vecSplitTime, std::vector<int> &vecSplitGroup, std::map<size_t, int> indexwsindexmap, - const std::vector<double> &logvalueranges, - Mantid::Types::time_duration tol, bool filterIncrease, - bool filterDecrease, Mantid::Types::DateAndTime startTime, - Mantid::Types::DateAndTime stopTime); + const std::vector<double> &logvalueranges, Types::Core::time_duration tol, + bool filterIncrease, bool filterDecrease, Types::Core::DateAndTime startTime, + Types::Core::DateAndTime stopTime); /// Generate event filters for integer sample log void processIntegerValueFilter(int minvalue, int maxvalue, bool filterIncrease, bool filterDecrease, - Mantid::Types::DateAndTime runend); + Types::Core::DateAndTime runend); /// Search a value in a sorted vector size_t searchValue(const std::vector<double> &sorteddata, double value); /// Add a splitter - void addNewTimeFilterSplitter(Mantid::Types::DateAndTime starttime, - Mantid::Types::DateAndTime stoptime, - int wsindex, std::string info); + void addNewTimeFilterSplitter(Types::Core::DateAndTime starttime, + Types::Core::DateAndTime stoptime, int wsindex, + std::string info); /// Create a splitter and add to the vector of time splitters - Mantid::Types::DateAndTime - makeSplitterInVector(std::vector<Mantid::Types::DateAndTime> &vecSplitTime, + Types::Core::DateAndTime + makeSplitterInVector(std::vector<Types::Core::DateAndTime> &vecSplitTime, std::vector<int> &vecGroupIndex, - Mantid::Types::DateAndTime start, - Mantid::Types::DateAndTime stop, int group, - int64_t tol_ns, Mantid::Types::DateAndTime lasttime); + Types::Core::DateAndTime start, Types::Core::DateAndTime stop, + int group, int64_t tol_ns, Types::Core::DateAndTime lasttime); /// Generate a matrix workspace containing splitters void generateSplittersInMatrixWorkspace(); @@ -161,19 +156,18 @@ private: void generateSplittersInSplitterWS(); /// Identify the a sample log entry is within intended value and time region - bool identifyLogEntry(const int &index, - const Mantid::Types::DateAndTime &currT, + bool identifyLogEntry(const int &index, const Types::Core::DateAndTime &currT, const bool &lastgood, const double &minvalue, const double &maxvalue, - const Mantid::Types::DateAndTime &startT, - const Mantid::Types::DateAndTime &stopT, + const Types::Core::DateAndTime &startT, + const Types::Core::DateAndTime &stopT, const bool &filterIncrease, const bool &filterDecrease); /// Determine the chaning direction of log value int determineChangingDirection(int startindex); /// Find the end of the run - Mantid::Types::DateAndTime findRunEnd(); + Types::Core::DateAndTime findRunEnd(); DataObjects::EventWorkspace_const_sptr m_dataWS; @@ -184,11 +178,11 @@ private: API::ITableWorkspace_sptr m_filterInfoWS; - Mantid::Types::DateAndTime m_startTime; - Mantid::Types::DateAndTime m_stopTime; + Types::Core::DateAndTime m_startTime; + Types::Core::DateAndTime m_stopTime; /// Run end time - Mantid::Types::DateAndTime m_runEndTime; + Types::Core::DateAndTime m_runEndTime; double m_timeUnitConvertFactorToNS; @@ -204,13 +198,13 @@ private: /// SplitterType Kernel::TimeSplitterType m_splitters; /// Vector as date and time - std::vector<Mantid::Types::DateAndTime> m_vecSplitterTime; + std::vector<Types::Core::DateAndTime> m_vecSplitterTime; std::vector<int> m_vecSplitterGroup; /// Processing algorithm type bool m_useParallel; - std::vector<std::vector<Mantid::Types::DateAndTime>> m_vecSplitterTimeSet; + std::vector<std::vector<Types::Core::DateAndTime>> m_vecSplitterTimeSet; std::vector<std::vector<int>> m_vecGroupIndexSet; }; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GetTimeSeriesLogInformation.h b/Framework/Algorithms/inc/MantidAlgorithms/GetTimeSeriesLogInformation.h index 5814b1ed3db..4213a8e7094 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GetTimeSeriesLogInformation.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GetTimeSeriesLogInformation.h @@ -57,19 +57,19 @@ public: private: API::MatrixWorkspace_sptr m_dataWS; - Mantid::Types::DateAndTime mRunStartTime; - Mantid::Types::DateAndTime mFilterT0; - Mantid::Types::DateAndTime mFilterTf; + Types::Core::DateAndTime mRunStartTime; + Types::Core::DateAndTime mFilterT0; + Types::Core::DateAndTime mFilterTf; std::map<std::string, std::size_t> m_intInfoMap; std::map<std::string, double> m_dblInfoMap; Kernel::TimeSeriesProperty<double> *m_log; - std::vector<Mantid::Types::DateAndTime> m_timeVec; + std::vector<Types::Core::DateAndTime> m_timeVec; std::vector<double> m_valueVec; - Mantid::Types::DateAndTime m_starttime; - Mantid::Types::DateAndTime m_endtime; + Types::Core::DateAndTime m_starttime; + Types::Core::DateAndTime m_endtime; bool m_ignoreNegativeTime; @@ -85,24 +85,24 @@ private: /// Calcualte the distribution of delta T in time stamps DataObjects::Workspace2D_sptr - calDistributions(std::vector<Mantid::Types::DateAndTime> timevec, double stepsize); + calDistributions(std::vector<Types::Core::DateAndTime> timevec, double stepsize); void exportLog(API::MatrixWorkspace_sptr ws, - std::vector<Mantid::Types::DateAndTime> abstimevec, double dts); + std::vector<Types::Core::DateAndTime> abstimevec, double dts); void setupEventWorkspace(int numentries, - std::vector<Mantid::Types::DateAndTime> ×, + std::vector<Types::Core::DateAndTime> ×, std::vector<double> values); - void setupWorkspace2D(int numentries, std::vector<Mantid::Types::DateAndTime> ×, + void setupWorkspace2D(int numentries, std::vector<Types::Core::DateAndTime> ×, std::vector<double> values); void execQuickStatistics(); void exportErrorLog(API::MatrixWorkspace_sptr ws, - std::vector<Mantid::Types::DateAndTime> abstimevec, double dts); + std::vector<Types::Core::DateAndTime> abstimevec, double dts); - void checkLogValueChanging(std::vector<Mantid::Types::DateAndTime> timevec, + void checkLogValueChanging(std::vector<Types::Core::DateAndTime> timevec, std::vector<double> values, double delta); void checkLogBasicInforamtion(); @@ -110,9 +110,9 @@ private: /// Generate statistic information table workspace DataObjects::TableWorkspace_sptr generateStatisticTable(); - Mantid::Types::DateAndTime getAbsoluteTime(double abstimens); + Types::Core::DateAndTime getAbsoluteTime(double abstimens); - Mantid::Types::DateAndTime calculateRelativeTime(double deltatime); + Types::Core::DateAndTime calculateRelativeTime(double deltatime); }; } // namespace Algorithms diff --git a/Framework/Algorithms/src/AddLogDerivative.cpp b/Framework/Algorithms/src/AddLogDerivative.cpp index 6827ef76f2b..798ea61d4bf 100644 --- a/Framework/Algorithms/src/AddLogDerivative.cpp +++ b/Framework/Algorithms/src/AddLogDerivative.cpp @@ -1,15 +1,15 @@ #include "MantidAlgorithms/AddLogDerivative.h" -#include "MantidAPI/MatrixWorkspace.h" -#include "MantidAPI/Run.h" -#include "MantidKernel/BoundedValidator.h" -#include "MantidKernel/MandatoryValidator.h" #include "MantidKernel/Strings.h" #include "MantidKernel/System.h" #include "MantidKernel/TimeSeriesProperty.h" +#include "MantidAPI/MatrixWorkspace.h" +#include "MantidKernel/MandatoryValidator.h" +#include "MantidKernel/BoundedValidator.h" +#include "MantidAPI/Run.h" using namespace Mantid::Kernel; using namespace Mantid::API; -using Mantid::Types::DateAndTime; +using Mantid::Types::Core::DateAndTime; namespace Mantid { namespace Algorithms { @@ -33,10 +33,9 @@ void AddLogDerivative::init() { declareProperty("Derivative", 1, boost::make_shared<BoundedValidator<int>>(1, 10), "How many derivatives to perform. Default 1."); - declareProperty("NewLogName", "", - "Name of the newly created log. If not " - "specified, the string '_derivativeN' will " - "be appended to the original name"); + declareProperty("NewLogName", "", "Name of the newly created log. If not " + "specified, the string '_derivativeN' will " + "be appended to the original name"); } //---------------------------------------------------------------------------------------------- @@ -130,11 +129,10 @@ void AddLogDerivative::exec() { TimeSeriesProperty<double> *tsp = dynamic_cast<TimeSeriesProperty<double> *>(prop); if (!tsp) - throw std::invalid_argument("Log " + LogName + - " is not a numerical series " - "(TimeSeriesProperty<double>" - ") so we can't perform its " - "derivative."); + throw std::invalid_argument("Log " + LogName + " is not a numerical series " + "(TimeSeriesProperty<double>" + ") so we can't perform its " + "derivative."); Progress progress(this, 0.0, 1.0, Derivative); @@ -147,5 +145,5 @@ void AddLogDerivative::exec() { g_log.notice() << "Added log named " << NewLogName << '\n'; } -} // namespace Algorithms } // namespace Mantid +} // namespace Algorithms diff --git a/Framework/Algorithms/src/AddNote.cpp b/Framework/Algorithms/src/AddNote.cpp index 7e55b73f79f..70c0b44b118 100644 --- a/Framework/Algorithms/src/AddNote.cpp +++ b/Framework/Algorithms/src/AddNote.cpp @@ -10,6 +10,7 @@ namespace Algorithms { using namespace API; using namespace Kernel; +using Types::Core::DateAndTime; namespace { /** @@ -36,7 +37,7 @@ void createOrUpdateValue(API::Run &run, const std::string &name, } timeSeries->addValue(time, value); } -} // namespace +} // Register the algorithm into the AlgorithmFactory DECLARE_ALGORITHM(AddNote) @@ -130,7 +131,7 @@ void AddNote::createOrUpdate(API::Run &run, const std::string &name) { std::string time = getProperty("Time"); if (time.empty()) { namespace pt = boost::posix_time; - auto dateTimeObj = Types::DateAndTime(pt::second_clock::local_time()); + auto dateTimeObj = DateAndTime(pt::second_clock::local_time()); time = dateTimeObj.toISO8601String(); } std::string value = getProperty("Value"); diff --git a/Framework/Algorithms/src/AddSampleLog.cpp b/Framework/Algorithms/src/AddSampleLog.cpp index 95af49652df..62580bed243 100644 --- a/Framework/Algorithms/src/AddSampleLog.cpp +++ b/Framework/Algorithms/src/AddSampleLog.cpp @@ -1,14 +1,14 @@ #include "MantidAlgorithms/AddSampleLog.h" #include "MantidAPI/ExperimentInfo.h" -#include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/Run.h" #include "MantidAPI/Workspace.h" +#include "MantidAPI/MatrixWorkspace.h" #include "MantidKernel/Exception.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/MandatoryValidator.h" -#include "MantidKernel/PropertyWithValue.h" #include "MantidKernel/Strings.h" #include "MantidKernel/TimeSeriesProperty.h" +#include "MantidKernel/PropertyWithValue.h" #include <string> @@ -21,7 +21,7 @@ static const std::string autoTypeOption = "AutoDetect"; static const std::string stringLogOption = "String"; static const std::string numberLogOption = "Number"; static const std::string numberSeriesLogOption = "Number Series"; -} // namespace +} namespace Mantid { namespace Algorithms { @@ -31,6 +31,7 @@ DECLARE_ALGORITHM(AddSampleLog) using namespace Kernel; using namespace API; +using Types::Core::DateAndTime; void AddSampleLog::init() { declareProperty(Kernel::make_unique<WorkspaceProperty<Workspace>>( @@ -77,10 +78,9 @@ void AddSampleLog::init() { declareProperty("TimeUnit", "Second", boost::make_shared<Kernel::StringListValidator>(time_units), "The unit of the time of the input workspace"); - declareProperty("RelativeTime", true, - "If specified as True, then then the " - "time stamps are relative to the run " - "start time of the target workspace."); + declareProperty("RelativeTime", true, "If specified as True, then then the " + "time stamps are relative to the run " + "start time of the target workspace."); } /** @@ -261,7 +261,7 @@ void AddSampleLog::addTimeSeriesProperty(Run &run_obj, // create workspace // get run start - Mantid::Types::DateAndTime startTime = getRunStart(run_obj); + Types::Core::DateAndTime startTime = getRunStart(run_obj); // initialze the TimeSeriesProperty and add unit if (is_int_series) { @@ -319,7 +319,7 @@ void AddSampleLog::setTimeSeriesData(Run &run_obj, bool is_second = timeunit == "Second"; // convert the data in workspace to time series property value - std::vector<Types::DateAndTime> time_vec = + std::vector<DateAndTime> time_vec = getTimes(data_ws, ws_index, epochtime, is_second, run_obj); if (value_is_int) { // integer property @@ -349,7 +349,7 @@ void AddSampleLog::setTimeSeriesData(Run &run_obj, * @param run_obj * @return */ -std::vector<Mantid::Types::DateAndTime> +std::vector<Types::Core::DateAndTime> AddSampleLog::getTimes(API::MatrixWorkspace_const_sptr dataws, int workspace_index, bool is_epoch, bool is_second, API::Run &run_obj) { @@ -357,19 +357,19 @@ AddSampleLog::getTimes(API::MatrixWorkspace_const_sptr dataws, int64_t timeshift(0); if (!is_epoch) { // get the run start time - Mantid::Types::DateAndTime run_start_time = getRunStart(run_obj); + Types::Core::DateAndTime run_start_time = getRunStart(run_obj); timeshift = run_start_time.totalNanoseconds(); } // set up the time vector - std::vector<Mantid::Types::DateAndTime> timevec; + std::vector<Types::Core::DateAndTime> timevec; size_t vecsize = dataws->readX(workspace_index).size(); for (size_t i = 0; i < vecsize; ++i) { double timedbl = dataws->readX(workspace_index)[i]; if (is_second) timedbl *= 1.E9; int64_t entry_i64 = static_cast<int64_t>(timedbl); - Mantid::Types::DateAndTime entry(timeshift + entry_i64); + Types::Core::DateAndTime entry(timeshift + entry_i64); timevec.push_back(entry); } @@ -381,10 +381,10 @@ AddSampleLog::getTimes(API::MatrixWorkspace_const_sptr dataws, * @param run_obj * @return */ -Mantid::Types::DateAndTime AddSampleLog::getRunStart(API::Run &run_obj) { +Types::Core::DateAndTime AddSampleLog::getRunStart(API::Run &run_obj) { // TODO/ISSUE/NOW - data ws should be the target workspace with run_start or // proton_charge property! - Mantid::Types::DateAndTime runstart(0); + Types::Core::DateAndTime runstart(0); try { runstart = run_obj.startTime(); } catch (std::runtime_error &) { diff --git a/Framework/Algorithms/src/CalculateCountRate.cpp b/Framework/Algorithms/src/CalculateCountRate.cpp index 129cf2f368f..f7367009e79 100644 --- a/Framework/Algorithms/src/CalculateCountRate.cpp +++ b/Framework/Algorithms/src/CalculateCountRate.cpp @@ -1,12 +1,12 @@ #include "MantidAlgorithms/CalculateCountRate.h" -#include "MantidKernel/BoundedValidator.h" -#include "MantidKernel/ListValidator.h" -#include "MantidKernel/MandatoryValidator.h" #include "MantidKernel/PropertyWithValue.h" +#include "MantidKernel/BoundedValidator.h" #include "MantidKernel/TimeSeriesProperty.h" +#include "MantidKernel/ListValidator.h" #include "MantidKernel/Unit.h" #include "MantidKernel/UnitFactory.h" +#include "MantidKernel/MandatoryValidator.h" #include "MantidKernel/make_unique.h" #include "MantidAPI/AlgorithmManager.h" @@ -18,8 +18,6 @@ #include "MantidDataObjects/Workspace2D.h" #include <numeric> -using Mantid::Types::TofEvent; - namespace Mantid { namespace Algorithms { @@ -186,14 +184,14 @@ void CalculateCountRate::exec() { } /** Process input workspace to calculate instrument counting rate as function of - *experiment time - *@param InputWorkspace :: shared pointer to the input workspace to process - *@param targLog :: pointer to time series property containing count rate - *log. - * Property should exist on input and will be modified - *with - * counting rate log on output. - */ +*experiment time +*@param InputWorkspace :: shared pointer to the input workspace to process +*@param targLog :: pointer to time series property containing count rate +*log. +* Property should exist on input and will be modified +*with +* counting rate log on output. +*/ void CalculateCountRate::calcRateLog( DataObjects::EventWorkspace_sptr &InputWorkspace, Kernel::TimeSeriesProperty<double> *const targLog) { @@ -265,21 +263,21 @@ void CalculateCountRate::calcRateLog( } // generate target log timing - std::vector<Mantid::Types::DateAndTime> times(m_numLogSteps); + std::vector<Types::Core::DateAndTime> times(m_numLogSteps); double dt = (dTRangeMax - dTRangeMin) / static_cast<double>(m_numLogSteps); auto t0 = m_TRangeMin.totalNanoseconds(); for (auto i = 0; i < m_numLogSteps; i++) { - times[i] = Mantid::Types::DateAndTime( - t0 + static_cast<int64_t>((0.5 + double(i)) * dt)); + times[i] = + Types::Core::DateAndTime(t0 + static_cast<int64_t>((0.5 + double(i)) * dt)); } // store calculated values within the target log. targLog->replaceValues(times, countRate); } /** histogram event list into visualization workspace - * @param el :: event list to rebin into visualization workspace - * @param spectraLocks :: pointer to the array of mutexes to lock modifyed - * visualization workspace spectra for a thread - */ +* @param el :: event list to rebin into visualization workspace +* @param spectraLocks :: pointer to the array of mutexes to lock modifyed +* visualization workspace spectra for a thread +*/ void CalculateCountRate::histogramEvents(const DataObjects::EventList &el, std::mutex *spectraLocks) { @@ -287,7 +285,7 @@ void CalculateCountRate::histogramEvents(const DataObjects::EventList &el, return; auto events = el.getEvents(); - for (const TofEvent &ev : events) { + for (const Types::Event::TofEvent &ev : events) { double pulsetime = static_cast<double>(ev.pulseTime().totalNanoseconds()); double tof = ev.tof(); if (pulsetime < m_visT0 || pulsetime >= m_visTmax) @@ -391,11 +389,11 @@ void CalculateCountRate::setOutLogParameters( } //--------------------------------------------------------------------- // find target log ranges and identify what normalization should be used - Mantid::Types::DateAndTime runTMin, runTMax; + Types::Core::DateAndTime runTMin, runTMax; InputWorkspace->getPulseTimeMinMax(runTMin, runTMax); // if (useLogAccuracy) { // extract log times located inside the run time - Mantid::Types::DateAndTime tLogMin, tLogMax; + Types::Core::DateAndTime tLogMin, tLogMax; if (m_useLogDerivative) { // derivative moves events to the bin centre, // but we need initial range auto pSource = @@ -480,7 +478,7 @@ void CalculateCountRate::setOutLogParameters( m_numLogSteps++; iTMax1 = iTMin + provDT * m_numLogSteps; } - m_TRangeMax = Mantid::Types::DateAndTime(iTMax1); + m_TRangeMax = Types::Core::DateAndTime(iTMax1); } } @@ -501,7 +499,7 @@ void CalculateCountRate::setOutLogParameters( *@return -- the input workspace cropped according to XMin-XMax ranges in units, * requested by the user * - */ +*/ void CalculateCountRate::setSourceWSandXRanges( DataObjects::EventWorkspace_sptr &InputWorkspace) { @@ -585,15 +583,15 @@ void CalculateCountRate::setSourceWSandXRanges( if (m_XRangeMin > m_XRangeMax) { throw std::invalid_argument(" Minimal spurion search data limit is bigger " "than the maximal limit. ( Min: " + - std::to_string(m_XRangeMin) + - "> Max: " + std::to_string(m_XRangeMax) + ")"); + std::to_string(m_XRangeMin) + "> Max: " + + std::to_string(m_XRangeMax) + ")"); } } /**Check if visualization workspace is necessary and initiate it if requested. - * Sets or clears up internal m_visWS pointer and "do-visualization workspace" - * option. - */ +* Sets or clears up internal m_visWS pointer and "do-visualization workspace" +* option. +*/ void CalculateCountRate::checkAndInitVisWorkspace() { std::string visWSName = getProperty("VisualizationWs"); if (visWSName.empty()) { @@ -686,13 +684,13 @@ void CalculateCountRate::checkAndInitVisWorkspace() { bool CalculateCountRate::buildVisWS() const { return m_doVis; } /** Helper function, mainly for testing - * @return true if count rate should be normalized and false - * otherwise */ +* @return true if count rate should be normalized and false +* otherwise */ bool CalculateCountRate::normalizeCountRate() const { return m_normalizeResult; } /** Helper function, mainly for testing - * @return true if log derivative is used instead of log itself */ +* @return true if log derivative is used instead of log itself */ bool CalculateCountRate::useLogDerivative() const { return m_useLogDerivative; } /** method to prepare normalization vector for the visualisation workspace using diff --git a/Framework/Algorithms/src/ChangeLogTime.cpp b/Framework/Algorithms/src/ChangeLogTime.cpp index f38b731ac34..64400d6797c 100644 --- a/Framework/Algorithms/src/ChangeLogTime.cpp +++ b/Framework/Algorithms/src/ChangeLogTime.cpp @@ -1,11 +1,9 @@ #include "MantidAlgorithms/ChangeLogTime.h" -#include "MantidAPI/Run.h" #include "MantidDataObjects/EventWorkspace.h" +#include "MantidAPI/Run.h" #include "MantidKernel/TimeSeriesProperty.h" #include <sstream> -using Mantid::Types::DateAndTime; - namespace Mantid { namespace Algorithms { @@ -18,6 +16,7 @@ using std::vector; using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::Kernel; +using Types::Core::DateAndTime; /// Algorithm's name for identification const string ChangeLogTime::name() const { return "ChangeLogTime"; } @@ -94,5 +93,5 @@ void ChangeLogTime::exec() { outputWS->mutableRun().addProperty(newlog, true); } -} // namespace Algorithms } // namespace Mantid +} // namespace Algorithms diff --git a/Framework/Algorithms/src/ChangeTimeZero.cpp b/Framework/Algorithms/src/ChangeTimeZero.cpp index 74e8cea8e54..2f1fc4d0fa8 100644 --- a/Framework/Algorithms/src/ChangeTimeZero.cpp +++ b/Framework/Algorithms/src/ChangeTimeZero.cpp @@ -1,22 +1,20 @@ #include "MantidAlgorithms/ChangeTimeZero.h" -#include "MantidAPI/IEventWorkspace.h" +#include "MantidAlgorithms/CloneWorkspace.h" +#include "MantidAlgorithms/ChangePulsetime.h" #include "MantidAPI/IMDIterator.h" +#include "MantidAPI/IEventWorkspace.h" #include "MantidAPI/Run.h" -#include "MantidAlgorithms/ChangePulsetime.h" -#include "MantidAlgorithms/CloneWorkspace.h" #include "MantidDataObjects/EventList.h" -#include "MantidKernel/ArrayProperty.h" -#include "MantidKernel/DateAndTimeHelpers.h" -#include "MantidKernel/DateTimeValidator.h" -#include "MantidKernel/PropertyWithValue.h" #include "MantidKernel/System.h" #include "MantidKernel/TimeSeriesProperty.h" +#include "MantidKernel/PropertyWithValue.h" +#include "MantidKernel/ArrayProperty.h" +#include "MantidKernel/DateAndTime.h" +#include "MantidKernel/DateTimeValidator.h" #include <boost/lexical_cast.hpp> #include <boost/shared_ptr.hpp> -using namespace Mantid::Types; - namespace Mantid { namespace Algorithms { @@ -25,6 +23,7 @@ DECLARE_ALGORITHM(ChangeTimeZero) using namespace Mantid::Kernel; using namespace Mantid::API; +using Types::Core::DateAndTime; using std::size_t; namespace { @@ -40,7 +39,7 @@ bool isTimeSeries(Mantid::Kernel::Property *prop) { } return isTimeSeries; } -} // namespace +} /** Initialize the algorithm's properties. */ @@ -135,8 +134,8 @@ double ChangeTimeZero::getTimeShift(API::MatrixWorkspace_sptr ws) const { // Check if we are dealing with an absolute time std::string timeOffset = getProperty("AbsoluteTimeOffset"); if (isAbsoluteTimeShift(timeOffset)) { - DateAndTime desiredTime = DateAndTimeHelpers::createFromISO8601(timeOffset); - DateAndTime originalTime = getStartTimeFromWorkspace(ws); + DateAndTime desiredTime(timeOffset); + DateAndTime originalTime(getStartTimeFromWorkspace(ws)); timeShift = DateAndTime::secondsFromDuration(desiredTime - originalTime); } else { timeShift = getProperty("RelativeTimeOffset"); @@ -198,7 +197,7 @@ void ChangeTimeZero::shiftTimeOfLogForStringProperty( // Parse the log entry and replace all ISO8601 strings with an adjusted value auto value = logEntry->value(); if (checkForDateTime(value)) { - DateAndTime dateTime = DateAndTimeHelpers::createFromISO8601(value); + DateAndTime dateTime(value); DateAndTime shiftedTime = dateTime + timeShift; logEntry->setValue(shiftedTime.toISO8601String()); } @@ -358,5 +357,5 @@ bool ChangeTimeZero::isAbsoluteTimeShift(const std::string &offset) const { return offset != m_defaultAbsoluteTimeShift && checkForDateTime(offset); } -} // namespace Algorithms } // namespace Mantid +} // namespace Algorithms diff --git a/Framework/Algorithms/src/CompareWorkspaces.cpp b/Framework/Algorithms/src/CompareWorkspaces.cpp index f438bf6b1d7..d03663a5bbd 100644 --- a/Framework/Algorithms/src/CompareWorkspaces.cpp +++ b/Framework/Algorithms/src/CompareWorkspaces.cpp @@ -23,7 +23,7 @@ using namespace Mantid::API; using namespace Mantid::Kernel; using namespace Mantid::DataObjects; using namespace Mantid::Geometry; -using Mantid::Types::TofEvent; +using Types::Event::TofEvent; // Register the algorithm into the AlgorithmFactory DECLARE_ALGORITHM(CompareWorkspaces) diff --git a/Framework/Algorithms/src/CorelliCrossCorrelate.cpp b/Framework/Algorithms/src/CorelliCrossCorrelate.cpp index 3686074ff9c..cdfe5659525 100644 --- a/Framework/Algorithms/src/CorelliCrossCorrelate.cpp +++ b/Framework/Algorithms/src/CorelliCrossCorrelate.cpp @@ -16,8 +16,6 @@ #include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/split.hpp> -using Mantid::Types::DateAndTime; - namespace Mantid { namespace Algorithms { @@ -25,6 +23,7 @@ using namespace Kernel; using namespace API; using namespace Geometry; using namespace DataObjects; +using Types::Core::DateAndTime; // Register the algorithm into the AlgorithmFactory DECLARE_ALGORITHM(CorelliCrossCorrelate) diff --git a/Framework/Algorithms/src/CreateSampleWorkspace.cpp b/Framework/Algorithms/src/CreateSampleWorkspace.cpp index cf5ca498cd5..f51024dd014 100644 --- a/Framework/Algorithms/src/CreateSampleWorkspace.cpp +++ b/Framework/Algorithms/src/CreateSampleWorkspace.cpp @@ -1,24 +1,23 @@ +#include "MantidHistogramData/LinearGenerator.h" #include "MantidAlgorithms/CreateSampleWorkspace.h" #include "MantidAPI/Axis.h" -#include "MantidAPI/FunctionDomain1D.h" #include "MantidAPI/FunctionFactory.h" +#include "MantidAPI/FunctionDomain1D.h" #include "MantidAPI/FunctionProperty.h" #include "MantidAPI/Run.h" #include "MantidAPI/WorkspaceFactory.h" -#include "MantidDataObjects/EventWorkspace.h" #include "MantidDataObjects/ScanningWorkspaceBuilder.h" #include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/EventWorkspace.h" #include "MantidDataObjects/WorkspaceCreation.h" -#include "MantidGeometry/Instrument/RectangularDetector.h" -#include "MantidGeometry/Instrument/ReferenceFrame.h" #include "MantidGeometry/Objects/ShapeFactory.h" -#include "MantidHistogramData/LinearGenerator.h" -#include "MantidIndexing/IndexInfo.h" +#include "MantidGeometry/Instrument/ReferenceFrame.h" +#include "MantidGeometry/Instrument/RectangularDetector.h" #include "MantidKernel/BoundedValidator.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/ListValidator.h" -#include "MantidKernel/MersenneTwister.h" #include "MantidKernel/UnitFactory.h" +#include "MantidKernel/MersenneTwister.h" +#include "MantidIndexing/IndexInfo.h" #include "MantidTypes/SpectrumDefinition.h" #include <cmath> @@ -26,8 +25,6 @@ #include <numeric> #include <stdexcept> -using namespace Mantid::Types; - namespace Mantid { namespace Algorithms { using namespace Kernel; @@ -38,6 +35,8 @@ using namespace HistogramData; using namespace Indexing; using Mantid::MantidVec; using Mantid::MantidVecPtr; +using Types::Core::DateAndTime; +using Types::Event::TofEvent; // Register the algorithm into the AlgorithmFactory DECLARE_ALGORITHM(CreateSampleWorkspace) @@ -202,8 +201,7 @@ void CreateSampleWorkspace::exec() { // down binWidth = xMax - xMin; g_log.warning() << "The bin width is so large that there is less than one " - "bin - it has been changed to " - << binWidth << '\n'; + "bin - it has been changed to " << binWidth << '\n'; } std::string functionString; @@ -262,8 +260,8 @@ void CreateSampleWorkspace::exec() { ws->setYUnit("Counts"); ws->setTitle("Test Workspace"); - auto run_start = DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00"); - auto run_end = DateAndTimeHelpers::createFromISO8601("2010-01-01T01:00:00"); + DateAndTime run_start("2010-01-01T00:00:00"); + DateAndTime run_end("2010-01-01T01:00:00"); Run &theRun = ws->mutableRun(); // belt and braces use both approaches for setting start and end times theRun.setStartAndEndTime(run_start, run_end); @@ -341,7 +339,7 @@ MatrixWorkspace_sptr CreateSampleWorkspace::createScanningWorkspace( timeRanges.push_back(double(i + 1)); } - builder.setTimeRanges(Mantid::Types::DateAndTime(0), timeRanges); + builder.setTimeRanges(Types::Core::DateAndTime(0), timeRanges); builder.setRelativeRotationsForScans(angles, inst->getSample()->getPos(), V3D(0, 1, 0)); @@ -361,7 +359,7 @@ EventWorkspace_sptr CreateSampleWorkspace::createEventWorkspace( int numPixels, int numBins, int numMonitors, int numEvents, double x0, double binDelta, Geometry::Instrument_sptr inst, const std::string &functionString, bool isRandom) { - auto run_start = DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00"); + DateAndTime run_start("2010-01-01T00:00:00"); std::vector<SpectrumDefinition> specDefs(numPixels + numMonitors); for (int wi = 0; wi < numMonitors + numPixels; wi++) @@ -561,9 +559,8 @@ Instrument_sptr CreateSampleWorkspace::createTestInstrumentRectangular( testInst->add(bank); // Set the bank along the z-axis of the instrument, between the detectors. - bank->setPos( - V3D(0.0, 0.0, - bankDistanceFromSample * (monitorNumber - monitorsStart + 0.5))); + bank->setPos(V3D(0.0, 0.0, bankDistanceFromSample * + (monitorNumber - monitorsStart + 0.5))); } // Define a source component diff --git a/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp b/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp index bc75e059129..6c4bbd10c44 100644 --- a/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp +++ b/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp @@ -1,4 +1,5 @@ #include "MantidAlgorithms/DiffractionEventCalibrateDetectors.h" +#include "MantidAlgorithms/GSLFunctions.h" #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/FileProperty.h" #include "MantidAPI/IFunction.h" @@ -6,7 +7,6 @@ #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/TableRow.h" #include "MantidAPI/TextAxis.h" -#include "MantidAlgorithms/GSLFunctions.h" #include "MantidDataObjects/EventList.h" #include "MantidDataObjects/EventWorkspace.h" #include "MantidDataObjects/GroupingWorkspace.h" @@ -14,15 +14,15 @@ #include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/Instrument/RectangularDetector.h" #include "MantidKernel/ArrayProperty.h" -#include "MantidKernel/BoundedValidator.h" #include "MantidKernel/CPUTimer.h" #include "MantidKernel/Exception.h" #include "MantidKernel/UnitFactory.h" +#include "MantidKernel/BoundedValidator.h" #include <Poco/File.h> #include <cmath> -#include <fstream> #include <numeric> +#include <fstream> #include <sstream> namespace Mantid { @@ -35,6 +35,7 @@ using namespace Kernel; using namespace API; using namespace Geometry; using namespace DataObjects; +using Types::Core::DateAndTime; /** * The gsl_costFunction is optimized by GSL simplex @@ -236,7 +237,7 @@ double DiffractionEventCalibrateDetectors::intensity( } /** Initialisation method - */ +*/ void DiffractionEventCalibrateDetectors::init() { declareProperty(make_unique<WorkspaceProperty<EventWorkspace>>( "InputWorkspace", "", Direction::Input, @@ -275,9 +276,9 @@ void DiffractionEventCalibrateDetectors::init() { } /** Executes the algorithm - * - * @throw runtime_error Thrown if algorithm cannot execute - */ +* +* @throw runtime_error Thrown if algorithm cannot execute +*/ void DiffractionEventCalibrateDetectors::exec() { // Try to retrieve optional properties const int maxIterations = getProperty("MaxIterations"); @@ -375,9 +376,7 @@ void DiffractionEventCalibrateDetectors::exec() { outfile << "# Base and up give directions of unit vectors for a local\n"; outfile << "# x,y coordinate system on the face of the detector.\n"; outfile << "#\n"; - outfile << "# " - << Mantid::Types::DateAndTime::getCurrentTime().toFormattedString( - "%c") + outfile << "# " << DateAndTime::getCurrentTime().toFormattedString("%c") << "\n"; outfile << "#\n"; outfile << "6 L1 T0_SHIFT\n"; @@ -586,5 +585,5 @@ void DiffractionEventCalibrateDetectors::exec() { outfile.close(); } -} // namespace Algorithms +} // namespace Algorithm } // namespace Mantid diff --git a/Framework/Algorithms/src/EQSANSTofStructure.cpp b/Framework/Algorithms/src/EQSANSTofStructure.cpp index 7496b53f2a6..4a988730276 100644 --- a/Framework/Algorithms/src/EQSANSTofStructure.cpp +++ b/Framework/Algorithms/src/EQSANSTofStructure.cpp @@ -2,19 +2,14 @@ #include "MantidAPI/Run.h" #include "MantidAPI/SpectrumInfo.h" #include "MantidAPI/WorkspaceUnitValidator.h" +#include "MantidDataObjects/Events.h" #include "MantidDataObjects/EventList.h" #include "MantidDataObjects/EventWorkspace.h" -#include "MantidDataObjects/Events.h" #include "MantidGeometry/Instrument.h" #include "MantidKernel/TimeSeriesProperty.h" #include <vector> -using namespace Mantid::Kernel; -using namespace Mantid::DataObjects; -using namespace Mantid::Geometry; -using Mantid::Types::TofEvent; - namespace Mantid { namespace Algorithms { @@ -23,7 +18,9 @@ DECLARE_ALGORITHM(EQSANSTofStructure) using namespace Kernel; using namespace API; +using namespace DataObjects; using namespace Geometry; +using Types::Event::TofEvent; EQSANSTofStructure::EQSANSTofStructure() : API::Algorithm(), frame_tof0(0.), flight_path_correction(false), @@ -37,15 +34,13 @@ void EQSANSTofStructure::init() { declareProperty("FlightPathCorrection", false, "If True, the neutron flight path correction will be applied", Kernel::Direction::Input); - declareProperty("LowTOFCut", 0.0, - "Width of the TOF margin to cut on the " - "lower end of the TOF distribution of each " - "frame", + declareProperty("LowTOFCut", 0.0, "Width of the TOF margin to cut on the " + "lower end of the TOF distribution of each " + "frame", Kernel::Direction::Input); - declareProperty("HighTOFCut", 0.0, - "Width of the TOF margin to cut on the " - "upper end of the TOF distribution of " - "each frame", + declareProperty("HighTOFCut", 0.0, "Width of the TOF margin to cut on the " + "upper end of the TOF distribution of " + "each frame", Kernel::Direction::Input); // Output parameters @@ -352,12 +347,12 @@ double EQSANSTofStructure::getTofOffset(EventWorkspace_const_sptr inputWS, bool passed = false; do { - frame_wl_1 = c_wl_1[0] = chopper_wl_1[0] + 3.9560346 * n_frame[0] * - tof_frame_width / - CHOPPER_LOCATION[0]; - frame_wl_2 = c_wl_2[0] = chopper_wl_2[0] + 3.9560346 * n_frame[0] * - tof_frame_width / - CHOPPER_LOCATION[0]; + frame_wl_1 = c_wl_1[0] = + chopper_wl_1[0] + + 3.9560346 * n_frame[0] * tof_frame_width / CHOPPER_LOCATION[0]; + frame_wl_2 = c_wl_2[0] = + chopper_wl_2[0] + + 3.9560346 * n_frame[0] * tof_frame_width / CHOPPER_LOCATION[0]; for (int i = 1; i < 4; i++) { n_frame[i] = n_frame[i - 1] - 1; @@ -365,12 +360,12 @@ double EQSANSTofStructure::getTofOffset(EventWorkspace_const_sptr inputWS, do { n_frame[i] += 1; - c_wl_1[i] = chopper_wl_1[i] + 3.9560346 * n_frame[i] * - tof_frame_width / - CHOPPER_LOCATION[i]; - c_wl_2[i] = chopper_wl_2[i] + 3.9560346 * n_frame[i] * - tof_frame_width / - CHOPPER_LOCATION[i]; + c_wl_1[i] = + chopper_wl_1[i] + + 3.9560346 * n_frame[i] * tof_frame_width / CHOPPER_LOCATION[i]; + c_wl_2[i] = + chopper_wl_2[i] + + 3.9560346 * n_frame[i] * tof_frame_width / CHOPPER_LOCATION[i]; if (frame_wl_1 < c_wl_2[i] && frame_wl_2 > c_wl_1[i]) { passed = true; @@ -404,12 +399,12 @@ double EQSANSTofStructure::getTofOffset(EventWorkspace_const_sptr inputWS, chopper_wl_1[i] = c_wl_1[i]; chopper_wl_2[i] = c_wl_2[i]; if (frame_skipping) { - chopper_frameskip_wl_1[i] = c_wl_1[i] + 3.9560346 * 2. * - tof_frame_width / - CHOPPER_LOCATION[i]; - chopper_frameskip_wl_2[i] = c_wl_2[i] + 3.9560346 * 2. * - tof_frame_width / - CHOPPER_LOCATION[i]; + chopper_frameskip_wl_1[i] = + c_wl_1[i] + + 3.9560346 * 2. * tof_frame_width / CHOPPER_LOCATION[i]; + chopper_frameskip_wl_2[i] = + c_wl_2[i] + + 3.9560346 * 2. * tof_frame_width / CHOPPER_LOCATION[i]; if (i == 0) { frameskip_wl_1 = chopper_frameskip_wl_1[i]; frameskip_wl_2 = chopper_frameskip_wl_2[i]; diff --git a/Framework/Algorithms/src/ExportTimeSeriesLog.cpp b/Framework/Algorithms/src/ExportTimeSeriesLog.cpp index ae8489b05ea..f7f59a040f1 100644 --- a/Framework/Algorithms/src/ExportTimeSeriesLog.cpp +++ b/Framework/Algorithms/src/ExportTimeSeriesLog.cpp @@ -10,7 +10,6 @@ #include "MantidDataObjects/Events.h" #include "MantidDataObjects/WorkspaceCreation.h" #include "MantidGeometry/Instrument.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/System.h" #include "MantidKernel/TimeSeriesProperty.h" @@ -23,11 +22,10 @@ using namespace Mantid; using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::DataObjects; +using Mantid::Types::Core::DateAndTime; using namespace std; -using Mantid::Types::DateAndTime; - namespace Mantid { namespace Algorithms { @@ -76,10 +74,9 @@ void ExportTimeSeriesLog::init() { "NumberEntriesExport", EMPTY_INT(), "Number of entries of the log to be exported. Default is all entries."); - declareProperty("IsEventWorkspace", true, - "If set to true, output workspace " - "is EventWorkspace. Otherwise, it " - "is Workspace2D."); + declareProperty("IsEventWorkspace", true, "If set to true, output workspace " + "is EventWorkspace. Otherwise, it " + "is Workspace2D."); } /** Main execution @@ -133,7 +130,7 @@ void ExportTimeSeriesLog::exportLog(const std::string &logname, int numentries, bool cal_first_deriv) { // Get log, time, and etc. - std::vector<Mantid::Types::DateAndTime> times; + std::vector<Types::Core::DateAndTime> times; std::vector<double> values; if (!logname.empty()) { @@ -191,8 +188,7 @@ void ExportTimeSeriesLog::exportLog(const std::string &logname, } else if (numentries <= 0) { stringstream errmsg; errmsg << "For Export Log, NumberEntriesExport must be greater than 0. " - "Input = " - << numentries; + "Input = " << numentries; g_log.error(errmsg.str()); throw std::runtime_error(errmsg.str()); } else if (static_cast<size_t>(numentries) > times.size()) { @@ -217,7 +213,7 @@ void ExportTimeSeriesLog::exportLog(const std::string &logname, * @param start_index :: array index for the first log entry * @param stop_index :: array index for the last log entry * @param numentries :: number of log entries to output - * @param times :: vector of Mantid::Types::DateAndTime + * @param times :: vector of Types::Core::DateAndTime * @param values :: vector of log value in double * @param epochtime :: flag to output time in epoch time/absolute time * @param timeunitfactor :: conversion factor for various unit of time for @@ -232,7 +228,7 @@ void ExportTimeSeriesLog::setupWorkspace2D( int64_t timeshift(0); if (!epochtime) { // relative time - auto runstart = Mantid::Types::DateAndTimeHelpers::createFromISO8601( + Types::Core::DateAndTime runstart( m_inputWS->run().getProperty("run_start")->value()); timeshift = runstart.totalNanoseconds(); } @@ -280,14 +276,14 @@ void ExportTimeSeriesLog::setupWorkspace2D( * @param start_index * @param stop_index * @param numentries :: number of log entries to output - * @param times :: vector of Mantid::Types::DateAndTime + * @param times :: vector of Types::Core::DateAndTime * @param values :: vector of log value in double * @param epochtime :: boolean flag for output time is absolute time/epoch time. */ void ExportTimeSeriesLog::setupEventWorkspace( const size_t &start_index, const size_t &stop_index, int numentries, vector<DateAndTime> ×, vector<double> values, const bool &epochtime) { - auto runstart = Mantid::Types::DateAndTimeHelpers::createFromISO8601( + Types::Core::DateAndTime runstart( m_inputWS->run().getProperty("run_start")->value()); // Get some stuff from the input workspace @@ -316,7 +312,7 @@ void ExportTimeSeriesLog::setupEventWorkspace( } for (size_t i = 0; i < outsize; i++) { - Mantid::Types::DateAndTime tnow = times[i + start_index]; + Types::Core::DateAndTime tnow = times[i + start_index]; int64_t dt = tnow.totalNanoseconds() - time_shift_ns; // convert to microseconds @@ -344,15 +340,15 @@ void ExportTimeSeriesLog::setupEventWorkspace( * second is 1E-9 */ bool ExportTimeSeriesLog::calculateTimeSeriesRangeByTime( - std::vector<Mantid::Types::DateAndTime> &vec_times, - const double &rel_start_time, size_t &i_start, const double &rel_stop_time, - size_t &i_stop, const double &time_factor) { + std::vector<Types::Core::DateAndTime> &vec_times, const double &rel_start_time, + size_t &i_start, const double &rel_stop_time, size_t &i_stop, + const double &time_factor) { // Initialize if there is something wrong. i_start = 0; i_stop = vec_times.size() - 1; // Check existence of proton_charge as run start - Mantid::Types::DateAndTime run_start(0); + Types::Core::DateAndTime run_start(0); if (m_inputWS->run().hasProperty("proton_charge")) { auto ts = dynamic_cast<TimeSeriesProperty<double> *>( m_inputWS->run().getProperty("proton_charge")); @@ -374,7 +370,7 @@ bool ExportTimeSeriesLog::calculateTimeSeriesRangeByTime( if (rel_start_time != EMPTY_DBL()) { int64_t start_time_ns = run_start.totalNanoseconds() + static_cast<int64_t>(rel_start_time / time_factor); - Mantid::Types::DateAndTime start_time(start_time_ns); + Types::Core::DateAndTime start_time(start_time_ns); i_start = static_cast<size_t>( std::lower_bound(vec_times.begin(), vec_times.end(), start_time) - vec_times.begin()); @@ -387,7 +383,7 @@ bool ExportTimeSeriesLog::calculateTimeSeriesRangeByTime( if (rel_stop_time != EMPTY_DBL()) { int64_t stop_time_ns = run_start.totalNanoseconds() + static_cast<int64_t>(rel_stop_time / time_factor); - Mantid::Types::DateAndTime stop_time(stop_time_ns); + Types::Core::DateAndTime stop_time(stop_time_ns); i_stop = static_cast<size_t>( std::lower_bound(vec_times.begin(), vec_times.end(), stop_time) - vec_times.begin()); @@ -461,5 +457,5 @@ void ExportTimeSeriesLog::setupMetaData(const std::string &log_name, m_outWS->mutableRun().addProperty("IsEpochTime", is_epoch, true); } -} // namespace Algorithms } // namespace Mantid +} // namespace Algorithms diff --git a/Framework/Algorithms/src/ExtractSpectra.cpp b/Framework/Algorithms/src/ExtractSpectra.cpp index ba3e41e4317..38495d629eb 100644 --- a/Framework/Algorithms/src/ExtractSpectra.cpp +++ b/Framework/Algorithms/src/ExtractSpectra.cpp @@ -23,7 +23,7 @@ namespace Algorithms { using namespace Kernel; using namespace API; using namespace DataObjects; -using Mantid::Types::TofEvent; +using Types::Event::TofEvent; // Register the algorithm into the AlgorithmFactory DECLARE_ALGORITHM(ExtractSpectra) diff --git a/Framework/Algorithms/src/FilterByLogValue.cpp b/Framework/Algorithms/src/FilterByLogValue.cpp index 393137da607..359a835cfae 100644 --- a/Framework/Algorithms/src/FilterByLogValue.cpp +++ b/Framework/Algorithms/src/FilterByLogValue.cpp @@ -1,12 +1,10 @@ #include "MantidAlgorithms/FilterByLogValue.h" -#include "MantidAPI/Run.h" #include "MantidDataObjects/WorkspaceCreation.h" +#include "MantidAPI/Run.h" #include "MantidKernel/BoundedValidator.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/ITimeSeriesProperty.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/MandatoryValidator.h" -#include "MantidKernel/TimeInterval.h" namespace Mantid { namespace Algorithms { @@ -18,9 +16,9 @@ using namespace DataObjects; using namespace API; using DataObjects::EventList; using DataObjects::EventWorkspace; -using DataObjects::EventWorkspace_const_sptr; using DataObjects::EventWorkspace_sptr; -using Mantid::Types::DateAndTime; +using DataObjects::EventWorkspace_const_sptr; +using Types::Core::DateAndTime; std::string CENTRE("Centre"); std::string LEFT("Left"); @@ -125,9 +123,7 @@ void FilterByLogValue::exec() { // Find the start and stop times of the run, but handle it if they are not // found. - DateAndTime run_start(0), - run_stop = Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2100-01-01T00:00:00"); + DateAndTime run_start(0), run_stop("2100-01-01T00:00:00"); bool handle_edge_values = false; try { run_start = inputWS->getFirstPulseTime() - tolerance; diff --git a/Framework/Algorithms/src/FilterByTime.cpp b/Framework/Algorithms/src/FilterByTime.cpp index 97d849865bd..4af6aa83ab9 100644 --- a/Framework/Algorithms/src/FilterByTime.cpp +++ b/Framework/Algorithms/src/FilterByTime.cpp @@ -3,12 +3,10 @@ #include "MantidDataObjects/EventWorkspace.h" #include "MantidDataObjects/WorkspaceCreation.h" #include "MantidKernel/BoundedValidator.h" -#include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/PhysicalConstants.h" #include "MantidKernel/UnitFactory.h" -using Mantid::Types::DateAndTime; - namespace Mantid { namespace Algorithms { // Register the algorithm into the algorithm factory @@ -18,8 +16,9 @@ using namespace Kernel; using namespace API; using DataObjects::EventList; using DataObjects::EventWorkspace; -using DataObjects::EventWorkspace_const_sptr; using DataObjects::EventWorkspace_sptr; +using DataObjects::EventWorkspace_const_sptr; +using Types::Core::DateAndTime; void FilterByTime::init() { std::string commonHelp("\nYou can only specify the relative or absolute " @@ -82,8 +81,8 @@ void FilterByTime::exec() { if ((start_str != "") && (stop_str != "") && (start_dbl <= 0.0) && (stop_dbl <= 0.0)) { // Use the absolute string - start = Mantid::Types::DateAndTimeHelpers::createFromISO8601(start_str); - stop = Mantid::Types::DateAndTimeHelpers::createFromISO8601(stop_str); + start = DateAndTime(start_str); + stop = DateAndTime(stop_str); } else if ((start_str == "") && (stop_str == "") && ((start_dbl > 0.0) || (stop_dbl > 0.0))) { // Use the relative times in seconds. diff --git a/Framework/Algorithms/src/FilterEvents.cpp b/Framework/Algorithms/src/FilterEvents.cpp index 69aa59285ca..ee310f2a8f1 100644 --- a/Framework/Algorithms/src/FilterEvents.cpp +++ b/Framework/Algorithms/src/FilterEvents.cpp @@ -14,8 +14,8 @@ #include "MantidDataObjects/TableWorkspace.h" #include "MantidDataObjects/WorkspaceCreation.h" #include "MantidKernel/ArrayProperty.h" +#include "MantidKernel/ArrayProperty.h" #include "MantidKernel/BoundedValidator.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/LogFilter.h" #include "MantidKernel/PhysicalConstants.h" @@ -32,7 +32,7 @@ using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::Geometry; -using namespace Mantid::Types; +using Types::Core::DateAndTime; using namespace std; @@ -93,10 +93,9 @@ void FilterEvents::init() { "environment log. This option can make execution of " "algorithm faster. But it lowers precision."); - declareProperty("GroupWorkspaces", false, - "Option to group all the output " - "workspaces. Group name will be " - "OutputWorkspaceBaseName."); + declareProperty("GroupWorkspaces", false, "Option to group all the output " + "workspaces. Group name will be " + "OutputWorkspaceBaseName."); declareProperty("OutputWorkspaceIndexedFrom1", false, "If selected, the minimum output workspace is indexed from 1 " @@ -397,8 +396,7 @@ void FilterEvents::processAlgorithmProperties() { if (m_toGroupWS && m_outputWSNameBase.compare(m_eventWS->getName()) == 0) { std::stringstream errss; errss << "It is not allowed to group output workspaces into the same name " - "(i..e, OutputWorkspaceBaseName = " - << m_outputWSNameBase + "(i..e, OutputWorkspaceBaseName = " << m_outputWSNameBase << ") as the input workspace to filter events from."; throw std::invalid_argument(errss.str()); } @@ -451,7 +449,7 @@ void FilterEvents::processAlgorithmProperties() { // Get run start time from property 'run_start' if (m_eventWS->run().hasProperty("run_start")) { - DateAndTime run_start_time = DateAndTimeHelpers::createFromISO8601( + Types::Core::DateAndTime run_start_time( m_eventWS->run().getProperty("run_start")->value()); m_runStartTime = run_start_time; } @@ -463,8 +461,7 @@ void FilterEvents::processAlgorithmProperties() { std::string start_time_str = getProperty("FilterStartTime"); if (!start_time_str.empty()) { // User specifies the filter starting time - DateAndTime temp_shift_time = - DateAndTimeHelpers::createFromISO8601(start_time_str); + Types::Core::DateAndTime temp_shift_time(start_time_str); m_filterStartTime = temp_shift_time; } else { // Retrieve filter starting time from property run_start as default @@ -632,7 +629,7 @@ void FilterEvents::splitTimeSeriesLogs( const std::vector<TimeSeriesProperty<double> *> &dbl_tsp_vector, const std::vector<TimeSeriesProperty<bool> *> &bool_tsp_vector) { // get split times by converting vector of int64 to Time - std::vector<Mantid::Types::DateAndTime> split_datetime_vec; + std::vector<Types::Core::DateAndTime> split_datetime_vec; // convert splitters workspace to vectors used by TableWorkspace and // MatrixWorkspace splitters @@ -700,7 +697,7 @@ void FilterEvents::splitTimeSeriesLogs( template <typename TYPE> void FilterEvents::splitTimeSeriesProperty( Kernel::TimeSeriesProperty<TYPE> *tsp, - std::vector<Mantid::Types::DateAndTime> &split_datetime_vec, + std::vector<Types::Core::DateAndTime> &split_datetime_vec, const int max_target_index) { // skip the sample logs if they are specified // get property name and etc @@ -1243,8 +1240,9 @@ void FilterEvents::createOutputWorkspacesMatrixCase() { } // Update progress report - m_progress = 0.1 + 0.1 * static_cast<double>(wsgindex) / - static_cast<double>(numoutputws); + m_progress = + 0.1 + + 0.1 * static_cast<double>(wsgindex) / static_cast<double>(numoutputws); progress(m_progress, "Creating output workspace"); wsgindex += 1; } // END-FOR (wsgroup) @@ -1332,8 +1330,9 @@ void FilterEvents::createOutputWorkspacesTableSplitterCase() { } // Update progress report - m_progress = 0.1 + 0.1 * static_cast<double>(wsgindex) / - static_cast<double>(numoutputws); + m_progress = + 0.1 + + 0.1 * static_cast<double>(wsgindex) / static_cast<double>(numoutputws); progress(m_progress, "Creating output workspace"); wsgindex += 1; } // END-FOR (wsgroup) @@ -1346,11 +1345,11 @@ void FilterEvents::createOutputWorkspacesTableSplitterCase() { } /** Set up neutron event's TOF correction. - * It can be (1) parsed from TOF-correction table workspace to vectors, - * (2) created according to detector's position in instrument; - * (3) or no correction,i.e., correction value is equal to 1. - * Offset should be as F*TOF + B - */ + * It can be (1) parsed from TOF-correction table workspace to vectors, + * (2) created according to detector's position in instrument; + * (3) or no correction,i.e., correction value is equal to 1. + * Offset should be as F*TOF + B + */ void FilterEvents::setupDetectorTOFCalibration() { // Set output correction workspace and set to output const size_t numhist = m_eventWS->getNumberHistograms(); @@ -1421,12 +1420,12 @@ TimeAtSampleStrategy *FilterEvents::setupIndirectTOFCorrection() const { } /** Set up corrections with customized TOF correction input - * The first column must be either DetectorID or Spectrum (from 0... as + * The first column must be either DetectorID or Spectrum (from 0... as * workspace index) - * The second column must be Correction or CorrectFactor, a number between 0 + * The second column must be Correction or CorrectFactor, a number between 0 * and 1, i.e, [0, 1] - * The third column is optional as shift in unit of second - */ + * The third column is optional as shift in unit of second + */ void FilterEvents::setupCustomizedTOFCorrection() { // Check input workspace vector<string> colnames = m_detCorrectWorkspace->getColumnNames(); @@ -1569,7 +1568,7 @@ void FilterEvents::setupCustomizedTOFCorrection() { } /** Main filtering method - * Structure: per spectrum --> per workspace + * Structure: per spectrum --> per workspace */ void FilterEvents::filterEventsBySplitters(double progressamount) { size_t numberOfSpectra = m_eventWS->getNumberHistograms(); @@ -1621,7 +1620,7 @@ void FilterEvents::filterEventsBySplitters(double progressamount) { } /** Split events by splitters represented by vector - */ + */ void FilterEvents::filterEventsByVectorSplitters(double progressamount) { size_t numberOfSpectra = m_eventWS->getNumberHistograms(); // FIXME : consider to use vector to index workspace and event list @@ -1629,8 +1628,8 @@ void FilterEvents::filterEventsByVectorSplitters(double progressamount) { // Loop over the histograms (detector spectra) to do split from 1 event list // to N event list g_log.notice() << "Filter by vector splitters: Number of spectra in " - "input/source EventWorkspace = " - << numberOfSpectra << ".\n"; + "input/source EventWorkspace = " << numberOfSpectra + << ".\n"; // check for option FilterByTime if (m_filterByPulseTime) { @@ -1641,11 +1640,9 @@ void FilterEvents::filterEventsByVectorSplitters(double progressamount) { std::stringstream errmsg; errmsg << "It is not proper to split fast event 'By PulseTime'', when " "there are " - "more splitters (" - << m_vecSplitterTime.size() + "more splitters (" << m_vecSplitterTime.size() << ") than pulse time " - "log entries (" - << num_proton_charges << ")"; + "log entries (" << num_proton_charges << ")"; throw runtime_error(errmsg.str()); } else g_log.warning("User should understand the inaccurancy to filter events " @@ -1736,7 +1733,7 @@ void FilterEvents::generateSplitterTSP( new Kernel::TimeSeriesProperty<int>("splitter"); split_tsp_vec.push_back(split_tsp); // add initial value if the first splitter time is after the run start time - split_tsp->addValue(Mantid::Types::DateAndTime(m_runStartTime), 0); + split_tsp->addValue(Types::Core::DateAndTime(m_runStartTime), 0); } // start to go through m_vecSplitterTime (int64) and m_vecSplitterGroup add @@ -1905,5 +1902,5 @@ std::vector<std::string> FilterEvents::getTimeSeriesLogNames() { return lognames; } -} // namespace Algorithms } // namespace Mantid +} // namespace Algorithms diff --git a/Framework/Algorithms/src/GenerateEventsFilter.cpp b/Framework/Algorithms/src/GenerateEventsFilter.cpp index 484cee1f70e..98ea6562c8c 100644 --- a/Framework/Algorithms/src/GenerateEventsFilter.cpp +++ b/Framework/Algorithms/src/GenerateEventsFilter.cpp @@ -6,17 +6,16 @@ #include "MantidAPI/WorkspaceProperty.h" #include "MantidKernel/VisibleWhenProperty.h" #include "MantidKernel/ArrayProperty.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include <boost/math/special_functions/round.hpp> using namespace Mantid; using namespace Mantid::Kernel; using namespace Mantid::API; +using Types::Core::DateAndTime; +using Types::Core::time_duration; using namespace std; -using Mantid::Types::DateAndTime; -using Mantid::Types::time_duration; namespace Mantid { namespace Algorithms { @@ -312,7 +311,7 @@ void GenerateEventsFilter::processInputTime() { m_startTime = runstarttime; } else if (instringformat) { // Time is absolute time in ISO format - m_startTime = Mantid::Types::DateAndTimeHelpers::createFromISO8601(s_inpt0); + m_startTime = DateAndTime(s_inpt0); } else { // Relative time in double. double inpt0 = std::stod(s_inpt0.c_str()); @@ -323,7 +322,7 @@ void GenerateEventsFilter::processInputTime() { } int64_t t0_ns = runstarttime.totalNanoseconds() + static_cast<int64_t>(inpt0 * m_timeUnitConvertFactorToNS); - m_startTime = Mantid::Types::DateAndTime(t0_ns); + m_startTime = Types::Core::DateAndTime(t0_ns); } // Set up run stop time @@ -332,13 +331,13 @@ void GenerateEventsFilter::processInputTime() { m_stopTime = m_runEndTime; } else if (instringformat) { // Absolute time in ISO format - m_stopTime = Mantid::Types::DateAndTimeHelpers::createFromISO8601(s_inptf); + m_stopTime = DateAndTime(s_inptf); } else { // Relative time in double double inptf = std::stod(s_inptf.c_str()); int64_t tf_ns = runstarttime.totalNanoseconds() + static_cast<int64_t>(inptf * m_timeUnitConvertFactorToNS); - m_stopTime = Mantid::Types::DateAndTime(tf_ns); + m_stopTime = Types::Core::DateAndTime(tf_ns); } // Check start/stop time @@ -408,8 +407,8 @@ void GenerateEventsFilter::setFilterByTimeOnly() { nexttime_ns = m_stopTime.totalNanoseconds(); // Create splitter and information - Mantid::Types::DateAndTime t0(curtime_ns); - Mantid::Types::DateAndTime tf(nexttime_ns); + Types::Core::DateAndTime t0(curtime_ns); + Types::Core::DateAndTime tf(nexttime_ns); std::stringstream ss; ss << "Time.Interval.From." << t0 << ".to." << tf; @@ -461,8 +460,8 @@ void GenerateEventsFilter::setFilterByTimeOnly() { } // Create splitter and information - Mantid::Types::DateAndTime t0(curtime_ns); - Mantid::Types::DateAndTime tf(nexttime_ns); + Types::Core::DateAndTime t0(curtime_ns); + Types::Core::DateAndTime tf(nexttime_ns); std::stringstream ss; ss << "Time.Interval.From." << t0 << ".to." << tf; @@ -812,7 +811,7 @@ void GenerateEventsFilter::processMultipleValueFilters(double minvalue, void GenerateEventsFilter::makeFilterBySingleValue( double min, double max, double TimeTolerance, bool centre, bool filterIncrease, bool filterDecrease, DateAndTime startTime, - Mantid::Types::DateAndTime stopTime, int wsindex) { + Types::Core::DateAndTime stopTime, int wsindex) { // Do nothing if the log is empty. if (m_dblLog->size() == 0) { g_log.warning() << "There is no entry in this property " << this->name() @@ -905,9 +904,9 @@ void GenerateEventsFilter::makeFilterBySingleValue( * with the old direction) */ bool GenerateEventsFilter::identifyLogEntry( - const int &index, const Mantid::Types::DateAndTime &currT, const bool &lastgood, + const int &index, const Types::Core::DateAndTime &currT, const bool &lastgood, const double &minvalue, const double &maxvalue, - const Mantid::Types::DateAndTime &startT, const Mantid::Types::DateAndTime &stopT, + const Types::Core::DateAndTime &startT, const Types::Core::DateAndTime &stopT, const bool &filterIncrease, const bool &filterDecrease) { double val = m_dblLog->nthValue(index); @@ -1170,7 +1169,7 @@ void GenerateEventsFilter::makeMultipleFiltersByValuesParallel( /** Make filters by multiple log values of partial log */ void GenerateEventsFilter::makeMultipleFiltersByValuesPartialLog( - int istart, int iend, std::vector<Mantid::Types::DateAndTime> &vecSplitTime, + int istart, int iend, std::vector<Types::Core::DateAndTime> &vecSplitTime, std::vector<int> &vecSplitGroup, map<size_t, int> indexwsindexmap, const vector<double> &logvalueranges, time_duration tol, bool filterIncrease, bool filterDecrease, DateAndTime startTime, @@ -1184,7 +1183,7 @@ void GenerateEventsFilter::makeMultipleFiltersByValuesPartialLog( int64_t tol_ns = tol.total_nanoseconds(); // Define loop control parameters - const Mantid::Types::DateAndTime ZeroTime(0); + const Types::Core::DateAndTime ZeroTime(0); int lastindex = -1; int currindex = -1; DateAndTime lastTime; @@ -1655,7 +1654,7 @@ int GenerateEventsFilter::determineChangingDirection(int startindex) { /** Add a new splitter to vector of splitters. It is used by FilterByTime only. */ void GenerateEventsFilter::addNewTimeFilterSplitter( - Mantid::Types::DateAndTime starttime, Mantid::Types::DateAndTime stoptime, int wsindex, + Types::Core::DateAndTime starttime, Types::Core::DateAndTime stoptime, int wsindex, string info) { if (m_forFastLog) { // For MatrixWorkspace splitter @@ -1697,9 +1696,9 @@ void GenerateEventsFilter::addNewTimeFilterSplitter( * This method will be called intensively. */ DateAndTime GenerateEventsFilter::makeSplitterInVector( - std::vector<Mantid::Types::DateAndTime> &vecSplitTime, - std::vector<int> &vecGroupIndex, Mantid::Types::DateAndTime start, - Mantid::Types::DateAndTime stop, int group, int64_t tol_ns, DateAndTime lasttime) { + std::vector<Types::Core::DateAndTime> &vecSplitTime, + std::vector<int> &vecGroupIndex, Types::Core::DateAndTime start, + Types::Core::DateAndTime stop, int group, int64_t tol_ns, DateAndTime lasttime) { DateAndTime starttime(start.totalNanoseconds() - tol_ns); DateAndTime stoptime(stop.totalNanoseconds() - tol_ns); // DateAndTime starttime = start-tolerance; @@ -1860,7 +1859,7 @@ DateAndTime GenerateEventsFilter::findRunEnd() { } if (protonchargelog->size() > 1) { - Mantid::Types::DateAndTime tmpendtime = protonchargelog->lastTime(); + Types::Core::DateAndTime tmpendtime = protonchargelog->lastTime(); extended_ns = protonchargelog->nthTime(1).totalNanoseconds() - protonchargelog->nthTime(0).totalNanoseconds(); if (tmpendtime > runendtime) { diff --git a/Framework/Algorithms/src/GenerateIPythonNotebook.cpp b/Framework/Algorithms/src/GenerateIPythonNotebook.cpp index 65fa592b27d..60c687a9e27 100644 --- a/Framework/Algorithms/src/GenerateIPythonNotebook.cpp +++ b/Framework/Algorithms/src/GenerateIPythonNotebook.cpp @@ -1,18 +1,17 @@ #include "MantidAlgorithms/GenerateIPythonNotebook.h" -#include "MantidAPI/AlgorithmHistory.h" -#include "MantidAPI/AlgorithmManager.h" +#include "MantidKernel/ListValidator.h" +#include "MantidKernel/System.h" #include "MantidAPI/FileProperty.h" +#include "MantidAPI/AlgorithmManager.h" +#include "MantidAPI/AlgorithmHistory.h" #include "MantidAPI/NotebookBuilder.h" #include "MantidAPI/Workspace.h" -#include "MantidKernel/DateAndTimeHelpers.h" -#include "MantidKernel/ListValidator.h" -#include "MantidKernel/System.h" #include <fstream> using namespace Mantid::Kernel; using namespace Mantid::API; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; namespace { Mantid::Kernel::Logger g_log("GenerateIPythonNotebook"); @@ -25,7 +24,7 @@ namespace Algorithms { DECLARE_ALGORITHM(GenerateIPythonNotebook) /** Initialize the algorithm's properties. - */ +*/ void GenerateIPythonNotebook::init() { declareProperty(make_unique<WorkspaceProperty<Workspace>>( "InputWorkspace", "", Direction::Input), @@ -62,7 +61,7 @@ void GenerateIPythonNotebook::init() { } /** Execute the algorithm. - */ +*/ void GenerateIPythonNotebook::exec() { const Workspace_const_sptr ws = getProperty("InputWorkspace"); const bool unrollAll = getProperty("UnrollAll"); @@ -85,12 +84,9 @@ void GenerateIPythonNotebook::exec() { if (!startTime.empty()) { if (endTime.empty()) { // If no end time was given then filter up to now - view->filterBetweenExecDate( - DateAndTimeHelpers::createFromISO8601(startTime)); + view->filterBetweenExecDate(DateAndTime(startTime)); } else { - view->filterBetweenExecDate( - DateAndTimeHelpers::createFromISO8601(startTime), - DateAndTimeHelpers::createFromISO8601(endTime)); + view->filterBetweenExecDate(DateAndTime(startTime), DateAndTime(endTime)); } } diff --git a/Framework/Algorithms/src/GeneratePythonScript.cpp b/Framework/Algorithms/src/GeneratePythonScript.cpp index bb7f5c6ab69..c618de3aa37 100644 --- a/Framework/Algorithms/src/GeneratePythonScript.cpp +++ b/Framework/Algorithms/src/GeneratePythonScript.cpp @@ -1,18 +1,17 @@ #include "MantidAlgorithms/GeneratePythonScript.h" -#include "MantidAPI/AlgorithmHistory.h" -#include "MantidAPI/AlgorithmManager.h" +#include "MantidKernel/ListValidator.h" +#include "MantidKernel/System.h" #include "MantidAPI/FileProperty.h" +#include "MantidAPI/AlgorithmManager.h" +#include "MantidAPI/AlgorithmHistory.h" #include "MantidAPI/ScriptBuilder.h" #include "MantidAPI/Workspace.h" -#include "MantidKernel/DateAndTimeHelpers.h" -#include "MantidKernel/ListValidator.h" -#include "MantidKernel/System.h" #include <fstream> using namespace Mantid::Kernel; -using namespace Mantid::Types; using namespace Mantid::API; +using Mantid::Types::Core::DateAndTime; namespace { Mantid::Kernel::Logger g_log("GeneratePythonScript"); @@ -25,7 +24,7 @@ namespace Algorithms { DECLARE_ALGORITHM(GeneratePythonScript) /** Initialize the algorithm's properties. - */ +*/ void GeneratePythonScript::init() { declareProperty(make_unique<WorkspaceProperty<Workspace>>( "InputWorkspace", "", Direction::Input), @@ -61,7 +60,7 @@ void GeneratePythonScript::init() { } /** Execute the algorithm. - */ +*/ void GeneratePythonScript::exec() { const Workspace_const_sptr ws = getProperty("InputWorkspace"); const bool unrollAll = getProperty("UnrollAll"); @@ -84,12 +83,9 @@ void GeneratePythonScript::exec() { if (!startTime.empty()) { if (endTime.empty()) { // If no end time was given then filter up to now - view->filterBetweenExecDate( - DateAndTimeHelpers::createFromISO8601(startTime)); + view->filterBetweenExecDate(DateAndTime(startTime)); } else { - view->filterBetweenExecDate( - DateAndTimeHelpers::createFromISO8601(startTime), - DateAndTimeHelpers::createFromISO8601(endTime)); + view->filterBetweenExecDate(DateAndTime(startTime), DateAndTime(endTime)); } } diff --git a/Framework/Algorithms/src/GetAllEi.cpp b/Framework/Algorithms/src/GetAllEi.cpp index e42d19434fa..ea9987fb37a 100644 --- a/Framework/Algorithms/src/GetAllEi.cpp +++ b/Framework/Algorithms/src/GetAllEi.cpp @@ -1036,10 +1036,10 @@ namespace { // former lambda function for findChopSpeedAndDelay *@return true if selection interval is completed * (current interval is not selected) and false otherwise */ -bool SelectInterval(const Mantid::Types::DateAndTime &t_beg, - const Mantid::Types::DateAndTime &t_end, double value, - bool &inSelection, Mantid::Types::DateAndTime &startTime, - Mantid::Types::DateAndTime &endTime) { +bool SelectInterval(const Types::Core::DateAndTime &t_beg, + const Types::Core::DateAndTime &t_end, double value, + bool &inSelection, Types::Core::DateAndTime &startTime, + Types::Core::DateAndTime &endTime) { if (value > 0) { if (!inSelection) { @@ -1074,14 +1074,14 @@ void GetAllEi::findChopSpeedAndDelay(const API::MatrixWorkspace_sptr &inputWS, // Define selecting function bool inSelection(false); // time interval to select (start-end) - Mantid::Types::DateAndTime startTime, endTime; + Types::Core::DateAndTime startTime, endTime; // // Analyze filtering log auto dateAndTimes = m_pFilterLog->valueAsCorrectMap(); auto it = dateAndTimes.begin(); auto next = it; next++; - std::map<Mantid::Types::DateAndTime, double> derivMap; + std::map<Types::Core::DateAndTime, double> derivMap; auto itder = it; if (m_FilterWithDerivative) { pDerivative = m_pFilterLog->getDerivative(); diff --git a/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp b/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp index 9dcf061596a..72a14a7949e 100644 --- a/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp +++ b/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp @@ -1,26 +1,23 @@ #include "MantidAlgorithms/GetTimeSeriesLogInformation.h" +#include "MantidAPI/WorkspaceProperty.h" #include "MantidAPI/Run.h" #include "MantidAPI/TableRow.h" #include "MantidAPI/WorkspaceFactory.h" -#include "MantidAPI/WorkspaceProperty.h" -#include "MantidDataObjects/EventList.h" #include "MantidDataObjects/EventWorkspace.h" +#include "MantidDataObjects/EventList.h" #include "MantidGeometry/Instrument.h" -#include "MantidKernel/DateAndTimeHelpers.h" -#include "MantidKernel/ListValidator.h" #include "MantidKernel/TimeSeriesProperty.h" #include <algorithm> #include <fstream> +#include "MantidKernel/ListValidator.h" using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::DataObjects; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; using namespace std; -using Mantid::Types::DateAndTime; - namespace Mantid { namespace Algorithms { @@ -234,9 +231,9 @@ void GetTimeSeriesLogInformation::processTimeRange() { /** Convert a value in nanosecond to DateAndTime. The value is treated as an * absolute time from - * 1990.01.01 - */ -Mantid::Types::DateAndTime + * 1990.01.01 + */ +Types::Core::DateAndTime GetTimeSeriesLogInformation::getAbsoluteTime(double abstimens) { DateAndTime temptime(static_cast<int64_t>(abstimens)); @@ -244,9 +241,9 @@ GetTimeSeriesLogInformation::getAbsoluteTime(double abstimens) { } /** Calculate the time from a given relative time from run start - * @param deltatime :: double as a relative time to run start time in second - */ -Mantid::Types::DateAndTime + * @param deltatime :: double as a relative time to run start time in second + */ +Types::Core::DateAndTime GetTimeSeriesLogInformation::calculateRelativeTime(double deltatime) { int64_t totaltime = m_starttime.totalNanoseconds() + static_cast<int64_t>(deltatime * 1.0E9); @@ -256,7 +253,7 @@ GetTimeSeriesLogInformation::calculateRelativeTime(double deltatime) { } /** Generate statistic information table workspace - */ + */ TableWorkspace_sptr GetTimeSeriesLogInformation::generateStatisticTable() { auto tablews = boost::make_shared<TableWorkspace>(); @@ -306,8 +303,7 @@ void GetTimeSeriesLogInformation::exportErrorLog(MatrixWorkspace_sptr ws, std::ofstream ofs; ofs.open(ofilename.c_str(), std::ios::out); - DateAndTime t0 = DateAndTimeHelpers::createFromISO8601( - ws->run().getProperty("run_start")->value()); + Types::Core::DateAndTime t0(ws->run().getProperty("run_start")->value()); for (size_t i = 1; i < abstimevec.size(); i++) { double tempdts = static_cast<double>(abstimevec[i].totalNanoseconds() - @@ -338,13 +334,13 @@ void GetTimeSeriesLogInformation::exportErrorLog(MatrixWorkspace_sptr ws, } /** Output distributions in order for a better understanding of the log - * Result is written to a Workspace2D - * - * @param timevec :: a vector of time stamps - * @param stepsize :: resolution of the delta time count bin - */ + * Result is written to a Workspace2D + * + * @param timevec :: a vector of time stamps + * @param stepsize :: resolution of the delta time count bin + */ Workspace2D_sptr GetTimeSeriesLogInformation::calDistributions( - std::vector<Mantid::Types::DateAndTime> timevec, double stepsize) { + std::vector<Types::Core::DateAndTime> timevec, double stepsize) { // 1. Get a vector of delta T (in unit of seconds) double dtmin = static_cast<double>(timevec.back().totalNanoseconds() - timevec[0].totalNanoseconds()) * @@ -420,8 +416,8 @@ void GetTimeSeriesLogInformation::checkLogBasicInforamtion() { size_t countsame = 0; size_t countinverse = 0; for (size_t i = 1; i < m_timeVec.size(); i++) { - Mantid::Types::DateAndTime tprev = m_timeVec[i - 1]; - Mantid::Types::DateAndTime tpres = m_timeVec[i]; + Types::Core::DateAndTime tprev = m_timeVec[i - 1]; + Types::Core::DateAndTime tpres = m_timeVec[i]; if (tprev == tpres) countsame++; else if (tprev > tpres) @@ -430,8 +426,8 @@ void GetTimeSeriesLogInformation::checkLogBasicInforamtion() { // Written to summary map /* - Kernel::time_duration dts = m_timeVec[0]-m_starttime; - Kernel::time_duration dtf = m_timeVec.back() - m_timeVec[0]; + Types::Core::time_duration dts = m_timeVec[0]-m_starttime; + Types::Core::time_duration dtf = m_timeVec.back() - m_timeVec[0]; size_t f = m_timeVec.size()-1; */ @@ -566,5 +562,5 @@ void GetTimeSeriesLogInformation::checkLogValueChanging( g_log.debug() << ss.str(); } -} // namespace Algorithms } // namespace Mantid +} // namespace Algorithms diff --git a/Framework/Algorithms/src/Pause.cpp b/Framework/Algorithms/src/Pause.cpp index 4b77b48be20..52440af4751 100644 --- a/Framework/Algorithms/src/Pause.cpp +++ b/Framework/Algorithms/src/Pause.cpp @@ -1,13 +1,12 @@ #include "MantidAlgorithms/Pause.h" #include "MantidAPI/Algorithm.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include <Poco/Thread.h> using namespace Mantid::Kernel; using namespace Mantid::API; - -using Mantid::Types::DateAndTime; +using Mantid::Types::Core::DateAndTime; namespace Mantid { namespace Algorithms { diff --git a/Framework/Algorithms/src/PlotAsymmetryByLogValue.cpp b/Framework/Algorithms/src/PlotAsymmetryByLogValue.cpp index 8b8ccfd2270..90d0db07614 100644 --- a/Framework/Algorithms/src/PlotAsymmetryByLogValue.cpp +++ b/Framework/Algorithms/src/PlotAsymmetryByLogValue.cpp @@ -9,20 +9,19 @@ #include "MantidAPI/TableRow.h" #include "MantidAPI/TextAxis.h" #include "MantidAPI/WorkspaceFactory.h" -#include "MantidAPI/WorkspaceGroup.h" #include "MantidAlgorithms/PlotAsymmetryByLogValue.h" #include "MantidDataObjects/TableWorkspace.h" #include "MantidKernel/ArrayProperty.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/MandatoryValidator.h" #include "MantidKernel/PropertyWithValue.h" #include "MantidKernel/TimeSeriesProperty.h" #include "Poco/File.h" #include <MantidAPI/FileFinder.h> +#include "MantidAPI/WorkspaceGroup.h" namespace // anonymous -{ + { /** * Convert a log property to a double value. @@ -59,7 +58,7 @@ bool convertLogToDouble(const Mantid::Kernel::Property *property, double &value, return false; } -} // namespace +} // anonymous namespace Mantid { namespace Algorithms { @@ -81,8 +80,8 @@ PlotAsymmetryByLogValue::PlotAsymmetryByLogValue() m_firstStart_ns(0) {} /** Initialisation method. Declares properties to be used in algorithm. - * - */ +* +*/ void PlotAsymmetryByLogValue::init() { std::string nexusExt(".nxs"); @@ -147,8 +146,8 @@ void PlotAsymmetryByLogValue::init() { } /** - * Executes the algorithm - */ +* Executes the algorithm +*/ void PlotAsymmetryByLogValue::exec() { // Check input properties to decide whether or not we can reuse previous @@ -186,7 +185,7 @@ void PlotAsymmetryByLogValue::exec() { nplots, // the number of plots npoints, // the number of data points on a plot npoints // it's not a histogram - ); + ); // Populate output workspace with data populateOutputWorkspace(outWS, nplots); // Assign the result to the output workspace property @@ -199,9 +198,9 @@ void PlotAsymmetryByLogValue::exec() { } /** Checks input properties and compares them to previous values - * @param is :: [output] Number of the first run - * @param ie :: [output] Number of the last run - */ +* @param is :: [output] Number of the first run +* @param ie :: [output] Number of the last run +*/ void PlotAsymmetryByLogValue::checkProperties(size_t &is, size_t &ie) { // Log Value @@ -303,10 +302,10 @@ void PlotAsymmetryByLogValue::checkProperties(size_t &is, size_t &ie) { } /** Loads one run and applies dead-time corrections and detector grouping if - * required - * @param runNumber :: [input] Run number specifying run to load - * @return :: Loaded workspace - */ +* required +* @param runNumber :: [input] Run number specifying run to load +* @return :: Loaded workspace +*/ Workspace_sptr PlotAsymmetryByLogValue::doLoad(size_t runNumber) { // Get complete run name @@ -363,9 +362,9 @@ Workspace_sptr PlotAsymmetryByLogValue::doLoad(size_t runNumber) { } /** Load dead-time corrections from specified file - * @param deadTimeFile :: [input] File to read corrections from - * @return :: Deadtime corrections loaded from file - */ +* @param deadTimeFile :: [input] File to read corrections from +* @return :: Deadtime corrections loaded from file +*/ Workspace_sptr PlotAsymmetryByLogValue::loadCorrectionsFromFile( const std::string &deadTimeFile) { @@ -378,9 +377,9 @@ Workspace_sptr PlotAsymmetryByLogValue::loadCorrectionsFromFile( } /** Populate output workspace with results - * @param outWS :: [input/output] Output workspace to populate - * @param nplots :: [input] Number of histograms - */ +* @param outWS :: [input/output] Output workspace to populate +* @param nplots :: [input] Number of histograms +*/ void PlotAsymmetryByLogValue::populateOutputWorkspace( MatrixWorkspace_sptr &outWS, int nplots) { @@ -423,9 +422,9 @@ void PlotAsymmetryByLogValue::populateOutputWorkspace( } /** Populate output workspace with results - * @param outWS :: [input/output] Output workspace to populate - * @param nplots :: [input] Number of histograms - */ +* @param outWS :: [input/output] Output workspace to populate +* @param nplots :: [input] Number of histograms +*/ void PlotAsymmetryByLogValue::saveResultsToADS(MatrixWorkspace_sptr &outWS, int nplots) { @@ -468,12 +467,12 @@ void PlotAsymmetryByLogValue::saveResultsToADS(MatrixWorkspace_sptr &outWS, } /** Parse run names - * @param firstFN :: [input/output] First run's name - * @param lastFN :: [input/output] Last run's name - * @param fnBase :: [output] Runs base name - * @param fnExt :: [output] Runs extension - * @param fnZeros :: [output] Number of zeros in run's name - */ +* @param firstFN :: [input/output] First run's name +* @param lastFN :: [input/output] Last run's name +* @param fnBase :: [output] Runs base name +* @param fnExt :: [output] Runs extension +* @param fnZeros :: [output] Number of zeros in run's name +*/ void PlotAsymmetryByLogValue::parseRunNames(std::string &firstFN, std::string &lastFN, std::string &fnBase, @@ -549,10 +548,10 @@ void PlotAsymmetryByLogValue::parseRunNames(std::string &firstFN, } /** Apply dead-time corrections. The calculation is done by ApplyDeadTimeCorr - * algorithm - * @param loadedWs :: [input/output] Workspace to apply corrections to - * @param deadTimes :: [input] Corrections to apply - */ +* algorithm +* @param loadedWs :: [input/output] Workspace to apply corrections to +* @param deadTimes :: [input] Corrections to apply +*/ void PlotAsymmetryByLogValue::applyDeadtimeCorr(Workspace_sptr &loadedWs, Workspace_sptr deadTimes) { ScopedWorkspace ws(loadedWs); @@ -573,10 +572,10 @@ void PlotAsymmetryByLogValue::applyDeadtimeCorr(Workspace_sptr &loadedWs, } /** Creates grouping table from supplied forward and backward spectra - * @param fwd :: [Input] Forward spectra - * @param bwd :: [Input] Backward spectra - * @return :: Workspace containing custom grouping - */ +* @param fwd :: [Input] Forward spectra +* @param bwd :: [Input] Backward spectra +* @return :: Workspace containing custom grouping +*/ Workspace_sptr PlotAsymmetryByLogValue::createCustomGrouping(const std::vector<int> &fwd, const std::vector<int> &bwd) { @@ -593,9 +592,9 @@ PlotAsymmetryByLogValue::createCustomGrouping(const std::vector<int> &fwd, } /** Group detectors from table - * @param loadedWs :: [input/output] Workspace to apply grouping to - * @param grouping :: [input] Workspace containing grouping to apply - */ +* @param loadedWs :: [input/output] Workspace to apply grouping to +* @param grouping :: [input] Workspace containing grouping to apply +*/ void PlotAsymmetryByLogValue::groupDetectors(Workspace_sptr &loadedWs, Workspace_sptr grouping) { @@ -615,9 +614,9 @@ void PlotAsymmetryByLogValue::groupDetectors(Workspace_sptr &loadedWs, } /** Performs asymmetry analysis on a loaded workspace - * @param loadedWs :: [input] Workspace to apply analysis to - * @param index :: [input] Vector index where results will be stored - */ +* @param loadedWs :: [input] Workspace to apply analysis to +* @param index :: [input] Vector index where results will be stored +*/ void PlotAsymmetryByLogValue::doAnalysis(Workspace_sptr loadedWs, size_t index) { @@ -683,11 +682,11 @@ void PlotAsymmetryByLogValue::doAnalysis(Workspace_sptr loadedWs, } /** Calculate the integral asymmetry for a workspace. - * The calculation is done by AsymmetryCalc and Integration algorithms. - * @param ws :: The workspace - * @param Y :: Reference to a variable receiving the value of asymmetry - * @param E :: Reference to a variable receiving the value of the error - */ +* The calculation is done by AsymmetryCalc and Integration algorithms. +* @param ws :: The workspace +* @param Y :: Reference to a variable receiving the value of asymmetry +* @param E :: Reference to a variable receiving the value of the error +*/ void PlotAsymmetryByLogValue::calcIntAsymmetry(MatrixWorkspace_sptr ws, double &Y, double &E) { @@ -731,11 +730,11 @@ void PlotAsymmetryByLogValue::calcIntAsymmetry(MatrixWorkspace_sptr ws, } /** Calculate the integral asymmetry for a pair of workspaces (red & green). - * @param ws_red :: The red workspace - * @param ws_green :: The green workspace - * @param Y :: Reference to a variable receiving the value of asymmetry - * @param E :: Reference to a variable receiving the value of the error - */ +* @param ws_red :: The red workspace +* @param ws_green :: The green workspace +* @param Y :: Reference to a variable receiving the value of asymmetry +* @param E :: Reference to a variable receiving the value of the error +*/ void PlotAsymmetryByLogValue::calcIntAsymmetry(MatrixWorkspace_sptr ws_red, MatrixWorkspace_sptr ws_green, double &Y, double &E) { @@ -809,12 +808,10 @@ double PlotAsymmetryByLogValue::getLogValue(MatrixWorkspace &ws) { const Run &run = ws.run(); // Get the start & end time for the run - Mantid::Types::DateAndTime start, end; + Mantid::Types::Core::DateAndTime start, end; if (run.hasProperty("run_start") && run.hasProperty("run_end")) { - start = Mantid::Types::DateAndTimeHelpers::createFromISO8601( - run.getProperty("run_start")->value()); - end = Mantid::Types::DateAndTimeHelpers::createFromISO8601( - run.getProperty("run_end")->value()); + start = run.getProperty("run_start")->value(); + end = run.getProperty("run_end")->value(); } // If this is the first run, cache the start time @@ -871,5 +868,5 @@ double PlotAsymmetryByLogValue::getLogValue(MatrixWorkspace &ws) { " cannot be converted to a double type."); } -} // namespace Algorithms +} // namespace Algorithm } // namespace Mantid diff --git a/Framework/Algorithms/src/RebinByTimeBase.cpp b/Framework/Algorithms/src/RebinByTimeBase.cpp index 99084538a8a..dd4fcb40b4d 100644 --- a/Framework/Algorithms/src/RebinByTimeBase.cpp +++ b/Framework/Algorithms/src/RebinByTimeBase.cpp @@ -16,7 +16,7 @@ namespace Algorithms { using namespace Mantid::Kernel; using namespace Mantid::API; -using Mantid::Types::DateAndTime; +using Types::Core::DateAndTime; /** Helper method to transform a MantidVector containing absolute times in diff --git a/Framework/Algorithms/src/RunCombinationHelpers/SampleLogsBehaviour.cpp b/Framework/Algorithms/src/RunCombinationHelpers/SampleLogsBehaviour.cpp index 26c2d6420ae..a734e22ceaf 100644 --- a/Framework/Algorithms/src/RunCombinationHelpers/SampleLogsBehaviour.cpp +++ b/Framework/Algorithms/src/RunCombinationHelpers/SampleLogsBehaviour.cpp @@ -510,7 +510,7 @@ void SampleLogsBehaviour::updateTimeSeriesProperty(MatrixWorkspace &addeeWS, } catch (std::invalid_argument &) { auto timeSeriesProp = outWS.mutableRun().getTimeSeriesProperty<double>(name); - Mantid::Types::DateAndTime startTime = addeeWS.mutableRun().startTime(); + Types::Core::DateAndTime startTime = addeeWS.mutableRun().startTime(); double value = addeeWS.mutableRun().getLogAsSingleValue(name); timeSeriesProp->addValue(startTime, value); // Remove this to supress a warning, we will put it back after adding the diff --git a/Framework/Algorithms/src/ShiftLogTime.cpp b/Framework/Algorithms/src/ShiftLogTime.cpp index cb4df45c072..fa85b0149d9 100644 --- a/Framework/Algorithms/src/ShiftLogTime.cpp +++ b/Framework/Algorithms/src/ShiftLogTime.cpp @@ -11,7 +11,7 @@ using namespace Mantid::API; using std::string; using std::stringstream; using std::vector; -using Mantid::Types::DateAndTime; +using Mantid::Types::Core::DateAndTime; namespace Mantid { namespace Algorithms { diff --git a/Framework/Algorithms/src/SumEventsByLogValue.cpp b/Framework/Algorithms/src/SumEventsByLogValue.cpp index 9216c3ea577..fe688648900 100644 --- a/Framework/Algorithms/src/SumEventsByLogValue.cpp +++ b/Framework/Algorithms/src/SumEventsByLogValue.cpp @@ -10,7 +10,6 @@ #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/MandatoryValidator.h" #include "MantidKernel/RebinParamsValidator.h" -#include "MantidKernel/TimeInterval.h" #include "MantidKernel/VectorHelper.h" #include <numeric> diff --git a/Framework/Algorithms/test/AddNoteTest.h b/Framework/Algorithms/test/AddNoteTest.h index a261ee5b90a..9276173bf4f 100644 --- a/Framework/Algorithms/test/AddNoteTest.h +++ b/Framework/Algorithms/test/AddNoteTest.h @@ -1,13 +1,10 @@ #ifndef MANTID_ALGORITHMS_ADDNOTETEST_H_ #define MANTID_ALGORITHMS_ADDNOTETEST_H_ +#include <cxxtest/TestSuite.h> #include "MantidAlgorithms/AddNote.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/TimeSeriesProperty.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" -#include <cxxtest/TestSuite.h> - -using namespace Mantid::Types; class AddNoteTest : public CxxTest::TestSuite { @@ -38,7 +35,7 @@ public: // Get Current Date Time namespace pt = boost::posix_time; auto dateTimeObj = - Mantid::Types::DateAndTime(pt::second_clock::local_time()); + Mantid::Types::Core::DateAndTime(pt::second_clock::local_time()); std::string time = dateTimeObj.toISO8601String(); std::string timeOffset = time; TS_ASSERT_THROWS_NOTHING( @@ -112,6 +109,7 @@ private: const int &logEndTime, const std::string logValue, const size_t position) { + using Mantid::Types::Core::DateAndTime; using Mantid::Kernel::TimeSeriesProperty; const auto &run = testWS->run(); @@ -127,8 +125,7 @@ private: TS_ASSERT(times.size() >= position + 1); auto values = timeSeries->valuesAsVector(); if (logEndTime == 0) { - TS_ASSERT_EQUALS(DateAndTimeHelpers::createFromISO8601(logStartTime), - times[position]); + TS_ASSERT_EQUALS(DateAndTime(logStartTime), times[position]); } else { int logMinTime = 0, logMaxTime = 0; TS_ASSERT_THROWS_NOTHING( diff --git a/Framework/Algorithms/test/AddSampleLogTest.h b/Framework/Algorithms/test/AddSampleLogTest.h index 322af463f32..18a1deec98c 100644 --- a/Framework/Algorithms/test/AddSampleLogTest.h +++ b/Framework/Algorithms/test/AddSampleLogTest.h @@ -5,16 +5,15 @@ #include <string> +#include "MantidTestHelpers/WorkspaceCreationHelper.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAlgorithms/AddSampleLog.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/TimeSeriesProperty.h" -#include "MantidTestHelpers/WorkspaceCreationHelper.h" using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::Algorithms; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; class AddSampleLogTest : public CxxTest::TestSuite { public: @@ -62,9 +61,8 @@ public: void test_NumberSeries() { MatrixWorkspace_sptr ws = WorkspaceCreationHelper::create2DWorkspace(10, 10); - ws->mutableRun().setStartAndEndTime( - DateAndTimeHelpers::createFromISO8601("2013-12-18T13:40:00"), - DateAndTimeHelpers::createFromISO8601("2013-12-18T13:42:00")); + ws->mutableRun().setStartAndEndTime(DateAndTime("2013-12-18T13:40:00"), + DateAndTime("2013-12-18T13:42:00")); ExecuteAlgorithm(ws, "My Name NS1", "Number Series", "1.234", 1.234); ExecuteAlgorithm(ws, "My Name NS1", "Number Series", "2.456", 2.456); // Only double is allowed if using default type @@ -77,9 +75,8 @@ public: void test_Units() { MatrixWorkspace_sptr ws = WorkspaceCreationHelper::create2DWorkspace(10, 10); - ws->mutableRun().setStartAndEndTime( - DateAndTimeHelpers::createFromISO8601("2013-12-18T13:40:00"), - DateAndTimeHelpers::createFromISO8601("2013-12-18T13:42:00")); + ws->mutableRun().setStartAndEndTime(DateAndTime("2013-12-18T13:40:00"), + DateAndTime("2013-12-18T13:42:00")); ExecuteAlgorithm(ws, "My Name", "Number Series", "1.234", 1.234, false, "myUnit"); ExecuteAlgorithm(ws, "My New Name", "Number", "963", 963, false, @@ -91,9 +88,8 @@ public: void test_number_type() { MatrixWorkspace_sptr ws = WorkspaceCreationHelper::create2DWorkspace(10, 10); - ws->mutableRun().setStartAndEndTime( - DateAndTimeHelpers::createFromISO8601("2013-12-18T13:40:00"), - DateAndTimeHelpers::createFromISO8601("2013-12-18T13:42:00")); + ws->mutableRun().setStartAndEndTime(DateAndTime("2013-12-18T13:40:00"), + DateAndTime("2013-12-18T13:42:00")); ExecuteAlgorithm(ws, "My Name", "Number Series", "1.234", 1.234, false, "myUnit", "Double"); ExecuteAlgorithm(ws, "My New Name", "Number", "963", 963, false, @@ -225,9 +221,8 @@ public: } else if (LogType == "Number Series") { auto testProp = dynamic_cast<TimeSeriesProperty<T> *>(prop); TS_ASSERT(testProp); - TS_ASSERT_EQUALS( - testProp->firstTime(), - DateAndTimeHelpers::createFromISO8601("2013-12-18T13:40:00")); + TS_ASSERT_EQUALS(testProp->firstTime(), + DateAndTime("2013-12-18T13:40:00")); TS_ASSERT_DELTA(testProp->firstValue(), expectedValue, 1e-5); } // cleanup diff --git a/Framework/Algorithms/test/AddTimeSeriesLogTest.h b/Framework/Algorithms/test/AddTimeSeriesLogTest.h index 2814df67e08..4ca06435658 100644 --- a/Framework/Algorithms/test/AddTimeSeriesLogTest.h +++ b/Framework/Algorithms/test/AddTimeSeriesLogTest.h @@ -1,13 +1,10 @@ #ifndef MANTID_ALGORITHMS_ADDTIMESERIESLOGTEST_H_ #define MANTID_ALGORITHMS_ADDTIMESERIESLOGTEST_H_ +#include <cxxtest/TestSuite.h> #include "MantidAlgorithms/AddTimeSeriesLog.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/TimeSeriesProperty.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" -#include <cxxtest/TestSuite.h> - -using namespace Mantid::Types; class AddTimeSeriesLogTest : public CxxTest::TestSuite { private: @@ -156,6 +153,7 @@ private: const std::string &logName, const std::string &logTime, const T logValue, const size_t position) { + using Mantid::Types::Core::DateAndTime; using Mantid::Kernel::TimeSeriesProperty; const auto &run = testWS->run(); @@ -170,8 +168,7 @@ private: auto times = timeSeries->timesAsVector(); TS_ASSERT(times.size() >= position + 1); auto values = timeSeries->valuesAsVector(); - TS_ASSERT_EQUALS(DateAndTimeHelpers::createFromISO8601(logTime), - times[position]); + TS_ASSERT_EQUALS(DateAndTime(logTime), times[position]); TS_ASSERT(values.size() >= position + 1); TS_ASSERT_EQUALS(logValue, values[position]); diff --git a/Framework/Algorithms/test/AppendSpectraTest.h b/Framework/Algorithms/test/AppendSpectraTest.h index 548f722ef82..2a5669762a0 100644 --- a/Framework/Algorithms/test/AppendSpectraTest.h +++ b/Framework/Algorithms/test/AppendSpectraTest.h @@ -7,7 +7,6 @@ #include "MantidAPI/SpectrumInfo.h" #include "MantidAlgorithms/AppendSpectra.h" #include "MantidDataHandling/LoadRaw3.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/TimeSeriesProperty.h" #include "MantidTestHelpers/InstrumentCreationHelper.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" @@ -18,7 +17,7 @@ using namespace Mantid::Algorithms; using namespace Mantid::API; using namespace Mantid::Kernel; using namespace Mantid::DataObjects; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; class AppendSpectraTest : public CxxTest::TestSuite { public: @@ -185,13 +184,11 @@ public: ""); auto ws1Log = new TimeSeriesProperty<std::string>("aLog"); - ws1Log->addValue( - DateAndTimeHelpers::createFromISO8601("2014-06-19T16:40:00"), "Hello"); + ws1Log->addValue(DateAndTime("2014-06-19T16:40:00"), "Hello"); ws1->mutableRun().addLogData(ws1Log); auto ws2Log = new TimeSeriesProperty<std::string>("aLog"); - ws2Log->addValue( - DateAndTimeHelpers::createFromISO8601("2014-06-19T16:40:10"), "World"); + ws2Log->addValue(DateAndTime("2014-06-19T16:40:10"), "World"); ws2->mutableRun().addLogData(ws2Log); AnalysisDataService::Instance().addOrReplace(ws1Name, ws1); @@ -413,7 +410,7 @@ private: TS_ASSERT(appendSpectra->isExecuted()); } /** Creates a 2D workspace with 5 histograms - */ + */ void createWorkspaceWithAxisAndLabel(const std::string outputName, const std::string &axisType, const std::string axisValue) { diff --git a/Framework/Algorithms/test/AverageLogDataTest.h b/Framework/Algorithms/test/AverageLogDataTest.h index 17cff239856..c3e497ba59b 100644 --- a/Framework/Algorithms/test/AverageLogDataTest.h +++ b/Framework/Algorithms/test/AverageLogDataTest.h @@ -4,7 +4,6 @@ #include <cxxtest/TestSuite.h> #include "MantidAlgorithms/AverageLogData.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/TimeSeriesProperty.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" @@ -115,8 +114,7 @@ private: inputWS = "AverageLogDataTestWS"; Mantid::DataObjects::Workspace2D_sptr w = WorkspaceCreationHelper::create2DWorkspace(1, 1); - auto run_start = Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2010-01-01T00:00:00"); + Mantid::Types::Core::DateAndTime run_start("2010-01-01T00:00:00"); Mantid::Kernel::TimeSeriesProperty<double> *pc, *p1; pc = new Mantid::Kernel::TimeSeriesProperty<double>("proton_charge"); pc->setUnits("picoCoulomb"); diff --git a/Framework/Algorithms/test/CalculateCountRateTest.h b/Framework/Algorithms/test/CalculateCountRateTest.h index 093b3e68949..4c7da529144 100644 --- a/Framework/Algorithms/test/CalculateCountRateTest.h +++ b/Framework/Algorithms/test/CalculateCountRateTest.h @@ -5,12 +5,11 @@ #include "MantidKernel/TimeSeriesProperty.h" +#include "MantidAlgorithms/CalculateCountRate.h" #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/Axis.h" #include "MantidAPI/NumericAxis.h" -#include "MantidAlgorithms/CalculateCountRate.h" #include "MantidHistogramData/HistogramX.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" #include <numeric> @@ -173,10 +172,8 @@ public: // Check time series log outside of the data range auto pTime_log = new Kernel::TimeSeriesProperty<double>("proton_charge"); - Mantid::Types::DateAndTime first = - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2015-11-30T16:17:10"); - std::vector<Mantid::Types::DateAndTime> times(140); + Types::Core::DateAndTime first("2015-11-30T16:17:10"); + std::vector<Types::Core::DateAndTime> times(140); std::vector<double> values(140); for (size_t i = 0; i < 140; ++i) { @@ -184,7 +181,7 @@ public: values[i] = double(i); } - // DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00") + // DateAndTime("2010-01-01T00:00:00") pTime_log->addValues(times, values); sws->mutableRun().addProperty(pTime_log, true); @@ -197,8 +194,7 @@ public: TS_ASSERT(!alg.useLogDerivative()); // Check correct date and time - first = Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2010-01-01T00:00:00"); + first = Types::Core::DateAndTime("2010-01-01T00:00:00"); times.resize(240); values.resize(240); for (size_t i = 0; i < 240; ++i) { @@ -472,10 +468,8 @@ public: } auto pTime_log = new Kernel::TimeSeriesProperty<double>("proton_charge"); - Mantid::Types::DateAndTime first = - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2010-01-01T00:00:00"); - std::vector<Mantid::Types::DateAndTime> times(240); + Types::Core::DateAndTime first("2010-01-01T00:00:00"); + std::vector<Types::Core::DateAndTime> times(240); std::vector<double> values(240); for (size_t i = 0; i < values.size(); ++i) { diff --git a/Framework/Algorithms/test/ChangeLogTimeTest.h b/Framework/Algorithms/test/ChangeLogTimeTest.h index b74c9b56cb0..91da65e80c5 100644 --- a/Framework/Algorithms/test/ChangeLogTimeTest.h +++ b/Framework/Algorithms/test/ChangeLogTimeTest.h @@ -1,19 +1,19 @@ #ifndef CHANGELOGTIMETEST_H_ #define CHANGELOGTIMETEST_H_ -#include "MantidAPI/AnalysisDataService.h" -#include "MantidAPI/Run.h" +#include <cxxtest/TestSuite.h> #include "MantidAlgorithms/ChangeLogTime.h" #include "MantidDataObjects/Workspace2D.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/TimeSeriesProperty.h" -#include <cxxtest/TestSuite.h> +#include "MantidAPI/AnalysisDataService.h" +#include "MantidAPI/Run.h" using std::string; using namespace Mantid::Algorithms; using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::Kernel; +using Mantid::Types::Core::DateAndTime; class ChangeLogTimeTest : public CxxTest::TestSuite { public: @@ -48,8 +48,7 @@ private: * @param out_name Name of the output workspace. */ void verify(const std::string in_name, const std::string out_name) { - auto start = - Mantid::Types::DateAndTimeHelpers::createFromISO8601(start_str); + DateAndTime start(start_str); // create a workspace to mess with Workspace2D_sptr testWorkspace(new Workspace2D); diff --git a/Framework/Algorithms/test/ChangePulsetime2Test.h b/Framework/Algorithms/test/ChangePulsetime2Test.h index 07927b3cbba..82e15ebe9c9 100644 --- a/Framework/Algorithms/test/ChangePulsetime2Test.h +++ b/Framework/Algorithms/test/ChangePulsetime2Test.h @@ -8,13 +8,12 @@ #include "MantidAlgorithms/ChangePulsetime2.h" #include "MantidDataObjects/EventWorkspace.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" -#include "MantidKernel/DateAndTimeHelpers.h" using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::Algorithms; using namespace Mantid::DataObjects; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; namespace { EventWorkspace_sptr @@ -79,11 +78,11 @@ public: double secs; secs = DateAndTime::secondsFromDuration( out_ws->getSpectrum(wi).getEvent(0).pulseTime() - - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00")); + DateAndTime("2010-01-01T00:00:00")); TS_ASSERT_DELTA(secs, 1000.0, 1e-5); secs = DateAndTime::secondsFromDuration( out_ws->getSpectrum(wi).getEvent(2).pulseTime() - - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00")); + DateAndTime("2010-01-01T00:00:00")); TS_ASSERT_DELTA(secs, 1001.0, 1e-5); } @@ -92,11 +91,11 @@ public: double secs; secs = DateAndTime::secondsFromDuration( out_ws->getSpectrum(0).getEvent(2).pulseTime() - - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00")); + DateAndTime("2010-01-01T00:00:00")); TS_ASSERT_DELTA(secs, 1.0, 1e-5); secs = DateAndTime::secondsFromDuration( out_ws->getSpectrum(30).getEvent(2).pulseTime() - - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00")); + DateAndTime("2010-01-01T00:00:00")); TS_ASSERT_DELTA(secs, 1.0, 1e-5); } @@ -105,7 +104,7 @@ public: double secs; secs = DateAndTime::secondsFromDuration( in_ws->getSpectrum(0).getEvent(2).pulseTime() - - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00")); + DateAndTime("2010-01-01T00:00:00")); TS_ASSERT_DELTA(secs, 1.0, 1e-5); } diff --git a/Framework/Algorithms/test/ChangePulsetimeTest.h b/Framework/Algorithms/test/ChangePulsetimeTest.h index b9e7d950e79..b01856d9520 100644 --- a/Framework/Algorithms/test/ChangePulsetimeTest.h +++ b/Framework/Algorithms/test/ChangePulsetimeTest.h @@ -1,20 +1,19 @@ #ifndef MANTID_ALGORITHMS_CHANGEPULSETIMETEST_H_ #define MANTID_ALGORITHMS_CHANGEPULSETIMETEST_H_ -#include "MantidKernel/System.h" -#include "MantidKernel/Timer.h" #include <cxxtest/TestSuite.h> +#include "MantidKernel/Timer.h" +#include "MantidKernel/System.h" #include "MantidAlgorithms/ChangePulsetime.h" -#include "MantidDataObjects/EventWorkspace.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" +#include "MantidDataObjects/EventWorkspace.h" using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::Algorithms; using namespace Mantid::DataObjects; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; namespace { EventWorkspace_sptr @@ -35,7 +34,7 @@ execute_change_of_pulse_times(EventWorkspace_sptr in_ws, std::string timeOffset, EventWorkspace_sptr out_ws = alg.getProperty("OutputWorkspace"); return out_ws; } -} // namespace +} //--------------------------------------------------------------------------------- // Unit Tests @@ -77,11 +76,11 @@ public: double secs; secs = DateAndTime::secondsFromDuration( out_ws->getSpectrum(wi).getEvent(0).pulseTime() - - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00")); + DateAndTime("2010-01-01T00:00:00")); TS_ASSERT_DELTA(secs, 1000.0, 1e-5); secs = DateAndTime::secondsFromDuration( out_ws->getSpectrum(wi).getEvent(2).pulseTime() - - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00")); + DateAndTime("2010-01-01T00:00:00")); TS_ASSERT_DELTA(secs, 1001.0, 1e-5); } @@ -90,11 +89,11 @@ public: double secs; secs = DateAndTime::secondsFromDuration( out_ws->getSpectrum(0).getEvent(2).pulseTime() - - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00")); + DateAndTime("2010-01-01T00:00:00")); TS_ASSERT_DELTA(secs, 1.0, 1e-5); secs = DateAndTime::secondsFromDuration( out_ws->getSpectrum(30).getEvent(2).pulseTime() - - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00")); + DateAndTime("2010-01-01T00:00:00")); TS_ASSERT_DELTA(secs, 1.0, 1e-5); } @@ -103,7 +102,7 @@ public: double secs; secs = DateAndTime::secondsFromDuration( in_ws->getSpectrum(0).getEvent(2).pulseTime() - - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00")); + DateAndTime("2010-01-01T00:00:00")); TS_ASSERT_DELTA(secs, 1.0, 1e-5); } diff --git a/Framework/Algorithms/test/ChangeTimeZeroTest.h b/Framework/Algorithms/test/ChangeTimeZeroTest.h index 2c8a80e9cf3..88520874edf 100644 --- a/Framework/Algorithms/test/ChangeTimeZeroTest.h +++ b/Framework/Algorithms/test/ChangeTimeZeroTest.h @@ -1,26 +1,25 @@ #ifndef CHANGETIMEZEROTEST_H_ #define CHANGETIMEZEROTEST_H_ -#include "MantidKernel/System.h" -#include "MantidKernel/Timer.h" #include <cxxtest/TestSuite.h> +#include "MantidKernel/Timer.h" +#include "MantidKernel/System.h" -#include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/ScopedWorkspace.h" -#include "MantidAPI/WorkspaceGroup.h" #include "MantidAlgorithms/ChangeTimeZero.h" #include "MantidAlgorithms/CloneWorkspace.h" -#include "MantidDataObjects/EventList.h" +#include "MantidTestHelpers/WorkspaceCreationHelper.h" #include "MantidDataObjects/EventWorkspace.h" -#include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidDataObjects/EventList.h" +#include "MantidAPI/MatrixWorkspace.h" +#include "MantidAPI/WorkspaceGroup.h" #include "MantidKernel/DateTimeValidator.h" -#include "MantidTestHelpers/WorkspaceCreationHelper.h" using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::Algorithms; using namespace Mantid::DataObjects; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; namespace { @@ -29,8 +28,7 @@ const std::string boolSeriesID("boolTimeSeries"); const std::string intSeriesID("intTimeSeries"); const std::string stringSeriesID("stringTimeSeries"); const std::string stringID("string"); -DateAndTime stringPropertyTime = - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:10:00"); +DateAndTime stringPropertyTime("2010-01-01T00:10:00"); enum LogType { STANDARD, NOPROTONCHARGE }; template <typename T> @@ -155,7 +153,7 @@ MatrixWorkspace_sptr execute_change_time(MatrixWorkspace_sptr in_ws, auto out_ws = alg.getProperty("OutputWorkspace"); return out_ws; } -} // namespace +} class ChangeTimeZeroTest : public CxxTest::TestSuite { public: @@ -165,8 +163,7 @@ public: static void destroySuite(ChangeTimeZeroTest *suite) { delete suite; } ChangeTimeZeroTest() - : m_startTime( - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00")), + : m_startTime("2010-01-01T00:00:00"), m_stringPropertyTime(stringPropertyTime), m_dateTimeValidator(boost::make_shared<DateTimeValidator>()), m_length(10) {} @@ -403,12 +400,12 @@ public: } /** - * Test that the algorithm can handle a WorkspaceGroup as input without - * crashing - * We have to use the ADS to test WorkspaceGroups - * - * Need to use absolute time to test this part of validateInputs - */ + * Test that the algorithm can handle a WorkspaceGroup as input without + * crashing + * We have to use the ADS to test WorkspaceGroups + * + * Need to use absolute time to test this part of validateInputs + */ void testValidateInputsWithWSGroup() { const double timeShiftDouble = 1000; DateAndTime absoluteTimeShift = m_startTime + timeShiftDouble; @@ -475,8 +472,7 @@ private: double timeShift = relativeTimeShift; if (relativeTimeShift == 0.0) { timeShift = DateAndTime::secondsFromDuration( - DateAndTimeHelpers::createFromISO8601(absoluteTimeShift) - - m_startTime); + DateAndTime(absoluteTimeShift) - m_startTime); } MatrixWorkspace_sptr out_ws = alg.getProperty("OutputWorkspace"); @@ -527,7 +523,7 @@ private: dynamic_cast<PropertyWithValue<std::string> *>(prop); auto value = propertyWithValue->value(); if (checkDateTime(value)) { - DateAndTime newTime = DateAndTimeHelpers::createFromISO8601(value); + DateAndTime newTime(value); double secs = DateAndTime::secondsFromDuration(newTime - m_stringPropertyTime); TSM_ASSERT_DELTA("String property should have shifted time", secs, @@ -604,8 +600,7 @@ private: public: void setUp() override { - DateAndTime date = - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00"); + DateAndTime date("2010-01-01T00:00:00"); // Set up the Workspace 2D const int length2D = 3000; diff --git a/Framework/Algorithms/test/ConvertUnitsTest.h b/Framework/Algorithms/test/ConvertUnitsTest.h index 3e3e21f5a27..193763a0f14 100644 --- a/Framework/Algorithms/test/ConvertUnitsTest.h +++ b/Framework/Algorithms/test/ConvertUnitsTest.h @@ -754,9 +754,9 @@ public: } } else if (sortType == PULSETIME_SORT) { // Check directly that it is indeed increasing - Mantid::Types::DateAndTime last_x; + Mantid::Types::Core::DateAndTime last_x; for (size_t i = 0; i < el.getNumberEvents(); i++) { - Mantid::Types::DateAndTime x = el.getEvent(i).pulseTime(); + Mantid::Types::Core::DateAndTime x = el.getEvent(i).pulseTime(); TS_ASSERT(x >= last_x); last_x = x; } diff --git a/Framework/Algorithms/test/CorelliCrossCorrelateTest.h b/Framework/Algorithms/test/CorelliCrossCorrelateTest.h index 983d8377178..6647ebd9c67 100644 --- a/Framework/Algorithms/test/CorelliCrossCorrelateTest.h +++ b/Framework/Algorithms/test/CorelliCrossCorrelateTest.h @@ -3,20 +3,20 @@ #include <cxxtest/TestSuite.h> +#include "MantidAlgorithms/CorelliCrossCorrelate.h" #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/Axis.h" #include "MantidAPI/Run.h" -#include "MantidAlgorithms/CorelliCrossCorrelate.h" +#include "MantidKernel/DateAndTime.h" #include "MantidDataObjects/EventWorkspace.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/TimeSeriesProperty.h" -#include "MantidTypes/DateAndTime.h" using Mantid::Algorithms::CorelliCrossCorrelate; using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::Kernel; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; +using Mantid::Types::Event::TofEvent; class CorelliCrossCorrelateTest : public CxxTest::TestSuite { public: @@ -50,8 +50,7 @@ public: ws = AnalysisDataService::Instance().retrieveWS<EventWorkspace>( "CorelliCrossCorrelateTest_OutputWS"); - DateAndTime startTime = - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); + DateAndTime startTime("2007-11-30T16:17:00"); auto &evlist = ws->getSpectrum(0); // Add some events to the workspace. diff --git a/Framework/Algorithms/test/CreateLogPropertyTableTest.h b/Framework/Algorithms/test/CreateLogPropertyTableTest.h index 19baca43227..4f5049bbb24 100644 --- a/Framework/Algorithms/test/CreateLogPropertyTableTest.h +++ b/Framework/Algorithms/test/CreateLogPropertyTableTest.h @@ -12,7 +12,6 @@ #include "MantidTestHelpers/WorkspaceCreationHelper.h" #include "MantidKernel/TimeSeriesProperty.h" #include "MantidDataObjects/EventWorkspace.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include <string> #include <vector> @@ -22,7 +21,7 @@ using namespace Mantid::API; using namespace Mantid::Algorithms; using namespace Mantid::DataHandling; using namespace Mantid::DataObjects; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; class CreateLogPropertyTableTest : public CxxTest::TestSuite { public: diff --git a/Framework/Algorithms/test/DiffractionFocussing2Test.h b/Framework/Algorithms/test/DiffractionFocussing2Test.h index a114b8de97d..c0a0e67a775 100644 --- a/Framework/Algorithms/test/DiffractionFocussing2Test.h +++ b/Framework/Algorithms/test/DiffractionFocussing2Test.h @@ -23,7 +23,7 @@ using namespace Mantid::Kernel; using namespace Mantid::Algorithms; using namespace Mantid::DataObjects; using Mantid::HistogramData::BinEdges; -using Mantid::Types::TofEvent; +using Mantid::Types::Event::TofEvent; class DiffractionFocussing2Test : public CxxTest::TestSuite { public: diff --git a/Framework/Algorithms/test/EstimateResolutionDiffractionTest.h b/Framework/Algorithms/test/EstimateResolutionDiffractionTest.h index d47e9181260..ffaeebe8cae 100644 --- a/Framework/Algorithms/test/EstimateResolutionDiffractionTest.h +++ b/Framework/Algorithms/test/EstimateResolutionDiffractionTest.h @@ -8,7 +8,7 @@ #include "MantidAPI/Run.h" #include "MantidAlgorithms/EstimateResolutionDiffraction.h" #include "MantidDataHandling/LoadEmptyInstrument.h" -#include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/TimeSeriesProperty.h" using Mantid::Algorithms::EstimateResolutionDiffraction; @@ -18,7 +18,7 @@ using namespace Mantid; using namespace Mantid::API; using namespace Mantid::Kernel; using namespace Mantid::DataHandling; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; class EstimateResolutionDiffractionTest : public CxxTest::TestSuite { public: @@ -32,7 +32,7 @@ public: } /** Test init - */ + */ void test_Init() { EstimateResolutionDiffraction alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()); @@ -40,7 +40,7 @@ public: } /** Test POWGEN - */ + */ void test_EmptyPG3() { // Create an empty PG3 workspace MatrixWorkspace_sptr ws = createInstrument(); @@ -73,7 +73,7 @@ public: } /** Create an instrument - */ + */ API::MatrixWorkspace_sptr createInstrument() { // Create empty workspace LoadEmptyInstrument loader; diff --git a/Framework/Algorithms/test/ExportTimeSeriesLogTest.h b/Framework/Algorithms/test/ExportTimeSeriesLogTest.h index b46cb49414a..f31423345d2 100644 --- a/Framework/Algorithms/test/ExportTimeSeriesLogTest.h +++ b/Framework/Algorithms/test/ExportTimeSeriesLogTest.h @@ -243,7 +243,7 @@ public: int64_t runstoptime_ns = 3001000000; int64_t pulsetime_ns = 100000; - Mantid::Types::DateAndTime runstarttime(runstarttime_ns); + Types::Core::DateAndTime runstarttime(runstarttime_ns); eventws->mutableRun().addProperty("run_start", runstarttime.toISO8601String()); @@ -252,7 +252,7 @@ public: new Kernel::TimeSeriesProperty<double>("proton_charge"); int64_t curtime_ns = runstarttime_ns; while (curtime_ns <= runstoptime_ns) { - Mantid::Types::DateAndTime curtime(curtime_ns); + Types::Core::DateAndTime curtime(curtime_ns); protonchargelog->addValue(curtime, 1.0); curtime_ns += pulsetime_ns; } @@ -265,7 +265,7 @@ public: curtime_ns = runstarttime_ns; size_t numevents = 0; while (curtime_ns < runstoptime_ns) { - Mantid::Types::DateAndTime curtime(curtime_ns); + Types::Core::DateAndTime curtime(curtime_ns); double value = sin(M_PI * static_cast<double>(curtime_ns) / period * 0.25); sinlog->addValue(curtime, value); @@ -281,7 +281,7 @@ public: period = static_cast<double>(pulsetime_ns * 10); curtime_ns = runstarttime_ns; while (curtime_ns < runstoptime_ns) { - Mantid::Types::DateAndTime curtime(curtime_ns); + Types::Core::DateAndTime curtime(curtime_ns); double value = sin(2 * M_PI * static_cast<double>(curtime_ns) / period); coslog->addValue(curtime, value); curtime_ns += pulsetime_ns * 2; diff --git a/Framework/Algorithms/test/FilterByLogValueTest.h b/Framework/Algorithms/test/FilterByLogValueTest.h index ac714540fd3..409121756fc 100644 --- a/Framework/Algorithms/test/FilterByLogValueTest.h +++ b/Framework/Algorithms/test/FilterByLogValueTest.h @@ -3,19 +3,18 @@ #include <cxxtest/TestSuite.h> -#include "MantidAPI/AlgorithmManager.h" #include "MantidAlgorithms/FilterByLogValue.h" -#include "MantidDataObjects/EventWorkspace.h" -#include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/TimeSeriesProperty.h" +#include "MantidDataObjects/EventWorkspace.h" +#include "MantidAPI/AlgorithmManager.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" -#include "MantidTypes/DateAndTime.h" using namespace Mantid::Algorithms; using namespace Mantid::DataObjects; using namespace Mantid::Kernel; using namespace Mantid::API; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; class FilterByLogValueTest : public CxxTest::TestSuite { public: @@ -110,10 +109,9 @@ public: // Default Event Workspace with times from 0-99 EventWorkspace_sptr ew = WorkspaceCreationHelper::createEventWorkspace2(); - DateAndTime run_start = DateAndTimeHelpers::createFromISO8601( - "2010-01-01T00:00:00"); // NOTE This run_start is - // hard-coded in - // WorkspaceCreationHelper. + DateAndTime run_start("2010-01-01T00:00:00"); // NOTE This run_start is + // hard-coded in + // WorkspaceCreationHelper. TimeSeriesProperty<double> *temp; temp = new TimeSeriesProperty<double>("temp"); diff --git a/Framework/Algorithms/test/FilterByTime2Test.h b/Framework/Algorithms/test/FilterByTime2Test.h index 3fd0d151cf8..8280809e9c4 100644 --- a/Framework/Algorithms/test/FilterByTime2Test.h +++ b/Framework/Algorithms/test/FilterByTime2Test.h @@ -12,10 +12,10 @@ #include "MantidAlgorithms/FilterByTime2.h" #include "MantidDataHandling/LoadEventPreNexus2.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidDataObjects/EventWorkspace.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" using namespace Mantid::Algorithms; using namespace Mantid::DataHandling; diff --git a/Framework/Algorithms/test/FilterByTimeTest.h b/Framework/Algorithms/test/FilterByTimeTest.h index 9d3ab341108..be958db447a 100644 --- a/Framework/Algorithms/test/FilterByTimeTest.h +++ b/Framework/Algorithms/test/FilterByTimeTest.h @@ -12,17 +12,17 @@ #include "MantidAlgorithms/FilterByTime.h" #include "MantidDataHandling/LoadEventNexus.h" +#include "MantidKernel/DateAndTime.h" #include "MantidDataObjects/EventWorkspace.h" -#include "MantidKernel/DateAndTimeHelpers.h" -#include "MantidKernel/TimeSeriesProperty.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/TimeSeriesProperty.h" using namespace Mantid::Algorithms; using namespace Mantid::DataHandling; using namespace Mantid::DataObjects; using namespace Mantid::Kernel; using namespace Mantid::API; +using Mantid::Types::Core::DateAndTime; class FilterByTimeTest : public CxxTest::TestSuite { public: @@ -39,10 +39,9 @@ public: TimeSeriesProperty<double> *pc = new TimeSeriesProperty<double>("proton_charge"); pc->setUnits("picoCoulomb"); - auto run_start = Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2010-01-01T00:00:00"); // NOTE This run_start is - // hard-coded in - // WorkspaceCreationHelper. + DateAndTime run_start("2010-01-01T00:00:00"); // NOTE This run_start is + // hard-coded in + // WorkspaceCreationHelper. for (double i = 0; i < 100; i++) pc->addValue(run_start + i, 1.0); ws->mutableRun().addProperty(pc); diff --git a/Framework/Algorithms/test/FilterEventsTest.h b/Framework/Algorithms/test/FilterEventsTest.h index 16cb63b6f81..8fcd3db350e 100644 --- a/Framework/Algorithms/test/FilterEventsTest.h +++ b/Framework/Algorithms/test/FilterEventsTest.h @@ -24,7 +24,7 @@ using namespace Mantid::Algorithms; using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::Geometry; -using Mantid::Types::TofEvent; +using Types::Event::TofEvent; using namespace std; @@ -162,9 +162,9 @@ public: filteredws0->run().getProperty("splitter")); TS_ASSERT(splitter0); TS_ASSERT_EQUALS(splitter0->size(), 2); - TS_ASSERT_EQUALS(splitter0->nthTime(0), Mantid::Types::DateAndTime(runstart_i64)); + TS_ASSERT_EQUALS(splitter0->nthTime(0), Types::Core::DateAndTime(runstart_i64)); TS_ASSERT_EQUALS(splitter0->nthValue(0), 1); - TS_ASSERT_EQUALS(splitter0->nthTime(1), Mantid::Types::DateAndTime(20035000000)); + TS_ASSERT_EQUALS(splitter0->nthTime(1), Types::Core::DateAndTime(20035000000)); TS_ASSERT_EQUALS(splitter0->nthValue(1), 0); // Check Workspace group 1 @@ -182,11 +182,11 @@ public: filteredws1->run().getProperty("splitter")); TS_ASSERT(splitter1); TS_ASSERT_EQUALS(splitter1->size(), 3); - TS_ASSERT_EQUALS(splitter1->nthTime(0), Mantid::Types::DateAndTime(runstart_i64)); + TS_ASSERT_EQUALS(splitter1->nthTime(0), Types::Core::DateAndTime(runstart_i64)); TS_ASSERT_EQUALS(splitter1->nthValue(0), 0); - TS_ASSERT_EQUALS(splitter1->nthTime(1), Mantid::Types::DateAndTime(20035000000)); + TS_ASSERT_EQUALS(splitter1->nthTime(1), Types::Core::DateAndTime(20035000000)); TS_ASSERT_EQUALS(splitter1->nthValue(1), 1); - TS_ASSERT_EQUALS(splitter1->nthTime(2), Mantid::Types::DateAndTime(20195000000)); + TS_ASSERT_EQUALS(splitter1->nthTime(2), Types::Core::DateAndTime(20195000000)); TS_ASSERT_EQUALS(splitter1->nthValue(2), 0); // Check Workspace group 2 @@ -219,22 +219,22 @@ public: TS_ASSERT(splitter2); TS_ASSERT_EQUALS(splitter2->size(), 7); - TS_ASSERT_EQUALS(splitter2->nthTime(0), Mantid::Types::DateAndTime(runstart_i64)); + TS_ASSERT_EQUALS(splitter2->nthTime(0), Types::Core::DateAndTime(runstart_i64)); TS_ASSERT_EQUALS(splitter2->nthValue(0), 0); - TS_ASSERT_EQUALS(splitter2->nthTime(1), Mantid::Types::DateAndTime(20200000000)); + TS_ASSERT_EQUALS(splitter2->nthTime(1), Types::Core::DateAndTime(20200000000)); TS_ASSERT_EQUALS(splitter2->nthValue(1), 1); - TS_ASSERT_EQUALS(splitter2->nthTime(2), Mantid::Types::DateAndTime(20265000000)); + TS_ASSERT_EQUALS(splitter2->nthTime(2), Types::Core::DateAndTime(20265000000)); TS_ASSERT_EQUALS(splitter2->nthValue(2), 0); - TS_ASSERT_EQUALS(splitter2->nthTime(3), Mantid::Types::DateAndTime(20300000000)); + TS_ASSERT_EQUALS(splitter2->nthTime(3), Types::Core::DateAndTime(20300000000)); TS_ASSERT_EQUALS(splitter2->nthValue(3), 1); - TS_ASSERT_EQUALS(splitter2->nthTime(4), Mantid::Types::DateAndTime(20365000000)); + TS_ASSERT_EQUALS(splitter2->nthTime(4), Types::Core::DateAndTime(20365000000)); TS_ASSERT_EQUALS(splitter2->nthValue(4), 0); - TS_ASSERT_EQUALS(splitter2->nthTime(5), Mantid::Types::DateAndTime(20400000000)); + TS_ASSERT_EQUALS(splitter2->nthTime(5), Types::Core::DateAndTime(20400000000)); TS_ASSERT_EQUALS(splitter2->nthValue(5), 1); - TS_ASSERT_EQUALS(splitter2->nthTime(6), Mantid::Types::DateAndTime(20465000000)); + TS_ASSERT_EQUALS(splitter2->nthTime(6), Types::Core::DateAndTime(20465000000)); TS_ASSERT_EQUALS(splitter2->nthValue(6), 0); // Clean up @@ -680,11 +680,11 @@ public: filteredws0->run().getProperty("splitter")); TS_ASSERT(splitter0); TS_ASSERT_EQUALS(splitter0->size(), 2); - TS_ASSERT_EQUALS(splitter0->nthTime(0), Mantid::Types::DateAndTime(runstart_i64)); + TS_ASSERT_EQUALS(splitter0->nthTime(0), Types::Core::DateAndTime(runstart_i64)); TS_ASSERT_EQUALS(splitter0->nthValue(0), 1); TS_ASSERT_EQUALS( splitter0->nthTime(1).totalNanoseconds(), - Mantid::Types::DateAndTime(static_cast<int>(3.5e+07)).totalNanoseconds() + + Types::Core::DateAndTime(static_cast<int>(3.5e+07)).totalNanoseconds() + runstart_i64); TS_ASSERT_EQUALS(splitter0->nthValue(1), 0); @@ -703,17 +703,17 @@ public: TS_ASSERT(splitter1); TS_ASSERT_EQUALS(splitter1->size(), 3); - TS_ASSERT_EQUALS(splitter1->nthTime(0), Mantid::Types::DateAndTime(runstart_i64)); + TS_ASSERT_EQUALS(splitter1->nthTime(0), Types::Core::DateAndTime(runstart_i64)); TS_ASSERT_EQUALS(splitter1->nthValue(0), 0); TS_ASSERT_EQUALS( splitter1->nthTime(1).totalNanoseconds(), - Mantid::Types::DateAndTime(static_cast<int>(3.5e+07)).totalNanoseconds() + + Types::Core::DateAndTime(static_cast<int>(3.5e+07)).totalNanoseconds() + runstart_i64); TS_ASSERT_EQUALS(splitter1->nthValue(1), 1); TS_ASSERT_EQUALS( splitter1->nthTime(2).totalNanoseconds(), - Mantid::Types::DateAndTime(static_cast<int>(1.95e+08)).totalNanoseconds() + + Types::Core::DateAndTime(static_cast<int>(1.95e+08)).totalNanoseconds() + runstart_i64); TS_ASSERT_EQUALS(splitter1->nthValue(2), 0); @@ -734,17 +734,17 @@ public: TS_ASSERT(splitter2); TS_ASSERT_EQUALS(splitter2->size(), 7); - TS_ASSERT_EQUALS(splitter2->nthTime(0), Mantid::Types::DateAndTime(runstart_i64)); + TS_ASSERT_EQUALS(splitter2->nthTime(0), Types::Core::DateAndTime(runstart_i64)); TS_ASSERT_EQUALS(splitter2->nthValue(0), 0); TS_ASSERT_EQUALS( splitter2->nthTime(1).totalNanoseconds(), - Mantid::Types::DateAndTime(static_cast<int>(1.95e+08)).totalNanoseconds() + + Types::Core::DateAndTime(static_cast<int>(1.95e+08)).totalNanoseconds() + runstart_i64); TS_ASSERT_EQUALS(splitter2->nthValue(1), 1); TS_ASSERT_EQUALS( splitter2->nthTime(2).totalNanoseconds(), - Mantid::Types::DateAndTime(static_cast<int>(2.65e+08)).totalNanoseconds() + + Types::Core::DateAndTime(static_cast<int>(2.65e+08)).totalNanoseconds() + runstart_i64); TS_ASSERT_EQUALS(splitter2->nthValue(2), 0); @@ -873,11 +873,11 @@ public: filteredws0->run().getProperty("splitter")); TS_ASSERT(splitter0); TS_ASSERT_EQUALS(splitter0->size(), 2); - TS_ASSERT_EQUALS(splitter0->nthTime(0), Mantid::Types::DateAndTime(runstart_i64)); + TS_ASSERT_EQUALS(splitter0->nthTime(0), Types::Core::DateAndTime(runstart_i64)); TS_ASSERT_EQUALS(splitter0->nthValue(0), 1); TS_ASSERT_EQUALS( splitter0->nthTime(1).totalNanoseconds(), - Mantid::Types::DateAndTime(static_cast<int>(3.5e+07)).totalNanoseconds() + + Types::Core::DateAndTime(static_cast<int>(3.5e+07)).totalNanoseconds() + runstart_i64); TS_ASSERT_EQUALS(splitter0->nthValue(1), 0); @@ -896,17 +896,17 @@ public: TS_ASSERT(splitter1); TS_ASSERT_EQUALS(splitter1->size(), 3); - TS_ASSERT_EQUALS(splitter1->nthTime(0), Mantid::Types::DateAndTime(runstart_i64)); + TS_ASSERT_EQUALS(splitter1->nthTime(0), Types::Core::DateAndTime(runstart_i64)); TS_ASSERT_EQUALS(splitter1->nthValue(0), 0); TS_ASSERT_EQUALS( splitter1->nthTime(1).totalNanoseconds(), - Mantid::Types::DateAndTime(static_cast<int>(3.5e+07)).totalNanoseconds() + + Types::Core::DateAndTime(static_cast<int>(3.5e+07)).totalNanoseconds() + runstart_i64); TS_ASSERT_EQUALS(splitter1->nthValue(1), 1); TS_ASSERT_EQUALS( splitter1->nthTime(2).totalNanoseconds(), - Mantid::Types::DateAndTime(static_cast<int>(1.95e+08)).totalNanoseconds() + + Types::Core::DateAndTime(static_cast<int>(1.95e+08)).totalNanoseconds() + runstart_i64); TS_ASSERT_EQUALS(splitter1->nthValue(2), 0); @@ -925,17 +925,17 @@ public: TS_ASSERT(splitter2); TS_ASSERT_EQUALS(splitter2->size(), 7); - TS_ASSERT_EQUALS(splitter2->nthTime(0), Mantid::Types::DateAndTime(runstart_i64)); + TS_ASSERT_EQUALS(splitter2->nthTime(0), Types::Core::DateAndTime(runstart_i64)); TS_ASSERT_EQUALS(splitter2->nthValue(0), 0); TS_ASSERT_EQUALS( splitter2->nthTime(1).totalNanoseconds(), - Mantid::Types::DateAndTime(static_cast<int>(1.95e+08)).totalNanoseconds() + + Types::Core::DateAndTime(static_cast<int>(1.95e+08)).totalNanoseconds() + runstart_i64); TS_ASSERT_EQUALS(splitter2->nthValue(1), 1); TS_ASSERT_EQUALS( splitter2->nthTime(2).totalNanoseconds(), - Mantid::Types::DateAndTime(static_cast<int>(2.65e+08)).totalNanoseconds() + + Types::Core::DateAndTime(static_cast<int>(2.65e+08)).totalNanoseconds() + runstart_i64); TS_ASSERT_EQUALS(splitter2->nthValue(2), 0); @@ -1139,7 +1139,7 @@ public: WorkspaceCreationHelper::createEventWorkspaceWithFullInstrument(10, 1, true); - Mantid::Types::DateAndTime runstart(runstart_i64); + Types::Core::DateAndTime runstart(runstart_i64); eventWS->mutableRun().addProperty("run_start", runstart.toISO8601String(), true); @@ -1153,7 +1153,7 @@ public: for (int64_t pid = 0; pid < static_cast<int64_t>(numpulses); pid++) { int64_t pulsetime_i64 = pid * pulsedt + runstart.totalNanoseconds(); - Mantid::Types::DateAndTime pulsetime(pulsetime_i64); + Types::Core::DateAndTime pulsetime(pulsetime_i64); // add pulse time to proton charge log once and only once if (i == 0) { @@ -1189,7 +1189,7 @@ public: Kernel::make_unique<Kernel::TimeSeriesProperty<int>>("slow_int_log"); int_tsp->setUnits("meter"); for (size_t i = 0; i < 10; ++i) { - Mantid::Types::DateAndTime log_time(runstart_i64 + 5 * pulsedt * i); + Types::Core::DateAndTime log_time(runstart_i64 + 5 * pulsedt * i); int log_value = static_cast<int>(i + 1) * 20; int_tsp->addValue(log_time, log_value); } @@ -1219,7 +1219,7 @@ public: const auto &spectrumInfo = eventWS->spectrumInfo(); double l1 = spectrumInfo.l1(); - Mantid::Types::DateAndTime runstart(runstart_i64); + Types::Core::DateAndTime runstart(runstart_i64); EventList fakeevlist = fake_uniform_time_sns_data(runstart_i64, pulsedt); @@ -1313,7 +1313,7 @@ public: WorkspaceCreationHelper::createEventWorkspaceWithFullInstrument(10, 1, true); - Mantid::Types::DateAndTime runstart(runstart_i64); + Types::Core::DateAndTime runstart(runstart_i64); // Create 1000 events EventList fakeevlist = fake_uniform_time_sns_data(runstart_i64, pulsedt); @@ -1594,7 +1594,7 @@ public: for (int time = 0; time < 1000; time++) { // All pulse times from 0 to 999 in seconds - Mantid::Types::DateAndTime pulsetime( + Types::Core::DateAndTime pulsetime( static_cast<int64_t>(time * pulselength + runstart)); double tof = static_cast<double>(g1() % 1000); el += TofEvent(tof, pulsetime); diff --git a/Framework/Algorithms/test/FindDetectorsOutsideLimitsTest.h b/Framework/Algorithms/test/FindDetectorsOutsideLimitsTest.h index 0de4204c13a..64f8bca462c 100644 --- a/Framework/Algorithms/test/FindDetectorsOutsideLimitsTest.h +++ b/Framework/Algorithms/test/FindDetectorsOutsideLimitsTest.h @@ -9,7 +9,6 @@ #include "MantidDataObjects/EventWorkspace.h" #include "MantidDataObjects/Workspace2D.h" #include "MantidGeometry/Instrument.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidTestHelpers/ComponentCreationHelper.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" @@ -18,9 +17,10 @@ using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::Geometry; using namespace Mantid::Kernel; -using namespace Mantid::Types; -using Mantid::HistogramData::CountStandardDeviations; using Mantid::HistogramData::Counts; +using Mantid::HistogramData::CountStandardDeviations; +using Mantid::Types::Core::DateAndTime; +using Mantid::Types::Event::TofEvent; class FindDetectorsOutsideLimitsTest : public CxxTest::TestSuite { public: @@ -161,12 +161,11 @@ public: Instrument_sptr inst = ComponentCreationHelper::createTestInstrumentCylindrical(10); work_in->setInstrument(inst); - DateAndTime run_start = - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00"); + DateAndTime run_start("2010-01-01T00:00:00"); // Add ten more at #10 so that it fails for (int i = 0; i < 10; i++) - work_in->getSpectrum(10).addEventQuickly( - TofEvent((i + 0.5), run_start + double(i))); + work_in->getSpectrum(10) + .addEventQuickly(TofEvent((i + 0.5), run_start + double(i))); AnalysisDataService::Instance().add("testdead_in", work_in); diff --git a/Framework/Algorithms/test/GenerateEventsFilterTest.h b/Framework/Algorithms/test/GenerateEventsFilterTest.h index 3d6f4fba570..e3885f7b159 100644 --- a/Framework/Algorithms/test/GenerateEventsFilterTest.h +++ b/Framework/Algorithms/test/GenerateEventsFilterTest.h @@ -1,40 +1,38 @@ #ifndef MANTID_ALGORITHMS_GENERATEEVENTSFILTERTEST_H_ #define MANTID_ALGORITHMS_GENERATEEVENTSFILTERTEST_H_ -#include <Poco/File.h> -#include <cmath> #include <cxxtest/TestSuite.h> +#include <cmath> +#include <Poco/File.h> -#include "MantidAPI/TableRow.h" #include "MantidAlgorithms/GenerateEventsFilter.h" -#include "MantidDataHandling/LoadInstrument.h" -#include "MantidDataObjects/EventList.h" #include "MantidDataObjects/EventWorkspace.h" #include "MantidDataObjects/SplittersWorkspace.h" +#include "MantidKernel/TimeSplitter.h" #include "MantidDataObjects/TableWorkspace.h" -#include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidTestHelpers/WorkspaceCreationHelper.h" #include "MantidKernel/TimeSeriesProperty.h" -#include "MantidKernel/TimeSplitter.h" +#include "MantidAPI/TableRow.h" +#include "MantidDataObjects/EventList.h" +#include "MantidDataHandling/LoadInstrument.h" #include "MantidKernel/UnitFactory.h" -#include "MantidTestHelpers/WorkspaceCreationHelper.h" using namespace Mantid; using namespace Mantid::Algorithms; using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::Kernel; -using namespace Mantid::Types; using namespace std; namespace { //---------------------------------------------------------------------------------------------- /** Create an EventWorkspace containing an integer log - * 1. Run start = 10 (s) - * 2. Run end = 22 (s) - * 3. Pulse = 0.5 (s) - * 4. Log change = 1 (s) - */ +* 1. Run start = 10 (s) +* 2. Run end = 22 (s) +* 3. Pulse = 0.5 (s) +* 4. Log change = 1 (s) +*/ EventWorkspace_sptr createEventWorkspaceIntLog() { using namespace WorkspaceCreationHelper; @@ -50,10 +48,10 @@ EventWorkspace_sptr createEventWorkspaceIntLog() { int64_t pulsetime_ns = 5 * factor / 10; int64_t logduration_ns = 1 * factor; - Mantid::Types::DateAndTime runstarttime(runstarttime_ns); + Types::Core::DateAndTime runstarttime(runstarttime_ns); eventws->mutableRun().addProperty("run_start", runstarttime.toISO8601String()); - Mantid::Types::DateAndTime runendtime(runstoptime_ns); + Types::Core::DateAndTime runendtime(runstoptime_ns); eventws->mutableRun().addProperty("run_end", runendtime.toISO8601String()); // 3. Proton charge log @@ -61,7 +59,7 @@ EventWorkspace_sptr createEventWorkspaceIntLog() { new Kernel::TimeSeriesProperty<double>("proton_charge"); int64_t curtime_ns = runstarttime_ns; while (curtime_ns <= runstoptime_ns) { - Mantid::Types::DateAndTime curtime(curtime_ns); + Types::Core::DateAndTime curtime(curtime_ns); protonchargelog->addValue(curtime, 1.0); curtime_ns += pulsetime_ns; } @@ -76,7 +74,7 @@ EventWorkspace_sptr createEventWorkspaceIntLog() { // double period = static_cast<double>(pulsetime_ns); curtime_ns = runstarttime_ns; while (curtime_ns < runstoptime_ns) { - Mantid::Types::DateAndTime curtime(curtime_ns); + Types::Core::DateAndTime curtime(curtime_ns); dummyintlog->addValue(curtime, logvalue); curtime_ns += logduration_ns; @@ -86,7 +84,7 @@ EventWorkspace_sptr createEventWorkspaceIntLog() { return eventws; } -} // namespace +} class GenerateEventsFilterTest : public CxxTest::TestSuite { public: // This pair of boilerplate methods prevent the suite being created statically @@ -141,7 +139,7 @@ public: TS_ASSERT_EQUALS(splittersws->getNumberSplitters(), 1); Kernel::SplittingInterval splitter0 = splittersws->getSplitter(0); - Mantid::Types::DateAndTime runstart(3000000000); + Types::Core::DateAndTime runstart(3000000000); TS_ASSERT_EQUALS(splitter0.start().totalNanoseconds(), runstart.totalNanoseconds() + 100); TS_ASSERT_EQUALS(splitter0.stop().totalNanoseconds(), @@ -201,14 +199,13 @@ public: std::string runstarttimestr = eventWS->run().getProperty("run_start")->value(); - DateAndTime runstarttime = - DateAndTimeHelpers::createFromISO8601(runstarttimestr); + Types::Core::DateAndTime runstarttime(runstarttimestr); int64_t runstarttime_ns = runstarttime.totalNanoseconds(); Kernel::TimeSeriesProperty<double> *protonchargelog = dynamic_cast<Kernel::TimeSeriesProperty<double> *>( eventWS->run().getProperty("proton_charge")); - Mantid::Types::DateAndTime runstoptime = Mantid::Types::DateAndTime( + Types::Core::DateAndTime runstoptime = Types::Core::DateAndTime( protonchargelog->lastTime().totalNanoseconds() + 100000); // b) First interval @@ -226,8 +223,8 @@ public: // d) Randomly Kernel::SplittingInterval splitterR = splittersws->getSplitter(40); - Mantid::Types::DateAndTime t0 = splitterR.start(); - Mantid::Types::DateAndTime tf = splitterR.stop(); + Types::Core::DateAndTime t0 = splitterR.start(); + Types::Core::DateAndTime tf = splitterR.stop(); int64_t dt_ns = tf.totalNanoseconds() - t0.totalNanoseconds(); TS_ASSERT_EQUALS(dt_ns, timeinterval_ns); int64_t dt_runtimestart = t0.totalNanoseconds() - runstarttime_ns; @@ -364,7 +361,7 @@ public: //---------------------------------------------------------------------------------------------- /** Test to generate a set of filters against an integer log - */ + */ void test_genFilterByIntegerLog() { // 1. Create input DataObjects::EventWorkspace_sptr eventWS = createEventWorkspaceIntLog(); @@ -435,7 +432,7 @@ public: //---------------------------------------------------------------------------------------------- /** Test to generate a set of filters against an integer log by using the * single value mode - */ + */ void test_genFilterByIntegerLog2() { // Create input DataObjects::EventWorkspace_sptr eventWS = createEventWorkspaceIntLog(); @@ -514,7 +511,7 @@ public: int64_t runstoptime_ns = 3001000000; int64_t pulsetime_ns = 100000; - Mantid::Types::DateAndTime runstarttime(runstarttime_ns); + Types::Core::DateAndTime runstarttime(runstarttime_ns); eventws->mutableRun().addProperty("run_start", runstarttime.toISO8601String()); @@ -523,7 +520,7 @@ public: new Kernel::TimeSeriesProperty<double>("proton_charge"); int64_t curtime_ns = runstarttime_ns; while (curtime_ns <= runstoptime_ns) { - Mantid::Types::DateAndTime curtime(curtime_ns); + Types::Core::DateAndTime curtime(curtime_ns); protonchargelog->addValue(curtime, 1.0); curtime_ns += pulsetime_ns; } @@ -537,7 +534,7 @@ public: double period = static_cast<double>(pulsetime_ns); curtime_ns = runstarttime_ns; while (curtime_ns < runstoptime_ns) { - Mantid::Types::DateAndTime curtime(curtime_ns); + Types::Core::DateAndTime curtime(curtime_ns); double value = sin(M_PI * static_cast<double>(curtime_ns) / period * 0.25); sinlog->addValue(curtime, value); @@ -551,7 +548,7 @@ public: period = static_cast<double>(pulsetime_ns * 10); curtime_ns = runstarttime_ns; while (curtime_ns < runstoptime_ns) { - Mantid::Types::DateAndTime curtime(curtime_ns); + Types::Core::DateAndTime curtime(curtime_ns); double value = sin(2 * M_PI * static_cast<double>(curtime_ns) / period); coslog->addValue(curtime, value); curtime_ns += pulsetime_ns * 2; @@ -602,7 +599,7 @@ public: TS_ASSERT_EQUALS(splittersws->x(0).size(), 2); TS_ASSERT_EQUALS(splittersws->y(0).size(), 1); - Mantid::Types::DateAndTime runstart(3000000000); + Types::Core::DateAndTime runstart(3000000000); TS_ASSERT_EQUALS(static_cast<int64_t>(splittersws->x(0)[0] * 1.E9), runstart.totalNanoseconds() + 100); TS_ASSERT_EQUALS(static_cast<int64_t>(splittersws->x(0)[1] * 1.E9), @@ -661,15 +658,14 @@ public: std::string runstarttimestr = eventWS->run().getProperty("run_start")->value(); - DateAndTime runstarttime = - DateAndTimeHelpers::createFromISO8601(runstarttimestr); + Types::Core::DateAndTime runstarttime(runstarttimestr); int64_t runstarttime_ns = runstarttime.totalNanoseconds(); Kernel::TimeSeriesProperty<double> *protonchargelog = dynamic_cast<Kernel::TimeSeriesProperty<double> *>( eventWS->run().getProperty("proton_charge")); - DateAndTime runstoptime = - DateAndTime(protonchargelog->lastTime().totalNanoseconds() + 100000); + Types::Core::DateAndTime runstoptime = Types::Core::DateAndTime( + protonchargelog->lastTime().totalNanoseconds() + 100000); // First interval TS_ASSERT_EQUALS(static_cast<int64_t>(splittersws->x(0)[0] * 1.E9), @@ -687,8 +683,8 @@ public: /* d) Randomly Kernel::SplittingInterval splitterR = splittersws->getSplitter(40); - Mantid::Types::DateAndTime t0 = splitterR.start(); - Mantid::Types::DateAndTime tf = splitterR.stop(); + Types::Core::DateAndTime t0 = splitterR.start(); + Types::Core::DateAndTime tf = splitterR.stop(); int64_t dt_ns = tf.totalNanoseconds()-t0.totalNanoseconds(); TS_ASSERT_EQUALS(dt_ns, timeinterval_ns); int64_t dt_runtimestart = t0.totalNanoseconds()-runstarttime_ns; @@ -1069,14 +1065,13 @@ public: std::string runstarttimestr = eventWS->run().getProperty("run_start")->value(); - DateAndTime runstarttime = - DateAndTimeHelpers::createFromISO8601(runstarttimestr); + Types::Core::DateAndTime runstarttime(runstarttimestr); int64_t runstarttime_ns = runstarttime.totalNanoseconds(); Kernel::TimeSeriesProperty<double> *protonchargelog = dynamic_cast<Kernel::TimeSeriesProperty<double> *>( eventWS->run().getProperty("proton_charge")); - Mantid::Types::DateAndTime runstoptime = Mantid::Types::DateAndTime( + Types::Core::DateAndTime runstoptime = Types::Core::DateAndTime( protonchargelog->lastTime().totalNanoseconds() + 100000); // First 3 intervals @@ -1110,7 +1105,7 @@ public: //---------------------------------------------------------------------------------------------- /** Test that time intervals consisting solely of zero-values throws - */ + */ void test_timeIntervalsOnlyZeroValuesThrows() { // Create input Workspace & initial setup DataObjects::EventWorkspace_sptr eventWS = createEventWorkspace(); @@ -1143,7 +1138,7 @@ public: //---------------------------------------------------------------------------------------------- /** Convert the splitters stored in a matrix workspace to a vector of * SplittingInterval objects - */ + */ size_t convertMatrixSplitterToSplitters( API::MatrixWorkspace_const_sptr matrixws, std::vector<Kernel::SplittingInterval> &splitters) { @@ -1155,9 +1150,8 @@ public: for (size_t i = 0; i < vecY.size(); ++i) { if (vecY[i] >= -0.0) { // A valid time interval for Splitters - Mantid::Types::DateAndTime tstart(static_cast<int64_t>(vecX[i] * 1.E9)); - Mantid::Types::DateAndTime tstop( - static_cast<int64_t>(vecX[i + 1] * 1.E9)); + Types::Core::DateAndTime tstart(static_cast<int64_t>(vecX[i] * 1.E9)); + Types::Core::DateAndTime tstop(static_cast<int64_t>(vecX[i + 1] * 1.E9)); int wsindex = static_cast<int>(vecY[i]); Kernel::SplittingInterval ti(tstart, tstop, wsindex); diff --git a/Framework/Algorithms/test/GetAllEiTest.h b/Framework/Algorithms/test/GetAllEiTest.h index a157112b9c7..e5e7c92501d 100644 --- a/Framework/Algorithms/test/GetAllEiTest.h +++ b/Framework/Algorithms/test/GetAllEiTest.h @@ -92,7 +92,7 @@ DataObjects::Workspace2D_sptr createTestingWS(bool noLogs = false) { Kernel::make_unique<Kernel::TimeSeriesProperty<double>>("is_running"); for (int i = 0; i < 10; i++) { - auto time = Mantid::Types::DateAndTime(10 * i, 0); + auto time = Types::Core::DateAndTime(10 * i, 0); chopDelayLog->addValue(time, delay); chopSpeedLog->addValue(time, chopSpeed); isRunning->addValue(time, 1.); @@ -238,13 +238,13 @@ public: auto chopSpeed = Kernel::make_unique<Kernel::TimeSeriesProperty<double>>( "Chopper_Speed"); for (int i = 0; i < 10; i++) { - chopSpeed->addValue(Mantid::Types::DateAndTime(10000 + 10 * i, 0), 1.); + chopSpeed->addValue(Types::Core::DateAndTime(10000 + 10 * i, 0), 1.); } for (int i = 0; i < 10; i++) { - chopSpeed->addValue(Mantid::Types::DateAndTime(100 + 10 * i, 0), 10.); + chopSpeed->addValue(Types::Core::DateAndTime(100 + 10 * i, 0), 10.); } for (int i = 0; i < 10; i++) { - chopSpeed->addValue(Mantid::Types::DateAndTime(10 * i, 0), 100.); + chopSpeed->addValue(Types::Core::DateAndTime(10 * i, 0), 100.); } ws->mutableRun().addLogData(chopSpeed.release()); @@ -253,13 +253,13 @@ public: "Attempt to get log without start/stop time set should fail", m_getAllEi.getAvrgLogValue(ws, "ChopperSpeedLog"), std::runtime_error); - ws->mutableRun().setStartAndEndTime(Mantid::Types::DateAndTime(90, 0), - Mantid::Types::DateAndTime(10000, 0)); + ws->mutableRun().setStartAndEndTime(Types::Core::DateAndTime(90, 0), + Types::Core::DateAndTime(10000, 0)); double val = m_getAllEi.getAvrgLogValue(ws, "ChopperSpeedLog"); TS_ASSERT_DELTA(val, (10 * 10 + 100.) / 11., 1.e-6); - ws->mutableRun().setStartAndEndTime(Mantid::Types::DateAndTime(100, 0), - Mantid::Types::DateAndTime(10000, 0)); + ws->mutableRun().setStartAndEndTime(Types::Core::DateAndTime(100, 0), + Types::Core::DateAndTime(10000, 0)); val = m_getAllEi.getAvrgLogValue(ws, "ChopperSpeedLog"); TS_ASSERT_DELTA(val, 10., 1.e-6); @@ -270,7 +270,7 @@ public: "proton_charge"); for (int i = 0; i < 10; i++) { - auto time = Mantid::Types::DateAndTime(200 + 10 * i, 0); + auto time = Types::Core::DateAndTime(200 + 10 * i, 0); chopDelay->addValue(time, 10.); if (i < 2) { goodFram->addValue(time, 1); @@ -279,12 +279,12 @@ public: } } for (int i = 0; i < 10; i++) { - auto time = Mantid::Types::DateAndTime(100 + 10 * i, 0); + auto time = Types::Core::DateAndTime(100 + 10 * i, 0); chopDelay->addValue(time, 0.1); goodFram->addValue(time, 1); } for (int i = 0; i < 10; i++) { - auto time = Mantid::Types::DateAndTime(10 * i, 0); + auto time = Types::Core::DateAndTime(10 * i, 0); chopDelay->addValue(time, 1.); goodFram->addValue(time, 0); } @@ -304,7 +304,7 @@ public: goodFram = Kernel::make_unique<Kernel::TimeSeriesProperty<double>>( "proton_charge"); for (int i = 0; i < 10; i++) { - auto time = Mantid::Types::DateAndTime(100 + 10 * i, 0); + auto time = Types::Core::DateAndTime(100 + 10 * i, 0); goodFram->addValue(time, 1); } @@ -340,7 +340,7 @@ public: double gf(0); for (int i = 0; i < 50; i++) { - auto time = Mantid::Types::DateAndTime(10 * i, 0); + auto time = Types::Core::DateAndTime(10 * i, 0); if (i > 10 && i < 20) { chopDelay->addValue(time, 100.); chopSpeed->addValue(time, 0.); diff --git a/Framework/Algorithms/test/GetTimeSeriesLogInformationTest.h b/Framework/Algorithms/test/GetTimeSeriesLogInformationTest.h index e600725d725..a32cc68b861 100644 --- a/Framework/Algorithms/test/GetTimeSeriesLogInformationTest.h +++ b/Framework/Algorithms/test/GetTimeSeriesLogInformationTest.h @@ -36,8 +36,8 @@ DataObjects::EventWorkspace_sptr createEventWorkspace() { int64_t runstoptime_ns = 3001000000; int64_t pulsetime_ns = 100000; - Mantid::Types::DateAndTime runstarttime(runstarttime_ns); - Mantid::Types::DateAndTime runendtime(runstoptime_ns); + Types::Core::DateAndTime runstarttime(runstarttime_ns); + Types::Core::DateAndTime runendtime(runstoptime_ns); eventws->mutableRun().addProperty("run_start", runstarttime.toISO8601String()); eventws->mutableRun().addProperty("run_end", runendtime.toISO8601String()); @@ -47,7 +47,7 @@ DataObjects::EventWorkspace_sptr createEventWorkspace() { new Kernel::TimeSeriesProperty<double>("proton_charge"); int64_t curtime_ns = runstarttime_ns; while (curtime_ns <= runstoptime_ns) { - Mantid::Types::DateAndTime curtime(curtime_ns); + Types::Core::DateAndTime curtime(curtime_ns); protonchargelog->addValue(curtime, 1.0); curtime_ns += pulsetime_ns; } @@ -59,7 +59,7 @@ DataObjects::EventWorkspace_sptr createEventWorkspace() { double period = static_cast<double>(pulsetime_ns); curtime_ns = runstarttime_ns; while (curtime_ns < runstoptime_ns) { - Mantid::Types::DateAndTime curtime(curtime_ns); + Types::Core::DateAndTime curtime(curtime_ns); double value = sin(M_PI * static_cast<double>(curtime_ns) / period * 0.25); sinlog->addValue(curtime, value); curtime_ns += pulsetime_ns / 4; @@ -72,7 +72,7 @@ DataObjects::EventWorkspace_sptr createEventWorkspace() { period = static_cast<double>(pulsetime_ns * 10); curtime_ns = runstarttime_ns; while (curtime_ns < runstoptime_ns) { - Mantid::Types::DateAndTime curtime(curtime_ns); + Types::Core::DateAndTime curtime(curtime_ns); double value = sin(2 * M_PI * static_cast<double>(curtime_ns) / period); coslog->addValue(curtime, value); curtime_ns += pulsetime_ns * 2; diff --git a/Framework/Algorithms/test/ModeratorTzeroLinearTest.h b/Framework/Algorithms/test/ModeratorTzeroLinearTest.h index beaf1c707b6..0bd545712be 100644 --- a/Framework/Algorithms/test/ModeratorTzeroLinearTest.h +++ b/Framework/Algorithms/test/ModeratorTzeroLinearTest.h @@ -16,7 +16,7 @@ using namespace Mantid::API; using namespace Mantid::DataObjects; using Mantid::HistogramData::BinEdges; using Mantid::HistogramData::LinearGenerator; -using Mantid::Types::TofEvent; +using Mantid::Types::Event::TofEvent; namespace { void addToInstrument(MatrixWorkspace_sptr testWS, diff --git a/Framework/Algorithms/test/ModeratorTzeroTest.h b/Framework/Algorithms/test/ModeratorTzeroTest.h index 459baf950bb..fe6872266dc 100644 --- a/Framework/Algorithms/test/ModeratorTzeroTest.h +++ b/Framework/Algorithms/test/ModeratorTzeroTest.h @@ -19,7 +19,7 @@ using namespace Mantid::DataObjects; using namespace Mantid::Algorithms; using Mantid::HistogramData::BinEdges; using Mantid::HistogramData::LinearGenerator; -using Mantid::Types::TofEvent; +using Mantid::Types::Event::TofEvent; namespace { void AddToIndirectInstrument(MatrixWorkspace_sptr &testWS, diff --git a/Framework/Algorithms/test/NormaliseByCurrentTest.h b/Framework/Algorithms/test/NormaliseByCurrentTest.h index 822f7dc015d..d25a550c696 100644 --- a/Framework/Algorithms/test/NormaliseByCurrentTest.h +++ b/Framework/Algorithms/test/NormaliseByCurrentTest.h @@ -118,14 +118,14 @@ void addPChargeLogTo(MatrixWorkspace_sptr ws, const double pChargeAccum) { auto pchargeLog = Kernel::make_unique<Kernel::TimeSeriesProperty<double>>("proton_charge"); - const Mantid::Types::DateAndTime runstart(20000000000); + const Types::Core::DateAndTime runstart(20000000000); const int64_t pulsedt = 100 * 1000 * 1000; const size_t numpulses = 100; const double pCharge = pChargeAccum / static_cast<double>(numpulses); for (int64_t pid = 0; pid < static_cast<int64_t>(numpulses); pid++) { const int64_t pulsetime_i64 = pulsedt + runstart.totalNanoseconds(); - const Mantid::Types::DateAndTime pulsetime(pulsetime_i64); + const Types::Core::DateAndTime pulsetime(pulsetime_i64); pchargeLog->addValue(pulsetime, pCharge); } // FOR each pulse diff --git a/Framework/Algorithms/test/RebinByTimeAtSampleTest.h b/Framework/Algorithms/test/RebinByTimeAtSampleTest.h index c25495b7b65..6529dd11710 100644 --- a/Framework/Algorithms/test/RebinByTimeAtSampleTest.h +++ b/Framework/Algorithms/test/RebinByTimeAtSampleTest.h @@ -10,7 +10,7 @@ #include <cmath> using Mantid::Algorithms::RebinByTimeAtSample; -using Mantid::Types::TofEvent; +using Mantid::Types::Event::TofEvent; namespace { diff --git a/Framework/Algorithms/test/RebinByTimeBaseTest.h b/Framework/Algorithms/test/RebinByTimeBaseTest.h index d8386e34917..2468ed295b4 100644 --- a/Framework/Algorithms/test/RebinByTimeBaseTest.h +++ b/Framework/Algorithms/test/RebinByTimeBaseTest.h @@ -13,7 +13,7 @@ #include "MantidDataObjects/EventWorkspace.h" #include "MantidDataObjects/Events.h" #include "MantidDataObjects/Workspace2D.h" -#include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/Unit.h" #include "MantidKernel/WarningSuppressions.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" @@ -24,8 +24,8 @@ using namespace Mantid::Algorithms; using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::DataObjects; -using Mantid::Types::DateAndTime; -using Mantid::Types::TofEvent; +using Mantid::Types::Core::DateAndTime; +using Mantid::Types::Event::TofEvent; namespace { /** diff --git a/Framework/Algorithms/test/SANSCollimationLengthEstimatorTest.h b/Framework/Algorithms/test/SANSCollimationLengthEstimatorTest.h index 63dab68fabe..b245bc66ed8 100644 --- a/Framework/Algorithms/test/SANSCollimationLengthEstimatorTest.h +++ b/Framework/Algorithms/test/SANSCollimationLengthEstimatorTest.h @@ -1,20 +1,18 @@ #ifndef MANTID_ALGORITHMS_SANSCOLLIMATIONLENGTHESTIMATORTEST_H #define MANTID_ALGORITHMS_SANSCOLLIMATIONLENGTHESTIMATORTEST_H -#include "MantidAlgorithms/AddSampleLog.h" -#include "MantidAlgorithms/SANSCollimationLengthEstimator.h" #include <cxxtest/TestSuite.h> +#include "MantidAlgorithms/SANSCollimationLengthEstimator.h" +#include "MantidAlgorithms/AddSampleLog.h" +#include "MantidKernel/TimeSeriesProperty.h" +#include "MantidKernel/DateAndTime.h" #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/Detector.h" #include "MantidGeometry/Objects/ShapeFactory.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/LogFilter.h" -#include "MantidKernel/TimeSeriesProperty.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" -#include "MantidTypes/DateAndTime.h" using namespace Mantid::Algorithms; -using namespace Mantid::Types; using Mantid::Kernel::V3D; using namespace Mantid::Geometry; @@ -107,8 +105,7 @@ void addSampleLog(Mantid::API::MatrixWorkspace_sptr workspace, unsigned int length) { auto timeSeries = new Mantid::Kernel::TimeSeriesProperty<double>(sampleLogName); - DateAndTime startTime = - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:10:00"); + Mantid::Types::Core::DateAndTime startTime("2010-01-01T00:10:00"); timeSeries->setUnits("mm"); for (unsigned int i = 0; i < length; i++) { timeSeries->addValue(startTime + static_cast<double>(i), value); @@ -162,7 +159,7 @@ Mantid::API::MatrixWorkspace_sptr createTestWorkspace( } return ws2d; } -} // namespace +} class SANSCollimationLengthEstimatorTest : public CxxTest::TestSuite { public: diff --git a/Framework/Algorithms/test/ShiftLogTimeTest.h b/Framework/Algorithms/test/ShiftLogTimeTest.h index b31837bc464..db04df44dd8 100644 --- a/Framework/Algorithms/test/ShiftLogTimeTest.h +++ b/Framework/Algorithms/test/ShiftLogTimeTest.h @@ -1,22 +1,21 @@ #ifndef MANTID_ALGORITHMS_SHIFTLOGTIMETEST_H_ #define MANTID_ALGORITHMS_SHIFTLOGTIMETEST_H_ -#include "MantidAPI/AnalysisDataService.h" -#include "MantidAPI/Run.h" +#include <cxxtest/TestSuite.h> #include "MantidAlgorithms/ShiftLogTime.h" #include "MantidDataObjects/Workspace2D.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/System.h" -#include "MantidKernel/TimeSeriesProperty.h" #include "MantidKernel/Timer.h" -#include <cxxtest/TestSuite.h> +#include "MantidKernel/TimeSeriesProperty.h" +#include "MantidAPI/AnalysisDataService.h" +#include "MantidAPI/Run.h" using namespace Mantid; using namespace Mantid::Algorithms; using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::Kernel; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; class ShiftLogTimeTest : public CxxTest::TestSuite { public: @@ -60,7 +59,7 @@ private: */ void verify(const std::string in_name, const std::string out_name, const int shift) { - DateAndTime start = DateAndTimeHelpers::createFromISO8601(start_str); + DateAndTime start(start_str); // create a workspace to mess with Workspace2D_sptr testWorkspace(new Workspace2D); diff --git a/Framework/Algorithms/test/SortEventsTest.h b/Framework/Algorithms/test/SortEventsTest.h index 47a6ff2f414..22472987dd6 100644 --- a/Framework/Algorithms/test/SortEventsTest.h +++ b/Framework/Algorithms/test/SortEventsTest.h @@ -15,7 +15,7 @@ using namespace Mantid::DataObjects; using namespace Mantid::API; using namespace Mantid::Algorithms; using namespace Mantid::DataHandling; -using Mantid::Types::TofEvent; +using Mantid::Types::Event::TofEvent; class SortEventsTest : public CxxTest::TestSuite { public: diff --git a/Framework/Algorithms/test/SumEventsByLogValueTest.h b/Framework/Algorithms/test/SumEventsByLogValueTest.h index 2c407cf851d..2a25bb69ff4 100644 --- a/Framework/Algorithms/test/SumEventsByLogValueTest.h +++ b/Framework/Algorithms/test/SumEventsByLogValueTest.h @@ -4,7 +4,6 @@ #include <cxxtest/TestSuite.h> #include "MantidAlgorithms/SumEventsByLogValue.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/TimeSeriesProperty.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" @@ -12,7 +11,7 @@ using Mantid::Algorithms::SumEventsByLogValue; using Mantid::DataObjects::EventWorkspace_sptr; using namespace Mantid::API; using namespace Mantid::Kernel; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; class SumEventsByLogValueTest : public CxxTest::TestSuite { public: @@ -150,8 +149,7 @@ private: WorkspaceCreationHelper::createEventWorkspace(3, 1); Run &run = ws->mutableRun(); - DateAndTime run_start = - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00"); + DateAndTime run_start("2010-01-01T00:00:00"); auto dblTSP = new TimeSeriesProperty<double>("doubleProp"); dblTSP->addValue(run_start, 3.0); @@ -194,8 +192,7 @@ public: std::vector<DateAndTime> times; std::vector<int> index; std::vector<double> dbl1, dbl2; - DateAndTime startTime = - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00"); + DateAndTime startTime("2010-01-01T00:00:00"); for (int i = 0; i < 100; ++i) { times.push_back(startTime + i * 10.0); index.push_back(i); diff --git a/Framework/Algorithms/test/TOFSANSResolutionByPixelTest.h b/Framework/Algorithms/test/TOFSANSResolutionByPixelTest.h index 89438938388..755d438afd7 100644 --- a/Framework/Algorithms/test/TOFSANSResolutionByPixelTest.h +++ b/Framework/Algorithms/test/TOFSANSResolutionByPixelTest.h @@ -1,19 +1,18 @@ #ifndef TOFSANSRESOLUTIONBYPIXELTEST_H_ #define TOFSANSRESOLUTIONBYPIXELTEST_H_ +#include <cxxtest/TestSuite.h> +#include "MantidAlgorithms/TOFSANSResolutionByPixel.h" #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/Axis.h" #include "MantidAPI/DataProcessorAlgorithm.h" #include "MantidAPI/IAlgorithm.h" #include "MantidAPI/Workspace.h" -#include "MantidAlgorithms/TOFSANSResolutionByPixel.h" #include "MantidDataObjects/Workspace2D.h" -#include "MantidGeometry/Instrument.h" +#include "MantidTestHelpers/WorkspaceCreationHelper.h" #include "MantidGeometry/Objects/ShapeFactory.h" -#include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidGeometry/Instrument.h" #include "MantidKernel/TimeSeriesProperty.h" -#include "MantidTestHelpers/WorkspaceCreationHelper.h" -#include <cxxtest/TestSuite.h> #include "boost/shared_ptr.hpp" #include <stdexcept> @@ -117,9 +116,7 @@ void addSampleLog(Mantid::API::MatrixWorkspace_sptr workspace, unsigned int length) { auto timeSeries = new Mantid::Kernel::TimeSeriesProperty<double>(sampleLogName); - Mantid::Types::DateAndTime startTime = - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2010-01-01T00:10:00"); + Mantid::Types::Core::DateAndTime startTime("2010-01-01T00:10:00"); timeSeries->setUnits("mm"); for (unsigned int i = 0; i < length; i++) { timeSeries->addValue(startTime + static_cast<double>(i), value); @@ -183,7 +180,7 @@ Mantid::API::MatrixWorkspace_sptr createTestWorkspace( } return ws2d; } -} // namespace +} class TOFSANSResolutionByPixelTest : public CxxTest::TestSuite { public: diff --git a/Framework/Beamline/src/DetectorInfo.cpp b/Framework/Beamline/src/DetectorInfo.cpp index b60d9ce6e56..2a6f90f352b 100644 --- a/Framework/Beamline/src/DetectorInfo.cpp +++ b/Framework/Beamline/src/DetectorInfo.cpp @@ -159,7 +159,7 @@ size_t DetectorInfo::scanCount(const size_t index) const { /** Returns the scan interval of the detector with given index. * * The interval start and end values would typically correspond to nanoseconds - * since 1990, as in Mantid::Types::DateAndTime. */ + * since 1990, as in Types::Core::DateAndTime. */ std::pair<int64_t, int64_t> DetectorInfo::scanInterval(const std::pair<size_t, size_t> &index) const { if (!m_scanIntervals) @@ -180,7 +180,7 @@ void checkScanInterval(const std::pair<int64_t, int64_t> &interval) { /** Set the scan interval of the detector with given detector index. * * The interval start and end values would typically correspond to nanoseconds - * since 1990, as in Mantid::Types::DateAndTime. Note that it is currently not possible + * since 1990, as in Types::Core::DateAndTime. Note that it is currently not possible * to modify scan intervals for a DetectorInfo with time-dependent detectors, * i.e., time intervals must be set with this method before merging individual * scans. */ diff --git a/Framework/CMakeLists.txt b/Framework/CMakeLists.txt index b565600deab..83a789fc27d 100644 --- a/Framework/CMakeLists.txt +++ b/Framework/CMakeLists.txt @@ -70,7 +70,7 @@ add_dependencies ( check FrameworkTests ) include_directories (Types/inc) add_subdirectory (Types) -set ( MANTIDLIBS ${MANTIDLIBS} Types ) +set ( MANTIDLIBS ${MANTIDLIBS} Types) include_directories (Kernel/inc) add_subdirectory (Kernel) @@ -87,7 +87,6 @@ add_subdirectory (Indexing) include_directories (Beamline/inc) add_subdirectory (Beamline) - set ( MANTIDLIBS ${MANTIDLIBS} Parallel ) # HistogramData has header-only dependency on Kernel, so Kernel comes after. set ( MANTIDLIBS ${MANTIDLIBS} HistogramData ) diff --git a/Framework/Crystal/src/LoadIsawPeaks.cpp b/Framework/Crystal/src/LoadIsawPeaks.cpp index 3995de9a715..d943a538d11 100644 --- a/Framework/Crystal/src/LoadIsawPeaks.cpp +++ b/Framework/Crystal/src/LoadIsawPeaks.cpp @@ -70,7 +70,7 @@ int LoadIsawPeaks::confidence(Kernel::FileDescriptor &descriptor) const { throw std::logic_error(std::string("No Instrument for Peaks file")); // Date: use the current date/time if not found - Mantid::Types::DateAndTime C_experimentDate; + Types::Core::DateAndTime C_experimentDate; tag = getWord(in, false); if (tag == "Date:") getWord(in, false); @@ -147,11 +147,11 @@ std::string LoadIsawPeaks::readHeader(PeaksWorkspace_sptr outWS, throw std::logic_error(std::string("No Instrument for Peaks file")); // Date: use the current date/time if not found - Mantid::Types::DateAndTime C_experimentDate; + Types::Core::DateAndTime C_experimentDate; std::string date; tag = getWord(in, false); if (tag.empty()) - date = Mantid::Types::DateAndTime::getCurrentTime().toISO8601String(); + date = Types::Core::DateAndTime::getCurrentTime().toISO8601String(); else if (tag == "Date:") date = getWord(in, false); readToEndOfLine(in, true); diff --git a/Framework/Crystal/src/SaveIsawPeaks.cpp b/Framework/Crystal/src/SaveIsawPeaks.cpp index 56a40a4f496..2c360488177 100644 --- a/Framework/Crystal/src/SaveIsawPeaks.cpp +++ b/Framework/Crystal/src/SaveIsawPeaks.cpp @@ -151,7 +151,7 @@ void SaveIsawPeaks::exec() { // TODO: The experiment date might be more useful than the instrument date. // For now, this allows the proper instrument to be loaded back after // saving. - Mantid::Types::DateAndTime expDate = inst->getValidFromDate() + 1.0; + Types::Core::DateAndTime expDate = inst->getValidFromDate() + 1.0; out << expDate.toISO8601String() << '\n'; out << "6 L1 T0_SHIFT\n"; diff --git a/Framework/Crystal/src/SetGoniometer.cpp b/Framework/Crystal/src/SetGoniometer.cpp index 1d832290fab..5b2acd46953 100644 --- a/Framework/Crystal/src/SetGoniometer.cpp +++ b/Framework/Crystal/src/SetGoniometer.cpp @@ -88,7 +88,7 @@ void SetGoniometer::exec() { << "_FixedValue\n"; axisName = "GoniometerAxis" + Strings::toString(i) + "_FixedValue"; try { - Mantid::Types::DateAndTime now = Mantid::Types::DateAndTime::getCurrentTime(); + Types::Core::DateAndTime now = Types::Core::DateAndTime::getCurrentTime(); auto tsp = new Kernel::TimeSeriesProperty<double>(axisName); tsp->addValue(now, angle); tsp->setUnits("degree"); diff --git a/Framework/Crystal/test/CentroidPeaksTest.h b/Framework/Crystal/test/CentroidPeaksTest.h index 1b73b3a4f2d..42a0d5a74db 100644 --- a/Framework/Crystal/test/CentroidPeaksTest.h +++ b/Framework/Crystal/test/CentroidPeaksTest.h @@ -9,7 +9,6 @@ #include "MantidDataObjects/PeaksWorkspace.h" #include "MantidDataObjects/WorkspaceCreation.h" #include "MantidHistogramData/LinearGenerator.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/OptionalBool.h" #include "MantidKernel/System.h" #include "MantidKernel/Timer.h" @@ -32,7 +31,8 @@ using namespace Mantid::DataObjects; using namespace Mantid::DataHandling; using namespace Mantid::Geometry; using namespace Mantid::HistogramData; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; +using Mantid::Types::Event::TofEvent; class CentroidPeaksTest : public CxxTest::TestSuite { public: @@ -57,8 +57,7 @@ public: size_t nd = 1; // Make a random generator for each dimensions typedef boost::variate_generator<boost::mt19937 &, - boost::uniform_real<double>> - gen_t; + boost::uniform_real<double>> gen_t; gen_t *gens[1]; for (size_t d = 0; d < nd; ++d) { double min = -1.; @@ -88,8 +87,7 @@ public: // a bug retVal->populateInstrumentParameters(); - DateAndTime run_start = - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00"); + DateAndTime run_start("2010-01-01T00:00:00"); for (int pix = 0; pix < numPixels; ++pix) { auto &el = retVal->getSpectrum(pix); diff --git a/Framework/Crystal/test/NormaliseVanadiumTest.h b/Framework/Crystal/test/NormaliseVanadiumTest.h index 3331e343855..d7f35363129 100644 --- a/Framework/Crystal/test/NormaliseVanadiumTest.h +++ b/Framework/Crystal/test/NormaliseVanadiumTest.h @@ -6,7 +6,6 @@ #include "MantidDataHandling/LoadInstrument.h" #include "MantidDataObjects/EventWorkspace.h" #include "MantidHistogramData/LinearGenerator.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/OptionalBool.h" #include "MantidKernel/System.h" #include "MantidKernel/Timer.h" @@ -28,15 +27,16 @@ using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::DataHandling; using namespace Mantid::Geometry; -using namespace Mantid::Types; using Mantid::HistogramData::BinEdges; using Mantid::HistogramData::LinearGenerator; +using Mantid::Types::Core::DateAndTime; +using Mantid::Types::Event::TofEvent; namespace { /** Create an EventWorkspace containing fake data of single-crystal diffraction. - * - * @return EventWorkspace_sptr - */ +* +* @return EventWorkspace_sptr +*/ EventWorkspace_sptr createDiffractionEventWorkspace(int numEvents) { FacilityHelper::ScopedFacilities loadTESTFacility( "IDFs_for_UNIT_TESTING/UnitTestFacilities.xml", "TEST"); @@ -53,8 +53,7 @@ EventWorkspace_sptr createDiffractionEventWorkspace(int numEvents) { size_t nd = 1; // Make a random generator for each dimensions typedef boost::variate_generator<boost::mt19937 &, - boost::uniform_real<double>> - gen_t; + boost::uniform_real<double>> gen_t; gen_t *gens[1]; for (size_t d = 0; d < nd; ++d) { double min = -1.; @@ -84,8 +83,7 @@ EventWorkspace_sptr createDiffractionEventWorkspace(int numEvents) { // a bug retVal->populateInstrumentParameters(); - DateAndTime run_start = - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00"); + DateAndTime run_start("2010-01-01T00:00:00"); for (int pix = 0; pix < numPixels; pix++) { EventList &el = retVal->getSpectrum(pix); @@ -104,8 +102,9 @@ EventWorkspace_sptr createDiffractionEventWorkspace(int numEvents) { (pix % 100 - 50.5) * (pix % 100 - 50.5))); for (int i = 0; i < r; i++) { el += TofEvent( - 0.75 + binDelta * - (((*gens[0])() + (*gens[0])() + (*gens[0])()) * 2. - 3.), + 0.75 + + binDelta * + (((*gens[0])() + (*gens[0])() + (*gens[0])()) * 2. - 3.), run_start + double(i)); } } @@ -127,10 +126,10 @@ EventWorkspace_sptr createDiffractionEventWorkspace(int numEvents) { } /** Creates an instance of the NormaliseVanadium algorithm and sets its - * properties. - * - * @return NormaliseVanadium alg - */ +* properties. +* +* @return NormaliseVanadium alg +*/ IAlgorithm_sptr createAlgorithm() { int numEventsPer = 100; MatrixWorkspace_sptr inputW = createDiffractionEventWorkspace(numEventsPer); @@ -145,7 +144,7 @@ IAlgorithm_sptr createAlgorithm() { return alg; } -} // namespace +} class NormaliseVanadiumImpl : public NormaliseVanadium { public: diff --git a/Framework/Crystal/test/PeakIntegrationTest.h b/Framework/Crystal/test/PeakIntegrationTest.h index 98b17307c75..b20f054df2a 100644 --- a/Framework/Crystal/test/PeakIntegrationTest.h +++ b/Framework/Crystal/test/PeakIntegrationTest.h @@ -15,7 +15,6 @@ #include "MantidTestHelpers/FacilityHelper.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" -#include <MantidKernel/DateAndTimeHelpers.h> #include <boost/random/linear_congruential.hpp> #include <boost/random/mersenne_twister.hpp> #include <boost/random/uniform_int.hpp> @@ -33,9 +32,10 @@ using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::DataHandling; using namespace Mantid::Geometry; -using namespace Mantid::Types; using Mantid::HistogramData::BinEdges; using Mantid::HistogramData::LinearGenerator; +using Mantid::Types::Core::DateAndTime; +using Mantid::Types::Event::TofEvent; class PeakIntegrationTest : public CxxTest::TestSuite { public: @@ -60,8 +60,7 @@ public: size_t nd = 1; // Make a random generator for each dimensions typedef boost::variate_generator<boost::mt19937 &, - boost::uniform_real<double>> - gen_t; + boost::uniform_real<double>> gen_t; gen_t *gens[1]; for (size_t d = 0; d < nd; ++d) { double min = -1.; @@ -91,8 +90,7 @@ public: // a bug retVal->populateInstrumentParameters(); - DateAndTime run_start = - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00"); + DateAndTime run_start("2010-01-01T00:00:00"); for (int pix = 0; pix < numPixels; pix++) { EventList &el = retVal->getSpectrum(pix); diff --git a/Framework/DataHandling/inc/MantidDataHandling/BankPulseTimes.h b/Framework/DataHandling/inc/MantidDataHandling/BankPulseTimes.h index a90599c4a7d..b2a298aa969 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/BankPulseTimes.h +++ b/Framework/DataHandling/inc/MantidDataHandling/BankPulseTimes.h @@ -2,7 +2,7 @@ #define MANTID_KERNEL_BANKPULSETIMES_H #include "MantidKernel/Property.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include <nexus/NeXusFile.hpp> @@ -21,7 +21,7 @@ public: BankPulseTimes(::NeXus::File &file, const std::vector<int> &pNumbers); /// Constructor with vector of DateAndTime - BankPulseTimes(const std::vector<Mantid::Types::DateAndTime> ×); + BankPulseTimes(const std::vector<Mantid::Types::Core::DateAndTime> ×); /// Destructor ~BankPulseTimes(); @@ -36,7 +36,7 @@ public: size_t numPulses; /// Array of the pulse times - Mantid::Types::DateAndTime *pulseTimes; + Mantid::Types::Core::DateAndTime *pulseTimes; /// Vector of period numbers corresponding to each pulse std::vector<int> periodNumbers; diff --git a/Framework/DataHandling/inc/MantidDataHandling/EventWorkspaceCollection.h b/Framework/DataHandling/inc/MantidDataHandling/EventWorkspaceCollection.h index 0dc323baac3..5a1ad0a08da 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/EventWorkspaceCollection.h +++ b/Framework/DataHandling/inc/MantidDataHandling/EventWorkspaceCollection.h @@ -93,7 +93,7 @@ public: std::vector<size_t> getDetectorIDToWorkspaceIndexVector(Mantid::specnum_t &offset, bool dothrow) const; - Mantid::Types::DateAndTime getFirstPulseTime() const; + Types::Core::DateAndTime getFirstPulseTime() const; void setAllX(const HistogramData::BinEdges &x); size_t getNumberEvents() const; void resizeTo(const size_t size); diff --git a/Framework/DataHandling/inc/MantidDataHandling/FilterEventsByLogValuePreNexus.h b/Framework/DataHandling/inc/MantidDataHandling/FilterEventsByLogValuePreNexus.h index 0fe742ebcb4..3040fe655c7 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/FilterEventsByLogValuePreNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/FilterEventsByLogValuePreNexus.h @@ -141,7 +141,7 @@ private: void procEvents(DataObjects::EventWorkspace_sptr &workspace); void procEventsLinear(DataObjects::EventWorkspace_sptr &workspace, - std::vector<Types::TofEvent> **arrayOfVectors, + std::vector<Types::Event::TofEvent> **arrayOfVectors, DasEvent *event_buffer, size_t current_event_buffer_size, size_t fileOffset); @@ -161,7 +161,7 @@ private: void filterEvents(); /// void filterEventsLinear(DataObjects::EventWorkspace_sptr &workspace, - std::vector<Types::TofEvent> **arrayOfVectors, + std::vector<Types::Event::TofEvent> **arrayOfVectors, DasEvent *event_buffer, size_t current_event_buffer_size, size_t fileOffset); @@ -180,10 +180,10 @@ private: std::unique_ptr<Mantid::API::Progress> m_progress = nullptr; DataObjects::EventWorkspace_sptr m_localWorkspace; //< Output EventWorkspace - std::vector<int64_t> m_spectraList; ///< the list of Spectra + std::vector<int64_t> m_spectraList; ///<the list of Spectra /// The times for each pulse. - std::vector<Mantid::Types::DateAndTime> pulsetimes; + std::vector<Types::Core::DateAndTime> pulsetimes; /// The index of the first event in each pulse. std::vector<uint64_t> m_vecEventIndex; /// The proton charge on a pulse by pulse basis. @@ -202,18 +202,17 @@ private: /// Handles loading from the event file Mantid::Kernel::BinaryFile<DasEvent> *m_eventFile; std::size_t m_numEvents; ///< The number of events in the file - std::size_t m_numPulses; ///< the number of pulses - uint32_t m_numPixel; ///< the number of pixels + std::size_t m_numPulses; ///<the number of pulses + uint32_t m_numPixel; ///<the number of pixels std::size_t m_numGoodEvents; ///< The number of good events loaded std::size_t m_numErrorEvents; ///< The number of error events encountered - std::size_t m_numBadEvents; ///< The number of bad events. Part of error - ///< events - std::size_t m_numWrongdetidEvents; ///< The number of events with wrong + std::size_t m_numBadEvents; ///<The number of bad events. Part of error events + std::size_t m_numWrongdetidEvents; ///<The number of events with wrong /// detector IDs. Part of error events. - std::set<PixelType> wrongdetids; ///< set of all wrong detector IDs + std::set<PixelType> wrongdetids; ///<set of all wrong detector IDs std::map<PixelType, size_t> wrongdetidmap; - std::vector<std::vector<Mantid::Types::DateAndTime>> wrongdetid_pulsetimes; + std::vector<std::vector<Types::Core::DateAndTime>> wrongdetid_pulsetimes; std::vector<std::vector<double>> wrongdetid_tofs; /// the number of events that were ignored (not loaded) because, e.g. of only @@ -285,6 +284,6 @@ private: bool m_corretctTOF; }; -} // namespace DataHandling -} // namespace Mantid +} +} #endif /*FILTEREVENTSBYLOGVALUEPRENEXUS_H_*/ diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadANSTOHelper.h b/Framework/DataHandling/inc/MantidDataHandling/LoadANSTOHelper.h index 209edee3fcd..a9a2939b46d 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadANSTOHelper.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadANSTOHelper.h @@ -24,7 +24,7 @@ namespace DataHandling { namespace ANSTO { /// pointer to the vector of events -typedef std::vector<Types::TofEvent> *EventVector_pt; +typedef std::vector<Types::Event::TofEvent> *EventVector_pt; /// helper class to keep track of progress class ProgressTracker { diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNexus2.h b/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNexus2.h index 9227e72ff5c..b02b915af12 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNexus2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNexus2.h @@ -124,7 +124,7 @@ private: std::vector<int64_t> spectra_list; ///<the list of Spectra /// The times for each pulse. - std::vector<Mantid::Types::DateAndTime> pulsetimes; + std::vector<Types::Core::DateAndTime> pulsetimes; /// The index of the first event in each pulse. std::vector<uint64_t> event_indices; /// The proton charge on a pulse by pulse basis. @@ -153,7 +153,7 @@ private: /// detector IDs. Part of error events. std::set<PixelType> wrongdetids; ///<set of all wrong detector IDs std::map<PixelType, size_t> wrongdetidmap; - std::vector<std::vector<Mantid::Types::DateAndTime>> wrongdetid_pulsetimes; + std::vector<std::vector<Types::Core::DateAndTime>> wrongdetid_pulsetimes; std::vector<std::vector<double>> wrongdetid_tofs; /// the number of events that were ignored (not loaded) because, e.g. of only @@ -207,7 +207,7 @@ private: void procEvents(DataObjects::EventWorkspace_sptr &workspace); void procEventsLinear(DataObjects::EventWorkspace_sptr &workspace, - std::vector<Types::TofEvent> **arrayOfVectors, + std::vector<Types::Event::TofEvent> **arrayOfVectors, DasEvent *event_buffer, size_t current_event_buffer_size, size_t fileOffset, bool dbprint); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadILLDiffraction.h b/Framework/DataHandling/inc/MantidDataHandling/LoadILLDiffraction.h index 0ccb568e518..e9e59f7e91f 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadILLDiffraction.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadILLDiffraction.h @@ -4,7 +4,7 @@ #include "MantidAPI/IFileLoader.h" #include "MantidDataHandling/DllConfig.h" #include "MantidDataHandling/LoadHelper.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/V3D.h" #include "MantidNexus/NexusClasses.h" @@ -66,7 +66,7 @@ private: void init() override; void exec() override; - std::vector<Mantid::Types::DateAndTime> + std::vector<Types::Core::DateAndTime> getAbsoluteTimes(const NeXus::NXDouble &) const; std::vector<double> getAxis(const NeXus::NXDouble &) const; std::vector<double> getDurations(const NeXus::NXDouble &) const; @@ -107,7 +107,7 @@ private: std::string m_instName; ///< instrument name to load the IDF std::set<std::string> m_instNames; ///< supported instruments std::string m_fileName; ///< file name to load - Mantid::Types::DateAndTime m_startTime; ///< start time of acquisition + Types::Core::DateAndTime m_startTime; ///< start time of acquisition ScanType m_scanType; ///< NoScan, DetectorScan or OtherScan std::vector<ScannedVariables> m_scanVar; ///< holds the scan info diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadRawHelper.h b/Framework/DataHandling/inc/MantidDataHandling/LoadRawHelper.h index 52fd5f0e72a..2df915c3394 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadRawHelper.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadRawHelper.h @@ -116,10 +116,10 @@ public: API::Algorithm *const pAlg); /// Extract the start time from a raw file - static Mantid::Types::DateAndTime extractStartTime(ISISRAW *isisRaw); + static Types::Core::DateAndTime extractStartTime(ISISRAW *isisRaw); /// Extract the end time from a raw file - static Mantid::Types::DateAndTime extractEndTime(ISISRAW *isisRaw); + static Types::Core::DateAndTime extractEndTime(ISISRAW *isisRaw); protected: /// Overwrites Algorithm method. diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadSpice2D.h b/Framework/DataHandling/inc/MantidDataHandling/LoadSpice2D.h index 58ed1ccb811..2553c519928 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadSpice2D.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadSpice2D.h @@ -1,7 +1,7 @@ #ifndef MANTID_DATAHANDLING_LoadSpice2D_H #define MANTID_DATAHANDLING_LoadSpice2D_H -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidAPI/IFileLoader.h" #include "MantidDataObjects/Workspace2D.h" #include "MantidDataHandling/XmlHandler.h" @@ -120,8 +120,8 @@ private: double m_wavelength{0.0}; double m_dwavelength{0.0}; double m_sansSpiceXmlFormatVersion{0.0}; - Mantid::Types::DateAndTime m_startTime; - Mantid::Types::DateAndTime m_endTime; + Mantid::Types::Core::DateAndTime m_startTime; + Mantid::Types::Core::DateAndTime m_endTime; }; } // namespace DataHandling } // namespace Mantid diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadTOFRawNexus.h b/Framework/DataHandling/inc/MantidDataHandling/LoadTOFRawNexus.h index a1a9a8d4df0..83db10f2857 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadTOFRawNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadTOFRawNexus.h @@ -9,7 +9,7 @@ #include "MantidAPI/SpectraDetectorTypes.h" #include "MantidDataObjects/Workspace2D.h" #include "MantidNexus/NexusClasses.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include <mutex> @@ -94,7 +94,7 @@ protected: const detid2index_map &id_to_wi); /// List of the absolute time of each pulse - std::vector<Mantid::Types::DateAndTime> pulseTimes; + std::vector<Types::Core::DateAndTime> pulseTimes; /// Number of bins size_t m_numBins; diff --git a/Framework/DataHandling/inc/MantidDataHandling/StartAndEndTimeFromNexusFileExtractor.h b/Framework/DataHandling/inc/MantidDataHandling/StartAndEndTimeFromNexusFileExtractor.h index 5f9b4c0dfc3..283364975aa 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/StartAndEndTimeFromNexusFileExtractor.h +++ b/Framework/DataHandling/inc/MantidDataHandling/StartAndEndTimeFromNexusFileExtractor.h @@ -2,7 +2,7 @@ #define MANTID_DATAHANDLING_STARTANDENDTIMEFROMNEXUSFILEEXTRACTOR_H_ #include "MantidDataHandling/DllConfig.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include <string> namespace Mantid { @@ -29,9 +29,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. File change history is stored at: <https://github.com/mantidproject/mantid> Code Documentation is available at: <http://doxygen.mantidproject.org> */ -Mantid::Types::DateAndTime DLLExport +Mantid::Types::Core::DateAndTime DLLExport extractStartTime(const std::string &filename); -Mantid::Types::DateAndTime DLLExport +Mantid::Types::Core::DateAndTime DLLExport extractEndTime(const std::string &filename); } // namespace DataHandling } // namespace Mantid diff --git a/Framework/DataHandling/src/BankPulseTimes.cpp b/Framework/DataHandling/src/BankPulseTimes.cpp index 29077de4bc6..3b8f6d8fdf4 100644 --- a/Framework/DataHandling/src/BankPulseTimes.cpp +++ b/Framework/DataHandling/src/BankPulseTimes.cpp @@ -1,9 +1,7 @@ #include "MantidDataHandling/BankPulseTimes.h" -#include "MantidKernel/DateAndTimeHelpers.h" using namespace Mantid::Kernel; -using namespace Mantid::Types; - +using Mantid::Types::Core::DateAndTime; //=============================================================================================== // BankPulseTimes //=============================================================================================== @@ -23,7 +21,7 @@ BankPulseTimes::BankPulseTimes(::NeXus::File &file, file.openData("event_time_zero"); // Read the offset (time zero) file.getAttr("offset", startTime); - Mantid::Types::DateAndTime start = DateAndTimeHelpers::createFromISO8601(startTime); + Mantid::Types::Core::DateAndTime start(startTime); // Load the seconds offsets std::vector<double> seconds; file.getData(seconds); diff --git a/Framework/DataHandling/src/CreateChunkingFromInstrument.cpp b/Framework/DataHandling/src/CreateChunkingFromInstrument.cpp index 942c75314a8..f96eed456df 100644 --- a/Framework/DataHandling/src/CreateChunkingFromInstrument.cpp +++ b/Framework/DataHandling/src/CreateChunkingFromInstrument.cpp @@ -10,7 +10,6 @@ #include "MantidGeometry/IDetector.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/StringTokenizer.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include <nexus/NeXusFile.hpp> #include <nexus/NeXusException.hpp> @@ -21,7 +20,7 @@ using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::Geometry; using namespace Mantid::Kernel; -using namespace Mantid::Types; +using Types::Core::DateAndTime; using namespace std; typedef Mantid::Kernel::StringTokenizer tokenizer; @@ -312,7 +311,7 @@ Instrument_const_sptr CreateChunkingFromInstrument::getInstrument() { nxsfile.openGroup(top_entry_name, "NXentry"); nxsfile.readData("start_time", start_time); tempWS->mutableRun().addProperty( - "run_start", DateAndTimeHelpers::createFromISO8601(start_time).toISO8601String(), true); + "run_start", DateAndTime(start_time).toISO8601String(), true); // get the instrument name nxsfile.openGroup("instrument", "NXinstrument"); diff --git a/Framework/DataHandling/src/CreateSimulationWorkspace.cpp b/Framework/DataHandling/src/CreateSimulationWorkspace.cpp index 71d95ce99bd..30af1f28778 100644 --- a/Framework/DataHandling/src/CreateSimulationWorkspace.cpp +++ b/Framework/DataHandling/src/CreateSimulationWorkspace.cpp @@ -26,8 +26,8 @@ namespace { struct StartAndEndTime { - Mantid::Types::DateAndTime startTime; - Mantid::Types::DateAndTime endTime; + Mantid::Types::Core::DateAndTime startTime; + Mantid::Types::Core::DateAndTime endTime; }; StartAndEndTime getStartAndEndTimesFromRawFile(std::string filename) { @@ -50,8 +50,8 @@ StartAndEndTime getStartAndEndTimesFromRawFile(std::string filename) { } StartAndEndTime getStartAndEndTimesFromNexusFile( - std::string filename, const Mantid::Types::DateAndTime &startTimeDefault, - const Mantid::Types::DateAndTime &endTimeDefault) { + std::string filename, const Mantid::Types::Core::DateAndTime &startTimeDefault, + const Mantid::Types::Core::DateAndTime &endTimeDefault) { StartAndEndTime startAndEndTime; try { startAndEndTime.startTime = @@ -407,15 +407,15 @@ void CreateSimulationWorkspace::setStartDate( auto hasDetTableFile = !detTableFile.empty(); auto &run = workspace->mutableRun(); - Mantid::Types::DateAndTime startTime; - Mantid::Types::DateAndTime endTime; + Types::Core::DateAndTime startTime; + Types::Core::DateAndTime endTime; try { // The start and end times might not be valid, and hence can throw startTime = run.startTime(); endTime = run.endTime(); } catch (std::runtime_error &) { - startTime = Mantid::Types::DateAndTime::getCurrentTime(); - endTime = Mantid::Types::DateAndTime::getCurrentTime(); + startTime = Types::Core::DateAndTime::getCurrentTime(); + endTime = Types::Core::DateAndTime::getCurrentTime(); } if (hasDetTableFile) { diff --git a/Framework/DataHandling/src/EventWorkspaceCollection.cpp b/Framework/DataHandling/src/EventWorkspaceCollection.cpp index f8fa5aae86a..3a6f9782e32 100644 --- a/Framework/DataHandling/src/EventWorkspaceCollection.cpp +++ b/Framework/DataHandling/src/EventWorkspaceCollection.cpp @@ -212,7 +212,7 @@ EventWorkspaceCollection::getDetectorIDToWorkspaceIndexVector( return m_WsVec[0]->getDetectorIDToWorkspaceIndexVector(offset, dothrow); } -Mantid::Types::DateAndTime EventWorkspaceCollection::getFirstPulseTime() const { +Types::Core::DateAndTime EventWorkspaceCollection::getFirstPulseTime() const { return m_WsVec[0]->getFirstPulseTime(); } void EventWorkspaceCollection::setAllX(const HistogramData::BinEdges &x) { diff --git a/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp b/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp index 958f32a567a..28512fcfb87 100644 --- a/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp +++ b/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp @@ -18,7 +18,7 @@ #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/CPUTimer.h" #include "MantidKernel/ConfigService.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/FileValidator.h" #include "MantidKernel/Glob.h" #include "MantidKernel/ListValidator.h" @@ -41,7 +41,6 @@ #include <vector> // #define DBOUT -using Mantid::Types::DateAndTime; namespace Mantid { namespace DataHandling { @@ -52,12 +51,13 @@ using namespace Kernel; using namespace API; using namespace DataObjects; using namespace Geometry; +using Types::Core::DateAndTime; using boost::posix_time::ptime; using boost::posix_time::time_duration; using DataObjects::EventList; using DataObjects::EventWorkspace; using DataObjects::EventWorkspace_sptr; -using Mantid::Types::TofEvent; +using Types::Event::TofEvent; using std::cout; using std::ifstream; using std::runtime_error; @@ -1147,7 +1147,7 @@ void FilterEventsByLogValuePreNexus::procEventsLinear( // Local data structure for loaded events std::map<PixelType, size_t> local_pidindexmap; - std::vector<std::vector<Mantid::Types::DateAndTime>> local_pulsetimes; + std::vector<std::vector<Types::Core::DateAndTime>> local_pulsetimes; std::vector<std::vector<double>> local_tofs; std::set<PixelType> local_wrongdetids; @@ -1291,7 +1291,7 @@ void FilterEventsByLogValuePreNexus::procEventsLinear( size_t newindex = local_pulsetimes.size(); local_pidindexmap[pixelid] = newindex; - std::vector<Mantid::Types::DateAndTime> tempvectime; + std::vector<Types::Core::DateAndTime> tempvectime; std::vector<double> temptofs; local_pulsetimes.push_back(tempvectime); local_tofs.push_back(temptofs); @@ -1337,7 +1337,7 @@ void FilterEventsByLogValuePreNexus::procEventsLinear( size_t newindex = this->wrongdetid_pulsetimes.size(); this->wrongdetidmap[tmpid] = newindex; - std::vector<Mantid::Types::DateAndTime> vec_pulsetimes; + std::vector<Types::Core::DateAndTime> vec_pulsetimes; std::vector<double> vec_tofs; this->wrongdetid_pulsetimes.push_back(vec_pulsetimes); this->wrongdetid_tofs.push_back(vec_tofs); @@ -1750,7 +1750,7 @@ void FilterEventsByLogValuePreNexus::filterEventsLinear( // NOT CALLED AT ALL // Local data structure for loaded events std::map<PixelType, size_t> local_pidindexmap; - std::vector<std::vector<Mantid::Types::DateAndTime> > local_pulsetimes; + std::vector<std::vector<Types::Core::DateAndTime> > local_pulsetimes; std::vector<std::vector<double> > local_tofs; #endif @@ -2066,7 +2066,7 @@ void FilterEventsByLogValuePreNexus::filterEventsLinear( size_t newindex = local_pulsetimes.size(); local_pidindexmap[pixelid] = newindex; - std::vector<Mantid::Types::DateAndTime> tempvectime; + std::vector<Types::Core::DateAndTime> tempvectime; std::vector<double> temptofs; local_pulsetimes.push_back(tempvectime); local_tofs.push_back(temptofs); diff --git a/Framework/DataHandling/src/LoadBBY.cpp b/Framework/DataHandling/src/LoadBBY.cpp index 89d945bfc0b..28da02d5d76 100644 --- a/Framework/DataHandling/src/LoadBBY.cpp +++ b/Framework/DataHandling/src/LoadBBY.cpp @@ -12,7 +12,6 @@ #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/RectangularDetector.h" #include "MantidGeometry/Objects/ShapeFactory.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/OptionalBool.h" #include "MantidKernel/PropertyWithValue.h" #include "MantidKernel/UnitFactory.h" @@ -24,8 +23,6 @@ #include <Poco/TemporaryFile.h> #include <Poco/Util/PropertyFileConfiguration.h> -using namespace Mantid::Types; - namespace Mantid { namespace DataHandling { @@ -336,12 +333,11 @@ void LoadBBY::exec() { "bm_counts", static_cast<double>(frame_count) * period / 1.0e6); // static_cast<double>(instrumentInfo.bm_counts) - Types::time_duration duration = boost::posix_time::microseconds( + Types::Core::time_duration duration = boost::posix_time::microseconds( static_cast<boost::int64_t>(static_cast<double>(frame_count) * period)); - Mantid::Types::DateAndTime start_time = - DateAndTimeHelpers::createFromISO8601("2000-01-01T00:00:00"); - Mantid::Types::DateAndTime end_time(start_time + duration); + Types::Core::DateAndTime start_time("2000-01-01T00:00:00"); + Types::Core::DateAndTime end_time(start_time + duration); logManager.addProperty("start_time", start_time.toISO8601String()); logManager.addProperty("end_time", end_time.toISO8601String()); @@ -814,5 +810,5 @@ void LoadBBY::loadEvents(API::Progress &prog, const char *progMsg, } } -} // namespace DataHandling -} // namespace Mantid +} // DataHandling +} // Mantid diff --git a/Framework/DataHandling/src/LoadEventNexus.cpp b/Framework/DataHandling/src/LoadEventNexus.cpp index c834d9e43e3..591b028bd1f 100644 --- a/Framework/DataHandling/src/LoadEventNexus.cpp +++ b/Framework/DataHandling/src/LoadEventNexus.cpp @@ -42,10 +42,12 @@ namespace DataHandling { DECLARE_NEXUS_FILELOADER_ALGORITHM(LoadEventNexus) using namespace Kernel; -using namespace Kernel::DateAndTimeHelpers; +using namespace DateAndTimeHelpers; using namespace Geometry; using namespace API; using namespace DataObjects; +using Types::Core::DateAndTime; +using Types::Event::TofEvent; namespace { @@ -1187,7 +1189,7 @@ boost::shared_ptr<BankPulseTimes> LoadEventNexus::runLoadNexusLogs( Kernel::TimeSeriesProperty<double> *log = dynamic_cast<Kernel::TimeSeriesProperty<double> *>( localWorkspace->mutableRun().getProperty("proton_charge")); - std::vector<Mantid::Types::DateAndTime> temp; + std::vector<Types::Core::DateAndTime> temp; if (log) temp = log->timesAsVector(); // if (returnpulsetimes) out = new BankPulseTimes(temp); @@ -1196,13 +1198,11 @@ boost::shared_ptr<BankPulseTimes> LoadEventNexus::runLoadNexusLogs( // Use the first pulse as the run_start time. if (!temp.empty()) { - if (temp[0] < Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "1991-01-01T00:00:00")) + if (temp[0] < Types::Core::DateAndTime("1991-01-01T00:00:00")) alg.getLogger().warning() << "Found entries in the proton_charge " "sample log with invalid pulse time!\n"; - Mantid::Types::DateAndTime run_start = - localWorkspace->getFirstPulseTime(); + Types::Core::DateAndTime run_start = localWorkspace->getFirstPulseTime(); // add the start of the run as a ISO8601 date/time string. The start = // first non-zero time. // (this is used in LoadInstrument to find the right instrument file to @@ -1398,8 +1398,8 @@ void LoadEventNexus::loadEvents(API::Progress *const prog, // Default to ALL pulse times bool is_time_filtered = false; - filter_time_start = Mantid::Types::DateAndTime::minimum(); - filter_time_stop = Mantid::Types::DateAndTime::maximum(); + filter_time_start = Types::Core::DateAndTime::minimum(); + filter_time_stop = Types::Core::DateAndTime::maximum(); if (m_allBanksPulseTimes->numPulses > 0) { // If not specified, use the limits of doubles. Otherwise, convert from diff --git a/Framework/DataHandling/src/LoadEventPreNexus2.cpp b/Framework/DataHandling/src/LoadEventPreNexus2.cpp index 31e5dfc2d03..be7e96be996 100644 --- a/Framework/DataHandling/src/LoadEventPreNexus2.cpp +++ b/Framework/DataHandling/src/LoadEventPreNexus2.cpp @@ -16,7 +16,7 @@ #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/CPUTimer.h" #include "MantidKernel/ConfigService.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/FileValidator.h" #include "MantidKernel/Glob.h" #include "MantidKernel/InstrumentInfo.h" @@ -39,8 +39,6 @@ #include <Poco/File.h> #include <Poco/Path.h> -using Mantid::Types::DateAndTime; - namespace Mantid { namespace DataHandling { @@ -56,7 +54,8 @@ using boost::posix_time::time_duration; using DataObjects::EventList; using DataObjects::EventWorkspace; using DataObjects::EventWorkspace_sptr; -using Mantid::Types::TofEvent; +using Types::Event::TofEvent; +using Types::Core::DateAndTime; using std::cout; using std::ifstream; using std::runtime_error; @@ -993,7 +992,7 @@ void LoadEventPreNexus2::procEventsLinear( // Storages std::map<PixelType, size_t> local_pidindexmap; - std::vector<std::vector<Mantid::Types::DateAndTime>> local_pulsetimes; + std::vector<std::vector<Types::Core::DateAndTime>> local_pulsetimes; std::vector<std::vector<double>> local_tofs; std::set<PixelType> local_wrongdetids; @@ -1091,7 +1090,7 @@ void LoadEventPreNexus2::procEventsLinear( size_t newindex = local_pulsetimes.size(); local_pidindexmap[pid] = newindex; - std::vector<Mantid::Types::DateAndTime> tempvectime; + std::vector<Types::Core::DateAndTime> tempvectime; std::vector<double> temptofs; local_pulsetimes.push_back(tempvectime); local_tofs.push_back(temptofs); @@ -1140,7 +1139,7 @@ void LoadEventPreNexus2::procEventsLinear( size_t newindex = this->wrongdetid_pulsetimes.size(); this->wrongdetidmap[tmpid] = newindex; - std::vector<Mantid::Types::DateAndTime> temppulsetimes; + std::vector<Types::Core::DateAndTime> temppulsetimes; std::vector<double> temptofs; this->wrongdetid_pulsetimes.push_back(temppulsetimes); this->wrongdetid_tofs.push_back(temptofs); diff --git a/Framework/DataHandling/src/LoadFullprofResolution.cpp b/Framework/DataHandling/src/LoadFullprofResolution.cpp index 6f2c878642c..66c534d1001 100644 --- a/Framework/DataHandling/src/LoadFullprofResolution.cpp +++ b/Framework/DataHandling/src/LoadFullprofResolution.cpp @@ -784,7 +784,7 @@ void LoadFullprofResolution::putParametersIntoWorkspace( writer.setOptions(XMLWriter::PRETTY_PRINT); // Get current time - Mantid::Types::DateAndTime date = Mantid::Types::DateAndTime::getCurrentTime(); + Types::Core::DateAndTime date = Types::Core::DateAndTime::getCurrentTime(); std::string ISOdate = date.toISO8601String(); std::string ISOdateShort = ISOdate.substr(0, 19); // Remove fraction of seconds diff --git a/Framework/DataHandling/src/LoadIDFFromNexus.cpp b/Framework/DataHandling/src/LoadIDFFromNexus.cpp index a18d2c96125..25950914024 100644 --- a/Framework/DataHandling/src/LoadIDFFromNexus.cpp +++ b/Framework/DataHandling/src/LoadIDFFromNexus.cpp @@ -3,24 +3,22 @@ #include "MantidAPI/MatrixWorkspace.h" #include "MantidGeometry/Instrument.h" #include "MantidKernel/ConfigService.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/Strings.h" -#include <Poco/DOM/DOMParser.h> #include <Poco/DOM/Document.h> +#include <Poco/DOM/DOMParser.h> #include <Poco/DOM/Element.h> -#include <Poco/DOM/NodeIterator.h> #include <Poco/DOM/NodeList.h> +#include <Poco/DOM/NodeIterator.h> #include <Poco/File.h> #include <Poco/Path.h> #include <nexus/NeXusFile.hpp> -using Mantid::Types::DateAndTime; using Poco::XML::DOMParser; using Poco::XML::Document; using Poco::XML::Element; -using Poco::XML::NodeIterator; using Poco::XML::NodeList; +using Poco::XML::NodeIterator; namespace Mantid { namespace DataHandling { @@ -30,6 +28,7 @@ DECLARE_ALGORITHM(LoadIDFFromNexus) using namespace Kernel; using namespace API; using Geometry::Instrument; +using Types::Core::DateAndTime; /// Empty default constructor LoadIDFFromNexus::LoadIDFFromNexus() {} @@ -153,7 +152,7 @@ void LoadIDFFromNexus::exec() { * @param instName :: short name of instrument as it appears in IDF filename * etc. * @returns full path name of correction file if found else "" - */ +*/ std::string LoadIDFFromNexus::getParameterCorrectionFile(const std::string &instName) { @@ -181,18 +180,18 @@ LoadIDFFromNexus::getParameterCorrectionFile(const std::string &instName) { } /* Reads the parameter correction file and if a correction is needed output the - *parameterfile needed - * and whether it is to be appended. - * @param correction_file :: path nsame of correction file as returned by - *getParameterCorrectionFile() - * @param date :: IS8601 date string applicable: Must be full timestamp - *(timezone optional) - * @param parameter_file :: output parameter file to use or "" if none - * @param append :: output whether the parameters from parameter_file should be - *appended. - * - * @throw FileError Thrown if unable to parse XML file - */ +*parameterfile needed +* and whether it is to be appended. +* @param correction_file :: path nsame of correction file as returned by +*getParameterCorrectionFile() +* @param date :: IS8601 date string applicable: Must be full timestamp (timezone +*optional) +* @param parameter_file :: output parameter file to use or "" if none +* @param append :: output whether the parameters from parameter_file should be +*appended. +* +* @throw FileError Thrown if unable to parse XML file +*/ void LoadIDFFromNexus::readParameterCorrectionFile( const std::string &correction_file, const std::string &date, std::string ¶meter_file, bool &append) { @@ -235,8 +234,7 @@ void LoadIDFFromNexus::readParameterCorrectionFile( // Convert date to Mantid object g_log.notice() << "Date for correction file " << date << "\n"; - DateAndTime externalDate = - Mantid::Types::DateAndTimeHelpers::createFromISO8601(date); + DateAndTime externalDate(date); // Examine the XML structure obtained by parsing Poco::AutoPtr<NodeList> correctionNodeList = @@ -245,10 +243,8 @@ void LoadIDFFromNexus::readParameterCorrectionFile( // For each correction element Element *corr = dynamic_cast<Element *>(correctionNodeList->item(i)); if (corr) { - auto start = Mantid::Types::DateAndTimeHelpers::createFromISO8601( - corr->getAttribute("valid-from")); - auto end = Mantid::Types::DateAndTimeHelpers::createFromISO8601( - corr->getAttribute("valid-to")); + DateAndTime start(corr->getAttribute("valid-from")); + DateAndTime end(corr->getAttribute("valid-to")); if (start <= externalDate && externalDate <= end) { parameter_file = corr->getAttribute("file"); append = (corr->getAttribute("append") == "true"); diff --git a/Framework/DataHandling/src/LoadILLDiffraction.cpp b/Framework/DataHandling/src/LoadILLDiffraction.cpp index a98133205a6..06dcc846a1d 100644 --- a/Framework/DataHandling/src/LoadILLDiffraction.cpp +++ b/Framework/DataHandling/src/LoadILLDiffraction.cpp @@ -1,4 +1,6 @@ #include "MantidDataHandling/LoadILLDiffraction.h" +#include "MantidGeometry/Instrument/ComponentInfo.h" +#include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidAPI/FileProperty.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/RegisterFileLoader.h" @@ -6,22 +8,18 @@ #include "MantidDataHandling/H5Util.h" #include "MantidDataObjects/ScanningWorkspaceBuilder.h" #include "MantidGeometry/Instrument/ComponentHelper.h" -#include "MantidGeometry/Instrument/ComponentInfo.h" -#include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidKernel/ConfigService.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/OptionalBool.h" #include "MantidKernel/TimeSeriesProperty.h" #include "MantidKernel/make_unique.h" -#include "MantidTypes/DateAndTime.h" #include <boost/algorithm/string/predicate.hpp> #include <numeric> #include <H5Cpp.h> -#include <Poco/Path.h> #include <nexus/napi.h> - -using Mantid::Types::DateAndTime; +#include <Poco/Path.h> namespace Mantid { namespace DataHandling { @@ -31,6 +29,7 @@ using namespace Geometry; using namespace H5; using namespace Kernel; using namespace NeXus; +using Types::Core::DateAndTime; namespace { // This defines the number of physical pixels in D20 (low resolution mode) @@ -44,7 +43,7 @@ constexpr size_t NUMBER_MONITORS = 1; // This is the angular size of a pixel in degrees (in low resolution mode) constexpr double D20_PIXEL_SIZE = 0.1; constexpr double rad2deg = 180. / M_PI; -} // namespace +} // Register the algorithm into the AlgorithmFactory DECLARE_NEXUS_FILELOADER_ALGORITHM(LoadILLDiffraction) @@ -118,8 +117,8 @@ void LoadILLDiffraction::exec() { } /** - * Loads the scanned detector data - */ +* Loads the scanned detector data +*/ void LoadILLDiffraction::loadDataScan() { // open the root entry @@ -128,7 +127,7 @@ void LoadILLDiffraction::loadDataScan() { m_instName = firstEntry.getString("instrument/name"); - m_startTime = Mantid::Types::DateAndTimeHelpers::createFromISO8601( + m_startTime = DateAndTime( m_loadHelper.dateTimeInIsoFormat(firstEntry.getString("start_time"))); // read the detector data @@ -190,8 +189,8 @@ void LoadILLDiffraction::loadDataScan() { } /** - * Dumps the metadata from the whole file to SampleLogs - */ +* Dumps the metadata from the whole file to SampleLogs +*/ void LoadILLDiffraction::loadMetaData() { m_outWorkspace->mutableRun().addProperty("Facility", std::string("ILL")); @@ -250,8 +249,7 @@ void LoadILLDiffraction::initMovingWorkspace(const NXDouble &scan) { g_log.debug() << "Last time index ends at:" << (m_startTime + std::accumulate(timeDurations.begin(), timeDurations.end(), 0.0)) - .toISO8601String() - << "\n"; + .toISO8601String() << "\n"; // Angles in the NeXus files are the absolute position for tube 1 std::vector<double> tubeAngles = @@ -645,8 +643,8 @@ void LoadILLDiffraction::resolveInstrument() { } /** - * Runs LoadInstrument as child to link the non-moving instrument to workspace - */ +* Runs LoadInstrument as child to link the non-moving instrument to workspace +*/ void LoadILLDiffraction::loadStaticInstrument() { IAlgorithm_sptr loadInst = createChildAlgorithm("LoadInstrument"); loadInst->setPropertyValue("Filename", getInstrumentFilePath(m_instName)); @@ -670,9 +668,9 @@ MatrixWorkspace_sptr LoadILLDiffraction::loadEmptyInstrument() { } /** - * Rotates the detector to the 2theta0 read from the file - * @param twoTheta0Read : 2theta0 read from the file - */ +* Rotates the detector to the 2theta0 read from the file +* @param twoTheta0Read : 2theta0 read from the file +*/ void LoadILLDiffraction::moveTwoThetaZero(double twoTheta0Read) { Instrument_const_sptr instrument = m_outWorkspace->getInstrument(); IComponent_const_sptr component = instrument->getComponentByName("detector"); @@ -689,11 +687,11 @@ void LoadILLDiffraction::moveTwoThetaZero(double twoTheta0Read) { } /** - * Makes up the full path of the relevant IDF dependent on resolution mode - * @param instName : the name of the instrument (including the resolution mode - * suffix) - * @return : the full path to the corresponding IDF - */ +* Makes up the full path of the relevant IDF dependent on resolution mode +* @param instName : the name of the instrument (including the resolution mode +* suffix) +* @return : the full path to the corresponding IDF +*/ std::string LoadILLDiffraction::getInstrumentFilePath(const std::string &instName) const { diff --git a/Framework/DataHandling/src/LoadLog.cpp b/Framework/DataHandling/src/LoadLog.cpp index 10ca08f2161..0401d572300 100644 --- a/Framework/DataHandling/src/LoadLog.cpp +++ b/Framework/DataHandling/src/LoadLog.cpp @@ -39,6 +39,7 @@ using API::MatrixWorkspace_sptr; using API::WorkspaceProperty; using DataObjects::Workspace2D; using DataObjects::Workspace2D_sptr; +using Types::Core::DateAndTime; /// Empty default constructor LoadLog::LoadLog() {} @@ -476,7 +477,7 @@ bool LoadLog::isAscii(const std::string &filename) { * @returns true if the strings format matched the expected date format */ bool LoadLog::isDateTimeString(const std::string &str) const { - return Kernel::DateAndTimeHelpers::stringIsISO8601(str.substr(0, 19)); + return DateAndTimeHelpers::stringIsISO8601(str.substr(0, 19)); } /** diff --git a/Framework/DataHandling/src/LoadMuonNexus2.cpp b/Framework/DataHandling/src/LoadMuonNexus2.cpp index 3d2d6907865..f3569e203c0 100644 --- a/Framework/DataHandling/src/LoadMuonNexus2.cpp +++ b/Framework/DataHandling/src/LoadMuonNexus2.cpp @@ -34,14 +34,14 @@ namespace DataHandling { DECLARE_NEXUS_FILELOADER_ALGORITHM(LoadMuonNexus2) using namespace Kernel; -using namespace Kernel::DateAndTimeHelpers; +using namespace DateAndTimeHelpers; using namespace API; using Geometry::Instrument; using Mantid::HistogramData::BinEdges; using Mantid::HistogramData::Counts; using Mantid::HistogramData::Histogram; using namespace Mantid::NeXus; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; /// Empty default constructor LoadMuonNexus2::LoadMuonNexus2() : LoadMuonNexus() {} diff --git a/Framework/DataHandling/src/LoadNexusLogs.cpp b/Framework/DataHandling/src/LoadNexusLogs.cpp index 7bd99a97c77..adc40f53f1b 100644 --- a/Framework/DataHandling/src/LoadNexusLogs.cpp +++ b/Framework/DataHandling/src/LoadNexusLogs.cpp @@ -1,21 +1,18 @@ #include "MantidDataHandling/LoadNexusLogs.h" +#include <nexus/NeXusException.hpp> +#include "MantidKernel/TimeSeriesProperty.h" +#include "MantidKernel/ArrayProperty.h" #include "MantidAPI/FileProperty.h" #include "MantidAPI/Run.h" -#include "MantidKernel/ArrayProperty.h" -#include "MantidKernel/DateAndTimeHelpers.h" -#include "MantidKernel/TimeSeriesProperty.h" #include <locale> -#include <nexus/NeXusException.hpp> -#include <Poco/DateTimeFormat.h> +#include <Poco/Path.h> #include <Poco/DateTimeFormatter.h> #include <Poco/DateTimeParser.h> -#include <Poco/Path.h> +#include <Poco/DateTimeFormat.h> -#include "MantidDataHandling/LoadTOFRawNexus.h" #include <boost/scoped_array.hpp> - -using Mantid::Types::DateAndTime; +#include "MantidDataHandling/LoadTOFRawNexus.h" namespace Mantid { namespace DataHandling { @@ -23,12 +20,12 @@ namespace DataHandling { DECLARE_ALGORITHM(LoadNexusLogs) using namespace Kernel; -using namespace Types; -using API::FileProperty; +using API::WorkspaceProperty; using API::MatrixWorkspace; using API::MatrixWorkspace_sptr; -using API::WorkspaceProperty; +using API::FileProperty; using std::size_t; +using Types::Core::DateAndTime; // Anonymous namespace namespace { @@ -76,11 +73,11 @@ bool loadAndApplyMeasurementInfo(::NeXus::File *const file, } /** - * @brief loadAndApplyRunTitle - * @param file : Nexus::File pointer - * @param workspace : Pointer to the workspace to set logs on - * @return True only if reading and execution successful. - */ +* @brief loadAndApplyRunTitle +* @param file : Nexus::File pointer +* @param workspace : Pointer to the workspace to set logs on +* @return True only if reading and execution successful. +*/ bool loadAndApplyRunTitle(::NeXus::File *const file, API::MatrixWorkspace &workspace) { @@ -99,18 +96,18 @@ bool loadAndApplyRunTitle(::NeXus::File *const file, } /** - * Checks whether the specified character is invalid or a control - * character. If it is invalid (i.e. negative) or a control character - * the method returns true. If it is valid and not a control character - * it returns false. Additionally if the character is invalid is - * logs a warning with the property name so users are aware. - * - * @param c :: Character to check - * @param propName :: The name of the property currently being checked for - *logging - * @param log :: Reference to logger to print out to - * @return :: True if control character OR invalid. Else False - */ +* Checks whether the specified character is invalid or a control +* character. If it is invalid (i.e. negative) or a control character +* the method returns true. If it is valid and not a control character +* it returns false. Additionally if the character is invalid is +* logs a warning with the property name so users are aware. +* +* @param c :: Character to check +* @param propName :: The name of the property currently being checked for +*logging +* @param log :: Reference to logger to print out to +* @return :: True if control character OR invalid. Else False +*/ bool isControlValue(const char &c, const std::string &propName, Kernel::Logger &log) { // Have to check it falls within range accepted by c style check @@ -152,12 +149,12 @@ void LoadNexusLogs::init() { } /** Executes the algorithm. Reading in the file and creating and populating - * the output workspace - * - * @throw Exception::FileError If the Nexus file cannot be found/opened - * @throw std::invalid_argument If the optional properties are set to invalid - *values - */ +* the output workspace +* +* @throw Exception::FileError If the Nexus file cannot be found/opened +* @throw std::invalid_argument If the optional properties are set to invalid +*values +*/ void LoadNexusLogs::exec() { std::string filename = getPropertyValue("Filename"); MatrixWorkspace_sptr workspace = getProperty("Workspace"); @@ -286,10 +283,10 @@ void LoadNexusLogs::exec() { Kernel::TimeSeriesProperty<double> *pcharge = new Kernel::TimeSeriesProperty<double>("proton_charge"); std::vector<double> pval; - std::vector<Mantid::Types::DateAndTime> ptime; + std::vector<Mantid::Types::Core::DateAndTime> ptime; pval.reserve(event_frame_number.size()); ptime.reserve(event_frame_number.size()); - std::vector<Mantid::Types::DateAndTime> plogt = plog->timesAsVector(); + std::vector<Mantid::Types::Core::DateAndTime> plogt = plog->timesAsVector(); std::vector<double> plogv = plog->valuesAsVector(); for (auto number : event_frame_number) { ptime.push_back(plogt[number]); @@ -303,10 +300,10 @@ void LoadNexusLogs::exec() { try { // Read the start and end time strings file.openData("start_time"); - auto start = DateAndTimeHelpers::createFromISO8601(file.getStrData()); + Types::Core::DateAndTime start(file.getStrData()); file.closeData(); file.openData("end_time"); - auto end = DateAndTimeHelpers::createFromISO8601(file.getStrData()); + Types::Core::DateAndTime end(file.getStrData()); file.closeData(); workspace->mutableRun().setStartAndEndTime(start, end); } catch (::NeXus::Exception &) { @@ -360,7 +357,7 @@ void LoadNexusLogs::loadVetoPulses( // Load the start date/time as ISO8601 string. std::string start_time; file.getAttr("start_time", start_time); - DateAndTime start = DateAndTimeHelpers::createFromISO8601(start_time); + DateAndTime start(start_time); // Read the offsets std::vector<double> time_double; @@ -611,8 +608,7 @@ LoadNexusLogs::createTimeSeries(::NeXus::File &file, } // Convert to date and time - Mantid::Types::DateAndTime start_time = - DateAndTimeHelpers::createFromISO8601(start); + Types::Core::DateAndTime start_time = Types::Core::DateAndTime(start); std::string time_units; file.getAttr("units", time_units); if (time_units.compare("second") < 0 && time_units != "s" && @@ -689,10 +685,9 @@ LoadNexusLogs::createTimeSeries(::NeXus::File &file, } // The string may contain non-printable (i.e. control) characters, replace // these - std::replace_if( - values.begin(), values.end(), - [&](const char &c) { return isControlValue(c, prop_name, g_log); }, - ' '); + std::replace_if(values.begin(), values.end(), [&](const char &c) { + return isControlValue(c, prop_name, g_log); + }, ' '); auto tsp = new TimeSeriesProperty<std::string>(prop_name); std::vector<DateAndTime> times; DateAndTime::createVector(start_time, time_double, times); diff --git a/Framework/DataHandling/src/LoadNexusMonitors2.cpp b/Framework/DataHandling/src/LoadNexusMonitors2.cpp index daf04a7219b..c43d5e261e9 100644 --- a/Framework/DataHandling/src/LoadNexusMonitors2.cpp +++ b/Framework/DataHandling/src/LoadNexusMonitors2.cpp @@ -329,7 +329,7 @@ void LoadNexusMonitors2::exec() { // Old SNS files don't have this try { // The run_start will be loaded from the pulse times. - Mantid::Types::DateAndTime run_start(0, 0); + Types::Core::DateAndTime run_start(0, 0); run_start = m_workspace->getFirstPulseTime(); m_workspace->mutableRun().addProperty("run_start", run_start.toISO8601String(), true); @@ -796,7 +796,7 @@ void LoadNexusMonitors2::readEventMonitorEntry(NeXus::File &file, size_t i) { file.closeData(); file.openData("event_time_zero"); file.getDataCoerce(seconds); - Mantid::Types::DateAndTime pulsetime_offset; + Mantid::Types::Core::DateAndTime pulsetime_offset; { std::string startTime; file.getAttr("offset", startTime); @@ -807,8 +807,8 @@ void LoadNexusMonitors2::readEventMonitorEntry(NeXus::File &file, size_t i) { // load up the event list DataObjects::EventList &event_list = eventWS->getSpectrum(i); - Mantid::Types::DateAndTime pulsetime(0); - Mantid::Types::DateAndTime lastpulsetime(0); + Mantid::Types::Core::DateAndTime pulsetime(0); + Mantid::Types::Core::DateAndTime lastpulsetime(0); std::size_t numEvents = time_of_flight.size(); bool pulsetimesincreasing = true; size_t pulse_index(0); @@ -826,7 +826,8 @@ void LoadNexusMonitors2::readEventMonitorEntry(NeXus::File &file, size_t i) { if (pulsetime < lastpulsetime) pulsetimesincreasing = false; lastpulsetime = pulsetime; - event_list.addEventQuickly(Types::TofEvent(time_of_flight[j], pulsetime)); + event_list.addEventQuickly( + Types::Event::TofEvent(time_of_flight[j], pulsetime)); } if (pulsetimesincreasing) event_list.setSortOrder(DataObjects::PULSETIME_SORT); diff --git a/Framework/DataHandling/src/LoadNexusProcessed.cpp b/Framework/DataHandling/src/LoadNexusProcessed.cpp index 81e19171bce..58c7f6db257 100644 --- a/Framework/DataHandling/src/LoadNexusProcessed.cpp +++ b/Framework/DataHandling/src/LoadNexusProcessed.cpp @@ -20,7 +20,7 @@ #include "MantidGeometry/Instrument/Goniometer.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/BoundedValidator.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/MultiThreaded.h" #include "MantidKernel/StringTokenizer.h" #include "MantidKernel/UnitFactory.h" @@ -38,9 +38,6 @@ #include <string> #include <vector> -using Mantid::Types::DateAndTime; -using Mantid::Types::TofEvent; - namespace Mantid { namespace DataHandling { @@ -52,6 +49,8 @@ using namespace DataObjects; using namespace Kernel; using namespace API; using Geometry::Instrument_const_sptr; +using Types::Core::DateAndTime; +using Mantid::Types::Event::TofEvent; namespace { diff --git a/Framework/DataHandling/src/LoadRawHelper.cpp b/Framework/DataHandling/src/LoadRawHelper.cpp index cdb7d33c29c..ff399fd5bf4 100644 --- a/Framework/DataHandling/src/LoadRawHelper.cpp +++ b/Framework/DataHandling/src/LoadRawHelper.cpp @@ -11,7 +11,6 @@ #include "MantidGeometry/Instrument.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/ConfigService.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/Glob.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/OptionalBool.h" @@ -23,11 +22,11 @@ #include <boost/date_time/gregorian/gregorian.hpp> #include <boost/shared_ptr.hpp> -#include <Poco/DateTimeFormat.h> -#include <Poco/DateTimeParser.h> -#include <Poco/DirectoryIterator.h> #include <Poco/File.h> #include <Poco/Path.h> +#include <Poco/DirectoryIterator.h> +#include <Poco/DateTimeParser.h> +#include <Poco/DateTimeFormat.h> #include <cmath> #include <cstdio> //Required for gcc 4.4 @@ -37,7 +36,7 @@ namespace DataHandling { using namespace Kernel; using namespace API; -using namespace Types; +using Types::Core::DateAndTime; /// Constructor LoadRawHelper::LoadRawHelper() @@ -379,8 +378,8 @@ void LoadRawHelper::setWorkspaceProperty(const std::string &propertyName, */ void LoadRawHelper::setWorkspaceData( DataObjects::Workspace2D_sptr newWorkspace, - const std::vector<boost::shared_ptr<HistogramData::HistogramX>> - &timeChannelsVec, + const std::vector<boost::shared_ptr<HistogramData::HistogramX>> & + timeChannelsVec, int64_t wsIndex, specnum_t nspecNum, int64_t noTimeRegimes, int64_t lengthIn, int64_t binStart) { if (!newWorkspace) @@ -841,14 +840,14 @@ void LoadRawHelper::loadRunParameters(API::MatrixWorkspace_sptr localWorkspace, * @param isisRaw: pointer to the raw file * @return the endtime */ -Mantid::Types::DateAndTime LoadRawHelper::extractEndTime(ISISRAW *isisRaw) { +Types::Core::DateAndTime LoadRawHelper::extractEndTime(ISISRAW *isisRaw) { std::string isisDate = std::string(isisRaw->rpb.r_enddate, 11); if (isisDate[0] == ' ') isisDate[0] = '0'; - return DateAndTimeHelpers::createFromISO8601( - isisDate.substr(7, 4) + "-" + - convertMonthLabelToIntStr(isisDate.substr(3, 3)) + "-" + - isisDate.substr(0, 2) + "T" + std::string(isisRaw->rpb.r_endtime, 8)); + return DateAndTime(isisDate.substr(7, 4) + "-" + + convertMonthLabelToIntStr(isisDate.substr(3, 3)) + "-" + + isisDate.substr(0, 2) + "T" + + std::string(isisRaw->rpb.r_endtime, 8)); } /** @@ -856,14 +855,14 @@ Mantid::Types::DateAndTime LoadRawHelper::extractEndTime(ISISRAW *isisRaw) { * @param isisRaw: pointer to the raw file * @return the start time */ -Mantid::Types::DateAndTime LoadRawHelper::extractStartTime(ISISRAW *isisRaw) { +Types::Core::DateAndTime LoadRawHelper::extractStartTime(ISISRAW *isisRaw) { auto isisDate = std::string(isisRaw->hdr.hd_date, 11); if (isisDate[0] == ' ') isisDate[0] = '0'; - return DateAndTimeHelpers::createFromISO8601( - isisDate.substr(7, 4) + "-" + - convertMonthLabelToIntStr(isisDate.substr(3, 3)) + "-" + - isisDate.substr(0, 2) + "T" + std::string(isisRaw->hdr.hd_time, 8)); + return DateAndTime(isisDate.substr(7, 4) + "-" + + convertMonthLabelToIntStr(isisDate.substr(3, 3)) + "-" + + isisDate.substr(0, 2) + "T" + + std::string(isisRaw->hdr.hd_time, 8)); } /// To help transforming date stored in ISIS raw file into iso 8601 @@ -1091,8 +1090,9 @@ void LoadRawHelper::loadSpectra( for (specnum_t i = 1; i <= m_numberOfSpectra; ++i) { int64_t histToRead = i + periodTimesNSpectraP1; if ((i >= m_spec_min && i < m_spec_max) || - (m_list && find(m_spec_list.begin(), m_spec_list.end(), i) != - m_spec_list.end())) { + (m_list && + find(m_spec_list.begin(), m_spec_list.end(), i) != + m_spec_list.end())) { progress(m_prog, "Reading raw file data..."); // read spectrum from raw file @@ -1106,9 +1106,9 @@ void LoadRawHelper::loadSpectra( if (numberOfPeriods == 1) { if (++histCurrent % 100 == 0) { - m_prog = - progStart + (progEnd - progStart) * - (static_cast<double>(histCurrent) / histTotal); + m_prog = progStart + + (progEnd - progStart) * + (static_cast<double>(histCurrent) / histTotal); } interruption_point(); } diff --git a/Framework/DataHandling/src/LoadSpice2D.cpp b/Framework/DataHandling/src/LoadSpice2D.cpp index 4275c379827..cc4def975f8 100644 --- a/Framework/DataHandling/src/LoadSpice2D.cpp +++ b/Framework/DataHandling/src/LoadSpice2D.cpp @@ -10,48 +10,47 @@ #include "MantidGeometry/Instrument.h" #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/ConfigService.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/OptionalBool.h" #include "MantidKernel/Strings.h" #include "MantidKernel/TimeSeriesProperty.h" #include "MantidKernel/UnitFactory.h" -#include <boost/lexical_cast.hpp> -#include <boost/make_shared.hpp> #include <boost/regex.hpp> #include <boost/shared_array.hpp> +#include <boost/lexical_cast.hpp> +#include <boost/make_shared.hpp> #include <boost/shared_ptr.hpp> +#include <Poco/Path.h> #include <MantidKernel/StringTokenizer.h> #include <Poco/DOM/DOMParser.h> #include <Poco/DOM/Document.h> #include <Poco/DOM/Element.h> -#include <Poco/DOM/Node.h> #include <Poco/DOM/NodeList.h> +#include <Poco/DOM/Node.h> #include <Poco/DOM/Text.h> -#include <Poco/Path.h> #include <Poco/SAX/InputSource.h> #include <algorithm> #include <iostream> #include <sstream> #include <string> -#include <utility> #include <vector> +#include <utility> using Poco::XML::DOMParser; using Poco::XML::Document; using Poco::XML::Element; -using Poco::XML::Node; using Poco::XML::NodeList; +using Poco::XML::Node; using Poco::XML::Text; namespace Mantid { namespace DataHandling { -using Mantid::API::WorkspaceProperty; using Mantid::Kernel::Direction; -using namespace Mantid::Types; +using Mantid::API::WorkspaceProperty; +using Types::Core::DateAndTime; using namespace Kernel; using namespace API; using namespace Geometry; @@ -287,8 +286,7 @@ void LoadSpice2D::setWavelength(std::map<std::string, std::string> &metadata) { // 20160720: New wavelength will be a ratio // HUGLY HACK! Comparing dates... - auto changingDate = - DateAndTimeHelpers::createFromISO8601("2016-06-13 00:00:00"); + DateAndTime changingDate("2016-06-13 00:00:00"); if (m_startTime >= changingDate) { g_log.debug() << "Using wavelength spread as a ratio" << '\n'; m_dwavelength = m_wavelength * m_dwavelength; @@ -495,8 +493,8 @@ void LoadSpice2D::setTimes() { std::map<std::string, std::string> attributes = m_xmlHandler.get_attributes_from_tag("/"); - m_startTime = DateAndTimeHelpers::createFromISO8601(attributes["start_time"]); - m_endTime = DateAndTimeHelpers::createFromISO8601(attributes["end_time"]); + m_startTime = DateAndTime(attributes["start_time"]); + m_endTime = DateAndTime(attributes["end_time"]); } void LoadSpice2D::setMetadataAsRunProperties( @@ -766,5 +764,5 @@ void LoadSpice2D::setSansSpiceXmlFormatVersion( g_log.debug() << "Sans_spice_xml_format_version == " << m_sansSpiceXmlFormatVersion << "\n"; } -} // namespace DataHandling -} // namespace Mantid +} +} diff --git a/Framework/DataHandling/src/LoadSpiceAscii.cpp b/Framework/DataHandling/src/LoadSpiceAscii.cpp index ec8f12b1eb6..6e0ff9fe7e1 100644 --- a/Framework/DataHandling/src/LoadSpiceAscii.cpp +++ b/Framework/DataHandling/src/LoadSpiceAscii.cpp @@ -1,28 +1,27 @@ -#include <boost/algorithm/string.hpp> #include <fstream> +#include <boost/algorithm/string.hpp> -#include "MantidAPI/FileLoaderRegistry.h" +#include "MantidDataHandling/LoadSpiceAscii.h" #include "MantidAPI/FileProperty.h" +#include "MantidAPI/FileLoaderRegistry.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/Run.h" #include "MantidAPI/TableRow.h" #include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceProperty.h" -#include "MantidDataHandling/LoadSpiceAscii.h" #include "MantidDataObjects/TableWorkspace.h" #include "MantidKernel/ArrayProperty.h" -#include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidKernel/ArrayProperty.h" -#include <boost/algorithm/string/finder.hpp> #include <boost/algorithm/string/iter_find.hpp> +#include <boost/algorithm/string/finder.hpp> using namespace boost::algorithm; using namespace Mantid::API; using namespace Mantid::Kernel; using namespace Mantid::DataHandling; - -using Mantid::Types::DateAndTime; +using Mantid::Types::Core::DateAndTime; namespace Mantid { namespace DataHandling { @@ -140,7 +139,7 @@ void LoadSpiceAscii::init() { //---------------------------------------------------------------------------------------------- /** Exec - */ + */ void LoadSpiceAscii::exec() { // Input properties and validate std::string filename = getPropertyValue("Filename"); @@ -443,8 +442,8 @@ void LoadSpiceAscii::setupRunStartTime( // Parse property vector if (datetimeprop.size() != 4) { g_log.warning() << "Run start date and time property must contain 4 " - "strings. User only specifies " - << datetimeprop.size() << ". Set up failed." + "strings. User only specifies " << datetimeprop.size() + << ". Set up failed." << "\n"; return; } @@ -475,8 +474,7 @@ void LoadSpiceAscii::setupRunStartTime( std::string mtddatetimestr = mtddatestring + "T" + mtdtimestring; // Set up property - auto runstart = - Mantid::Types::DateAndTimeHelpers::createFromISO8601(mtddatetimestr); + DateAndTime runstart(mtddatetimestr); addProperty<std::string>(runinfows, "run_start", runstart.toISO8601String()); } diff --git a/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp b/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp index e79da6a475a..725bcfd9be1 100644 --- a/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp +++ b/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp @@ -274,7 +274,7 @@ bool LoadSpiceXML2DDet::setupSampleLogs(API::MatrixWorkspace_sptr outws) { setupSampleLogFromSpiceTable(outws, spicetablews, m_ptNumber4Log); } - Mantid::Types::DateAndTime anytime(1000); + Types::Core::DateAndTime anytime(1000); // Process 2theta bool return_true = true; @@ -833,7 +833,7 @@ void LoadSpiceXML2DDet::setupSampleLogFromSpiceTable( size_t numrows = spicetablews->rowCount(); std::vector<std::string> colnames = spicetablews->getColumnNames(); // FIXME - Shouldn't give a better value? - Mantid::Types::DateAndTime anytime(1000); + Types::Core::DateAndTime anytime(1000); bool foundlog = false; for (size_t ir = 0; ir < numrows; ++ir) { diff --git a/Framework/DataHandling/src/LoadSwans.cpp b/Framework/DataHandling/src/LoadSwans.cpp index da2b408bca1..9543a47322e 100644 --- a/Framework/DataHandling/src/LoadSwans.cpp +++ b/Framework/DataHandling/src/LoadSwans.cpp @@ -5,11 +5,11 @@ #include "MantidKernel/OptionalBool.h" #include "MantidKernel/StringTokenizer.h" +#include <map> +#include <iostream> +#include <fstream> #include <algorithm> #include <boost/tokenizer.hpp> -#include <fstream> -#include <iostream> -#include <map> namespace Mantid { namespace DataHandling { @@ -18,7 +18,7 @@ using namespace Mantid::Kernel; using namespace Mantid::Geometry; using namespace Mantid::API; using namespace Mantid::DataObjects; -using Mantid::Types::TofEvent; +using Mantid::Types::Event::TofEvent; // Register the algorithm into the AlgorithmFactory DECLARE_ALGORITHM(LoadSwans) @@ -202,9 +202,8 @@ std::vector<double> LoadSwans::loadMetaData() { if (!line.empty() && line[0] != '#') { g_log.debug() << "Metadata parsed line: " << line << '\n'; auto tokenizer = Mantid::Kernel::StringTokenizer( - line, "\t ", - Mantid::Kernel::StringTokenizer::TOK_TRIM | - Mantid::Kernel::StringTokenizer::TOK_IGNORE_EMPTY); + line, "\t ", Mantid::Kernel::StringTokenizer::TOK_TRIM | + Mantid::Kernel::StringTokenizer::TOK_IGNORE_EMPTY); for (const auto &token : tokenizer) { metadata.push_back(boost::lexical_cast<double>(token)); } diff --git a/Framework/DataHandling/src/MergeLogs.cpp b/Framework/DataHandling/src/MergeLogs.cpp index de51774dc6b..36b3b33f744 100644 --- a/Framework/DataHandling/src/MergeLogs.cpp +++ b/Framework/DataHandling/src/MergeLogs.cpp @@ -69,8 +69,8 @@ void Merge2WorkspaceLogs::mergeLogs(std::string ilogname1, Kernel::TimeSeriesProperty<double> *p1 = getTimeSeriesLog(ilogname1); Kernel::TimeSeriesProperty<double> *p2 = getTimeSeriesLog(ilogname2); - std::vector<Mantid::Types::DateAndTime> times1 = p1->timesAsVector(); - std::vector<Mantid::Types::DateAndTime> times2 = p2->timesAsVector(); + std::vector<Types::Core::DateAndTime> times1 = p1->timesAsVector(); + std::vector<Types::Core::DateAndTime> times2 = p2->timesAsVector(); auto rp = new Kernel::TimeSeriesProperty<double>(ologname); @@ -79,7 +79,7 @@ void Merge2WorkspaceLogs::mergeLogs(std::string ilogname1, size_t index2 = 0; bool icont = true; - Mantid::Types::DateAndTime tmptime; + Types::Core::DateAndTime tmptime; double tmpvalue; bool launch1 = true; ; diff --git a/Framework/DataHandling/src/ProcessBankData.cpp b/Framework/DataHandling/src/ProcessBankData.cpp index 1a6d96d1b50..181eb0095fa 100644 --- a/Framework/DataHandling/src/ProcessBankData.cpp +++ b/Framework/DataHandling/src/ProcessBankData.cpp @@ -1,6 +1,7 @@ #include "MantidDataHandling/ProcessBankData.h" using namespace Mantid::DataObjects; +using Mantid::Types::Event::TofEvent; namespace Mantid { namespace DataHandling { @@ -73,10 +74,10 @@ void ProcessBankData::run() { // override { } // Default pulse time (if none are found) - Mantid::Types::DateAndTime pulsetime; + Mantid::Types::Core::DateAndTime pulsetime; int periodNumber = 1; int periodIndex = 0; - Mantid::Types::DateAndTime lastpulsetime(0); + Mantid::Types::Core::DateAndTime lastpulsetime(0); bool pulsetimesincreasing = true; diff --git a/Framework/DataHandling/src/RenameLog.cpp b/Framework/DataHandling/src/RenameLog.cpp index 0e29d3fe5f0..e983fa4745b 100644 --- a/Framework/DataHandling/src/RenameLog.cpp +++ b/Framework/DataHandling/src/RenameLog.cpp @@ -48,7 +48,7 @@ void RenameLog::exec() { // std::cout << "Change log name\n"; timeprop->setName(newlogname); // std::cout << "Add log" << timeprop->name() << '\n'; - // std::vector<Mantid::Types::DateAndTime> newtimes = timeprop->timesAsVector(); + // std::vector<Types::Core::DateAndTime> newtimes = timeprop->timesAsVector(); // std::cout << "Entries = " << newtimes.size() << '\n'; matrixWS->mutableRun().addProperty(timeprop); } diff --git a/Framework/DataHandling/src/SaveCalFile.cpp b/Framework/DataHandling/src/SaveCalFile.cpp index 1ca32cf5492..222d25f55a8 100644 --- a/Framework/DataHandling/src/SaveCalFile.cpp +++ b/Framework/DataHandling/src/SaveCalFile.cpp @@ -1,8 +1,7 @@ -#include "MantidDataHandling/SaveCalFile.h" #include "MantidAPI/FileProperty.h" -#include "MantidKernel/BoundedValidator.h" +#include "MantidDataHandling/SaveCalFile.h" #include "MantidKernel/System.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/BoundedValidator.h" #include <cmath> #include <fstream> @@ -10,8 +9,7 @@ using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::Geometry; - -using Mantid::Types::DateAndTime; +using Mantid::Types::Core::DateAndTime; namespace Mantid { namespace DataHandling { @@ -153,5 +151,5 @@ void SaveCalFile::saveCalFile(const std::string &calFileName, } } -} // namespace DataHandling } // namespace Mantid +} // namespace DataHandling diff --git a/Framework/DataHandling/src/SaveIsawDetCal.cpp b/Framework/DataHandling/src/SaveIsawDetCal.cpp index 703b3a5e822..fc524a63012 100644 --- a/Framework/DataHandling/src/SaveIsawDetCal.cpp +++ b/Framework/DataHandling/src/SaveIsawDetCal.cpp @@ -18,7 +18,7 @@ using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::Geometry; using std::string; -using Mantid::Types::DateAndTime; +using Mantid::Types::Core::DateAndTime; namespace Mantid { namespace DataHandling { diff --git a/Framework/DataHandling/src/SaveNexus.cpp b/Framework/DataHandling/src/SaveNexus.cpp index 4a2505c04c8..a24e8187537 100644 --- a/Framework/DataHandling/src/SaveNexus.cpp +++ b/Framework/DataHandling/src/SaveNexus.cpp @@ -142,7 +142,7 @@ void SaveNexus::runSaveNexusProcessed() { // If we're tracking history, add the entry before we save it to file if (trackingHistory()) { m_history->fillAlgorithmHistory( - this, Mantid::Types::DateAndTime::getCurrentTime(), 0, + this, Mantid::Types::Core::DateAndTime::getCurrentTime(), 0, Algorithm::g_execCount); if (!isChild()) { m_inputWorkspace->history().addHistory(m_history); diff --git a/Framework/DataHandling/src/SaveNexusProcessed.cpp b/Framework/DataHandling/src/SaveNexusProcessed.cpp index 7cbe9333bb0..df1889a1418 100644 --- a/Framework/DataHandling/src/SaveNexusProcessed.cpp +++ b/Framework/DataHandling/src/SaveNexusProcessed.cpp @@ -287,7 +287,7 @@ void SaveNexusProcessed::doExec( // Switch to the Cpp API for the algorithm history if (trackingHistory()) { m_history->fillAlgorithmHistory( - this, Mantid::Types::DateAndTime::getCurrentTime(), 0, + this, Mantid::Types::Core::DateAndTime::getCurrentTime(), 0, Algorithm::g_execCount); if (!isChild()) { inputWorkspace->history().addHistory(m_history); diff --git a/Framework/DataHandling/src/StartAndEndTimeFromNexusFileExtractor.cpp b/Framework/DataHandling/src/StartAndEndTimeFromNexusFileExtractor.cpp index 3f85bbf0277..f978cd534d4 100644 --- a/Framework/DataHandling/src/StartAndEndTimeFromNexusFileExtractor.cpp +++ b/Framework/DataHandling/src/StartAndEndTimeFromNexusFileExtractor.cpp @@ -1,7 +1,6 @@ -#include "MantidDataHandling/StartAndEndTimeFromNexusFileExtractor.h" #include "MantidAPI/FileFinder.h" #include "MantidDataHandling/LoadNexus.h" -#include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidDataHandling/StartAndEndTimeFromNexusFileExtractor.h" #include "MantidKernel/Exception.h" #include "MantidKernel/Logger.h" #include "MantidNexus/NexusClasses.h" @@ -19,51 +18,45 @@ namespace DataHandling { enum class NexusType { Muon, Processed, ISIS, TofRaw }; enum class TimeType : unsigned char { StartTime, EndTime }; -Mantid::Types::DateAndTime handleMuonNexusFile(TimeType type, - std::string filename) { +Mantid::Types::Core::DateAndTime handleMuonNexusFile(TimeType type, + std::string filename) { Mantid::NeXus::NXRoot root(filename); if (type == TimeType::StartTime) { - return Mantid::Types::DateAndTimeHelpers::createFromISO8601( - root.getString("run/start_time")); + return Mantid::Types::Core::DateAndTime(root.getString("run/start_time")); } else { - return Mantid::Types::DateAndTimeHelpers::createFromISO8601( - root.getString("run/stop_time")); + return Mantid::Types::Core::DateAndTime(root.getString("run/stop_time")); } } -Mantid::Types::DateAndTime handleProcessedNexusFile(TimeType type, - std::string filename) { +Mantid::Types::Core::DateAndTime handleProcessedNexusFile(TimeType type, + std::string filename) { Mantid::NeXus::NXRoot root(filename); if (type == TimeType::StartTime) { - return Mantid::Types::DateAndTimeHelpers::createFromISO8601( + return Mantid::Types::Core::DateAndTime( root.getString("mantid_workspace_1/logs/run_start/value")); } else { - return Mantid::Types::DateAndTimeHelpers::createFromISO8601( + return Mantid::Types::Core::DateAndTime( root.getString("mantid_workspace_1/logs/run_end/value")); } } -Mantid::Types::DateAndTime handleISISNexusFile(TimeType type, - std::string filename) { +Mantid::Types::Core::DateAndTime handleISISNexusFile(TimeType type, + std::string filename) { Mantid::NeXus::NXRoot root(filename); if (type == TimeType::StartTime) { - return Mantid::Types::DateAndTimeHelpers::createFromISO8601( - root.getString("raw_data_1/start_time")); + return Mantid::Types::Core::DateAndTime(root.getString("raw_data_1/start_time")); } else { - return Mantid::Types::DateAndTimeHelpers::createFromISO8601( - root.getString("raw_data_1/end_time")); + return Mantid::Types::Core::DateAndTime(root.getString("raw_data_1/end_time")); } } -Mantid::Types::DateAndTime handleTofRawNexusFile(TimeType type, - std::string filename) { +Mantid::Types::Core::DateAndTime handleTofRawNexusFile(TimeType type, + std::string filename) { Mantid::NeXus::NXRoot root(filename); if (type == TimeType::StartTime) { - return Mantid::Types::DateAndTimeHelpers::createFromISO8601( - root.getString("entry/start_time")); + return Mantid::Types::Core::DateAndTime(root.getString("entry/start_time")); } else { - return Mantid::Types::DateAndTimeHelpers::createFromISO8601( - root.getString("entry/end_time")); + return Mantid::Types::Core::DateAndTime(root.getString("entry/end_time")); } } @@ -111,13 +104,13 @@ NexusType whichNexusType(std::string filename) { return nexusType; } -Mantid::Types::DateAndTime extractDateAndTime(TimeType type, - std::string filename) { +Mantid::Types::Core::DateAndTime extractDateAndTime(TimeType type, + std::string filename) { auto fullFileName = Mantid::API::FileFinder::Instance().getFullPath(filename); // Figure out the type of the Nexus file. We need to handle them individually // since they store the datetime differently auto nexusType = whichNexusType(fullFileName); - Mantid::Types::DateAndTime dateAndTime; + Mantid::Types::Core::DateAndTime dateAndTime; switch (nexusType) { case NexusType::Muon: @@ -146,7 +139,7 @@ Mantid::Types::DateAndTime extractDateAndTime(TimeType type, * @return the start time * @throws if the the start time cannot be extracted */ -Mantid::Types::DateAndTime extractStartTime(const std::string &filename) { +Mantid::Types::Core::DateAndTime extractStartTime(const std::string &filename) { return extractDateAndTime(TimeType::StartTime, filename); } @@ -156,7 +149,7 @@ Mantid::Types::DateAndTime extractStartTime(const std::string &filename) { * @return the start time * @throws if the the start time cannot be extracted */ -Mantid::Types::DateAndTime extractEndTime(const std::string &filename) { +Mantid::Types::Core::DateAndTime extractEndTime(const std::string &filename) { return extractDateAndTime(TimeType::EndTime, filename); } diff --git a/Framework/DataHandling/test/GroupDetectors2Test.h b/Framework/DataHandling/test/GroupDetectors2Test.h index 265d619da07..5cd8a54db85 100644 --- a/Framework/DataHandling/test/GroupDetectors2Test.h +++ b/Framework/DataHandling/test/GroupDetectors2Test.h @@ -16,7 +16,7 @@ #include "MantidGeometry/Instrument/DetectorGroup.h" #include "MantidHistogramData/LinearGenerator.h" #include "MantidIndexing/IndexInfo.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/UnitFactory.h" #include "MantidTestHelpers/HistogramDataTestHelper.h" #include "MantidTypes/SpectrumDefinition.h" @@ -36,7 +36,7 @@ using Mantid::HistogramData::HistogramX; using Mantid::HistogramData::Counts; using Mantid::HistogramData::CountStandardDeviations; using Mantid::HistogramData::LinearGenerator; -using Mantid::Types::TofEvent; +using Mantid::Types::Event::TofEvent; class GroupDetectors2Test : public CxxTest::TestSuite { public: @@ -980,7 +980,7 @@ private: timeRanges.push_back(double(i + 1)); } - builder.setTimeRanges(Mantid::Types::DateAndTime(0), timeRanges); + builder.setTimeRanges(Mantid::Types::Core::DateAndTime(0), timeRanges); return builder.buildWorkspace(); } diff --git a/Framework/DataHandling/test/LoadEventNexusTest.h b/Framework/DataHandling/test/LoadEventNexusTest.h index afb98cf00b9..13405636342 100644 --- a/Framework/DataHandling/test/LoadEventNexusTest.h +++ b/Framework/DataHandling/test/LoadEventNexusTest.h @@ -8,11 +8,10 @@ #include "MantidAPI/Run.h" #include "MantidAPI/SpectrumInfo.h" #include "MantidAPI/Workspace.h" -#include "MantidDataHandling/LoadEventNexus.h" #include "MantidDataObjects/EventWorkspace.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/Property.h" #include "MantidKernel/TimeSeriesProperty.h" +#include "MantidDataHandling/LoadEventNexus.h" #include <cxxtest/TestSuite.h> using namespace Mantid::Geometry; @@ -20,7 +19,8 @@ using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::Kernel; using namespace Mantid::DataHandling; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; +using Mantid::Types::Event::TofEvent; class LoadEventNexusTest : public CxxTest::TestSuite { private: @@ -474,9 +474,8 @@ public: 1.426, 1e-6); // Check monitor workspace pointer held in main workspace - TS_ASSERT_EQUALS( - WS, - ads.retrieveWS<MatrixWorkspace>("cncs_compressed")->monitorWorkspace()); + TS_ASSERT_EQUALS(WS, ads.retrieveWS<MatrixWorkspace>("cncs_compressed") + ->monitorWorkspace()); } void doTestSingleBank(bool SingleBankPixelsOnly, bool Precount, @@ -557,7 +556,7 @@ public: auto ws = AnalysisDataService::Instance().retrieveWS<EventWorkspace>(outws); auto inst = ws->getInstrument(); TS_ASSERT_EQUALS(inst->getName(), "HYSPECA"); - TS_ASSERT_EQUALS(inst->getValidFromDate().toSimpleString(), + TS_ASSERT_EQUALS(inst->getValidFromDate(), std::string("2011-Jul-20 17:02:48.437294000")); TS_ASSERT_EQUALS(inst->getNumberDetectors(), 20483); TS_ASSERT_EQUALS(inst->baseInstrument()->getMonitors().size(), 3); diff --git a/Framework/DataHandling/test/LoadEventPreNexus2Test.h b/Framework/DataHandling/test/LoadEventPreNexus2Test.h index a5feed58d87..bc837f8f4c1 100644 --- a/Framework/DataHandling/test/LoadEventPreNexus2Test.h +++ b/Framework/DataHandling/test/LoadEventPreNexus2Test.h @@ -20,7 +20,7 @@ #include "MantidDataObjects/EventWorkspace.h" #include "MantidDataObjects/Workspace2D.h" #include "MantidGeometry/Instrument.h" -#include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/TimeSeriesProperty.h" #include <sys/stat.h> @@ -32,13 +32,14 @@ using namespace Mantid::Kernel; using namespace Mantid::Kernel::Exception; using namespace Mantid::API; using namespace Mantid::Geometry; -using namespace Mantid::Types; using Mantid::HistogramData::HistogramX; +using Mantid::Types::Core::DateAndTime; +using Mantid::Types::Event::TofEvent; -using std::cout; using std::runtime_error; using std::size_t; using std::vector; +using std::cout; //========================================================================================== class LoadEventPreNexus2Test : public CxxTest::TestSuite { @@ -131,7 +132,7 @@ public: std::map<DateAndTime, double> logMap = log->valueAsMap(); std::map<DateAndTime, double>::iterator it, it2; it = logMap.begin(); - Mantid::Types::DateAndTime start = it->first; + Types::Core::DateAndTime start = it->first; std::vector<TofEvent> events1 = ew->getSpectrum(1000).getEvents(); for (size_t i = 0; i < events1.size(); i++) { diff --git a/Framework/DataHandling/test/LoadInstrumentTest.h b/Framework/DataHandling/test/LoadInstrumentTest.h index bfa33f9f3f1..5e5c3723135 100644 --- a/Framework/DataHandling/test/LoadInstrumentTest.h +++ b/Framework/DataHandling/test/LoadInstrumentTest.h @@ -3,6 +3,7 @@ #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/Axis.h" +#include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidAPI/ExperimentInfo.h" #include "MantidAPI/InstrumentDataService.h" #include "MantidAPI/SpectrumInfo.h" @@ -10,10 +11,8 @@ #include "MantidDataHandling/LoadInstrument.h" #include "MantidDataObjects/Workspace2D.h" #include "MantidGeometry/Instrument.h" -#include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidGeometry/Instrument/FitParameter.h" #include "MantidHistogramData/LinearGenerator.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/Exception.h" #include "MantidKernel/OptionalBool.h" #include "MantidKernel/Strings.h" @@ -24,14 +23,13 @@ #include <vector> using namespace Mantid; -using namespace Mantid::Types; using namespace Mantid::API; using namespace Mantid::Kernel; using namespace Mantid::Geometry; using namespace Mantid::DataHandling; using namespace Mantid::DataObjects; -using Mantid::HistogramData::LinearGenerator; using Mantid::HistogramData::Points; +using Mantid::HistogramData::LinearGenerator; class LoadInstrumentTest : public CxxTest::TestSuite { public: @@ -165,10 +163,8 @@ public: TS_ASSERT_EQUALS(output->getInstrument()->baseInstrument(), i); // Valid-from/to1951-01-01 00:00:01 - DateAndTime validFrom = - DateAndTimeHelpers::createFromISO8601("1951-01-01T00:00:01"); - DateAndTime validTo = - DateAndTimeHelpers::createFromISO8601("2100-01-31 23:59:59"); + Types::Core::DateAndTime validFrom("1951-01-01T00:00:01"); + Types::Core::DateAndTime validTo("2100-01-31 23:59:59"); TS_ASSERT_EQUALS(i->getValidFromDate(), validFrom); TS_ASSERT_EQUALS(i->getValidToDate(), validTo); diff --git a/Framework/DataHandling/test/LoadLogTest.h b/Framework/DataHandling/test/LoadLogTest.h index 76a2e82d022..67cd7fabd22 100644 --- a/Framework/DataHandling/test/LoadLogTest.h +++ b/Framework/DataHandling/test/LoadLogTest.h @@ -20,6 +20,7 @@ using namespace Mantid::API; using namespace Mantid::Kernel; using namespace Mantid::DataHandling; using namespace Mantid::DataObjects; +using Mantid::Types::Core::DateAndTime; class LoadLogTest : public CxxTest::TestSuite { public: @@ -173,7 +174,7 @@ public: Property *prop = 0; TimeSeriesProperty<double> *tsp; std::vector<double> vals; - std::vector<Mantid::Types::DateAndTime> times; + std::vector<DateAndTime> times; TS_ASSERT_THROWS_NOTHING(prop = output->run().getLogData("Temp1")); tsp = dynamic_cast<TimeSeriesProperty<double> *>(prop); diff --git a/Framework/DataHandling/test/LoadMuonNexus2Test.h b/Framework/DataHandling/test/LoadMuonNexus2Test.h index 31e34da8716..fe4ebfcd5ff 100644 --- a/Framework/DataHandling/test/LoadMuonNexus2Test.h +++ b/Framework/DataHandling/test/LoadMuonNexus2Test.h @@ -25,8 +25,8 @@ using namespace Mantid::API; using namespace Mantid::Kernel; using namespace Mantid::DataHandling; using namespace Mantid::DataObjects; -using Mantid::Types::DateAndTime; using Mantid::detid_t; +using Mantid::Types::Core::DateAndTime; class LoadMuonNexus2Test : public CxxTest::TestSuite { public: diff --git a/Framework/DataHandling/test/LoadNexusLogsTest.h b/Framework/DataHandling/test/LoadNexusLogsTest.h index 3ab35a3d0bd..7a6b6b2dd11 100644 --- a/Framework/DataHandling/test/LoadNexusLogsTest.h +++ b/Framework/DataHandling/test/LoadNexusLogsTest.h @@ -1,17 +1,16 @@ #ifndef LOADNEXUSLOGSTEST_H_ #define LOADNEXUSLOGSTEST_H_ +#include "MantidDataHandling/LoadNexusLogs.h" #include "MantidAPI/AnalysisDataService.h" -#include "MantidAPI/FrameworkManager.h" #include "MantidAPI/MatrixWorkspace.h" +#include "MantidKernel/TimeSeriesProperty.h" +#include "MantidAPI/FrameworkManager.h" #include "MantidAPI/Run.h" #include "MantidAPI/Workspace.h" #include "MantidAPI/WorkspaceFactory.h" -#include "MantidDataHandling/LoadNexusLogs.h" #include "MantidDataObjects/Workspace2D.h" #include "MantidKernel/PhysicalConstants.h" -#include "MantidKernel/TimeInterval.h" -#include "MantidKernel/TimeSeriesProperty.h" using namespace Mantid; using namespace Mantid::Geometry; @@ -19,8 +18,8 @@ using namespace Mantid::API; using namespace Mantid::Kernel; using namespace Mantid::DataHandling; -#include "MantidAPI/WorkspaceGroup.h" #include <cxxtest/TestSuite.h> +#include "MantidAPI/WorkspaceGroup.h" class LoadNexusLogsTest : public CxxTest::TestSuite { public: @@ -65,9 +64,9 @@ public: TS_ASSERT_DELTA(tsp->nthValue(1), 13715.55, 2); // The time diff between the 0th and 1st entry is 0.328 seconds - TS_ASSERT_DELTA(Mantid::Types::DateAndTime::secondsFromDuration( - tsp->nthInterval(0).length()), - 0.328, 0.01); + TS_ASSERT_DELTA( + Types::Core::DateAndTime::secondsFromDuration(tsp->nthInterval(0).length()), + 0.328, 0.01); // Now the stats } diff --git a/Framework/DataHandling/test/LoadRaw3Test.h b/Framework/DataHandling/test/LoadRaw3Test.h index 37a47837af8..442003ffe17 100644 --- a/Framework/DataHandling/test/LoadRaw3Test.h +++ b/Framework/DataHandling/test/LoadRaw3Test.h @@ -1,15 +1,15 @@ #ifndef LoadRaw3TEST_H_ #define LoadRaw3TEST_H_ -#include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/Axis.h" +#include "MantidAPI/AnalysisDataService.h" +#include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidAPI/FrameworkManager.h" #include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceGroup.h" #include "MantidDataHandling/LoadRaw3.h" #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/Detector.h" -#include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidKernel/ConfigService.h" #include "MantidKernel/TimeSeriesProperty.h" #include "MantidKernel/Unit.h" @@ -22,7 +22,7 @@ using namespace Mantid::DataHandling; using namespace Mantid::DataObjects; using namespace Mantid::Geometry; using namespace Mantid::Kernel; -using Mantid::Types::DateAndTime; +using Mantid::Types::Core::DateAndTime; class LoadRaw3Test : public CxxTest::TestSuite { public: diff --git a/Framework/DataHandling/test/MaskDetectorsTest.h b/Framework/DataHandling/test/MaskDetectorsTest.h index 9251dccd705..de6d0be7b9d 100644 --- a/Framework/DataHandling/test/MaskDetectorsTest.h +++ b/Framework/DataHandling/test/MaskDetectorsTest.h @@ -31,7 +31,7 @@ using Mantid::HistogramData::BinEdges; using Mantid::HistogramData::Counts; using Mantid::HistogramData::CountStandardDeviations; using Mantid::HistogramData::LinearGenerator; -using Mantid::Types::TofEvent; +using Mantid::Types::Event::TofEvent; class MaskDetectorsTest : public CxxTest::TestSuite { public: diff --git a/Framework/DataHandling/test/MergeLogsTest.h b/Framework/DataHandling/test/MergeLogsTest.h index aa7023454ad..1fdb7c3f48b 100644 --- a/Framework/DataHandling/test/MergeLogsTest.h +++ b/Framework/DataHandling/test/MergeLogsTest.h @@ -9,7 +9,7 @@ #include "MantidAPI/Run.h" #include "MantidAPI/WorkspaceFactory.h" #include "MantidKernel/TimeSeriesProperty.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidDataHandling/MergeLogs.h" @@ -54,13 +54,13 @@ public: size_t num2 = 12; for (size_t i = 0; i < num1; i++) { - Mantid::Types::DateAndTime time(t1_ns); + Types::Core::DateAndTime time(t1_ns); p1->addValue(time, v1); t1_ns += dt_ns; } for (size_t i = 0; i < num2; i++) { - Mantid::Types::DateAndTime time(t2_ns); + Types::Core::DateAndTime time(t2_ns); p2->addValue(time, v2); t2_ns += dt_ns; } @@ -94,9 +94,9 @@ public: TS_ASSERT_EQUALS(mergprop->size(), p1->size() + p2->size()); - std::vector<Mantid::Types::DateAndTime> mergedtimes = mergprop->timesAsVector(); + std::vector<Types::Core::DateAndTime> mergedtimes = mergprop->timesAsVector(); for (size_t i = 0; i < 2 * num1; i++) { - Mantid::Types::DateAndTime logtime = mergedtimes[i]; + Types::Core::DateAndTime logtime = mergedtimes[i]; double logvalue = mergprop->getSingleValue(logtime); if (i % 2 == 0) { TS_ASSERT_DELTA(logvalue, -1.0, 0.001); @@ -106,7 +106,7 @@ public: } // ENDFOR for (size_t i = 2 * num1; i < num1 + num2; i++) { - Mantid::Types::DateAndTime logtime = mergedtimes[i]; + Types::Core::DateAndTime logtime = mergedtimes[i]; double logvalue = mergprop->getSingleValue(logtime); TS_ASSERT_DELTA(logvalue, 1.0, 0.001); } diff --git a/Framework/DataHandling/test/RemoveLogsTest.h b/Framework/DataHandling/test/RemoveLogsTest.h index 271e22b890c..16922210e60 100644 --- a/Framework/DataHandling/test/RemoveLogsTest.h +++ b/Framework/DataHandling/test/RemoveLogsTest.h @@ -3,18 +3,17 @@ #include <cxxtest/TestSuite.h> -#include "MantidAPI/Algorithm.h" +#include "MantidDataHandling/RemoveLogs.h" +#include "MantidDataHandling/LoadLog.h" +#include "MantidAPI/WorkspaceFactory.h" +#include "MantidGeometry/Instrument.h" +#include "MantidDataObjects/Workspace2D.h" #include "MantidAPI/AnalysisDataService.h" +#include "MantidKernel/Exception.h" #include "MantidAPI/FrameworkManager.h" #include "MantidAPI/Workspace.h" -#include "MantidAPI/WorkspaceFactory.h" -#include "MantidDataHandling/LoadLog.h" -#include "MantidDataHandling/RemoveLogs.h" -#include "MantidDataObjects/Workspace2D.h" -#include "MantidGeometry/Instrument.h" +#include "MantidAPI/Algorithm.h" #include "MantidGeometry/Instrument/Component.h" -#include "MantidKernel/DateAndTimeHelpers.h" -#include "MantidKernel/Exception.h" #include "MantidKernel/TimeSeriesProperty.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" @@ -24,7 +23,7 @@ using namespace Mantid::API; using namespace Mantid::Kernel; using namespace Mantid::DataHandling; using namespace Mantid::DataObjects; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; class RemoveLogsTest : public CxxTest::TestSuite { public: @@ -126,8 +125,7 @@ private: std::vector<DateAndTime> times; std::vector<int> index; std::vector<double> dbl1, dbl2; - DateAndTime startTime = - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00"); + DateAndTime startTime("2010-01-01T00:00:00"); for (int i = 0; i < 100; ++i) { times.push_back(startTime + i * 10.0); index.push_back(i); diff --git a/Framework/DataHandling/test/RenameLogTest.h b/Framework/DataHandling/test/RenameLogTest.h index 2566304aec5..0946a1bcf35 100644 --- a/Framework/DataHandling/test/RenameLogTest.h +++ b/Framework/DataHandling/test/RenameLogTest.h @@ -104,7 +104,7 @@ private: m_rawValues.clear(); for (size_t i = 0; i < m_num1; i++) { - Mantid::Types::DateAndTime time(t1_ns); + Types::Core::DateAndTime time(t1_ns); p1->addValue(time, v1); m_rawTimes.push_back(time); @@ -128,7 +128,7 @@ private: rp = dynamic_cast<Kernel::TimeSeriesProperty<double> *>( resultWS->run().getProperty(logName)); - std::vector<Mantid::Types::DateAndTime> newtimes = rp->timesAsVector(); + std::vector<Types::Core::DateAndTime> newtimes = rp->timesAsVector(); TS_ASSERT_EQUALS(newtimes.size(), m_num1); for (size_t i = 0; i < m_num1; i++) { double newvalue; @@ -139,7 +139,7 @@ private: } size_t m_num1; - std::vector<Mantid::Types::DateAndTime> m_rawTimes; + std::vector<Types::Core::DateAndTime> m_rawTimes; std::vector<double> m_rawValues; }; diff --git a/Framework/DataHandling/test/StartAndEndTimeFromNexusFileExtractorTest.h b/Framework/DataHandling/test/StartAndEndTimeFromNexusFileExtractorTest.h index 9c14d2b12cd..f1063829f18 100644 --- a/Framework/DataHandling/test/StartAndEndTimeFromNexusFileExtractorTest.h +++ b/Framework/DataHandling/test/StartAndEndTimeFromNexusFileExtractorTest.h @@ -5,10 +5,8 @@ #include "MantidAPI/FileFinder.h" #include "MantidDataHandling/StartAndEndTimeFromNexusFileExtractor.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include <string> -using namespace Mantid::Types; using namespace Mantid::DataHandling; class StartAndEndTimeFromNexusFileExtractorTest : public CxxTest::TestSuite { @@ -76,10 +74,8 @@ private: auto endTimeExtracted = extractEndTime(fullFilePath); // Assert - Mantid::Types::DateAndTime expectedStartTimeString = - DateAndTimeHelpers::createFromISO8601(startTime.c_str()); - Mantid::Types::DateAndTime expectedEndTimeString = - DateAndTimeHelpers::createFromISO8601(endTime.c_str()); + Mantid::Types::Core::DateAndTime expectedStartTimeString(startTime.c_str()); + Mantid::Types::Core::DateAndTime expectedEndTimeString(endTime.c_str()); TSM_ASSERT("Should have the same start time", startTimeExtracted == expectedStartTimeString); diff --git a/Framework/DataObjects/inc/MantidDataObjects/EventList.h b/Framework/DataObjects/inc/MantidDataObjects/EventList.h index 5a7b2a9c844..c1a31b2934c 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/EventList.h +++ b/Framework/DataObjects/inc/MantidDataObjects/EventList.h @@ -14,10 +14,11 @@ namespace Mantid { namespace Types { +namespace Core { class DateAndTime; } +} // namespace Types namespace Kernel { - class SplittingInterval; typedef std::vector<SplittingInterval> TimeSplitterType; class Unit; @@ -78,7 +79,7 @@ public: EventList(const EventList &rhs); - EventList(const std::vector<Types::TofEvent> &events); + EventList(const std::vector<Types::Event::TofEvent> &events); EventList(const std::vector<WeightedEvent> &events); @@ -91,9 +92,9 @@ public: EventList &operator=(const EventList &); - EventList &operator+=(const Types::TofEvent &event); + EventList &operator+=(const Types::Event::TofEvent &event); - EventList &operator+=(const std::vector<Types::TofEvent> &more_events); + EventList &operator+=(const std::vector<Types::Event::TofEvent> &more_events); EventList &operator+=(const WeightedEvent &event); @@ -115,9 +116,9 @@ public: *faster. * NOTE: Only call this on a un-weighted event list! * - * @param event :: Types::TofEvent to add at the end of the list. + * @param event :: TofEvent to add at the end of the list. * */ - inline void addEventQuickly(const Types::TofEvent &event) { + inline void addEventQuickly(const Types::Event::TofEvent &event) { this->events.push_back(event); this->order = UNSORTED; } @@ -148,8 +149,8 @@ public: WeightedEvent getEvent(size_t event_number); - std::vector<Types::TofEvent> &getEvents(); - const std::vector<Types::TofEvent> &getEvents() const; + std::vector<Types::Event::TofEvent> &getEvents(); + const std::vector<Types::Event::TofEvent> &getEvents() const; std::vector<WeightedEvent> &getWeightedEvents(); const std::vector<WeightedEvent> &getWeightedEvents() const; @@ -258,14 +259,14 @@ public: void getTofs(std::vector<double> &tofs) const override; double getTofMin() const override; double getTofMax() const override; - Mantid::Types::DateAndTime getPulseTimeMax() const override; - Mantid::Types::DateAndTime getPulseTimeMin() const override; - void getPulseTimeMinMax(Mantid::Types::DateAndTime &tMin, - Mantid::Types::DateAndTime &tM) const; - Mantid::Types::DateAndTime + Mantid::Types::Core::DateAndTime getPulseTimeMax() const override; + Mantid::Types::Core::DateAndTime getPulseTimeMin() const override; + void getPulseTimeMinMax(Mantid::Types::Core::DateAndTime &tMin, + Mantid::Types::Core::DateAndTime &tM) const; + Mantid::Types::Core::DateAndTime getTimeAtSampleMax(const double &tofFactor, const double &tofOffset) const override; - Mantid::Types::DateAndTime + Mantid::Types::Core::DateAndTime getTimeAtSampleMin(const double &tofFactor, const double &tofOffset) const override; @@ -281,18 +282,18 @@ public: /// Return the list of event weight error values void getWeightErrors(std::vector<double> &weightErrors) const override; - std::vector<Mantid::Types::DateAndTime> getPulseTimes() const override; + std::vector<Mantid::Types::Core::DateAndTime> getPulseTimes() const override; void setTofs(const MantidVec &tofs) override; void reverse(); - void filterByPulseTime(Mantid::Types::DateAndTime start, - Mantid::Types::DateAndTime stop, + void filterByPulseTime(Types::Core::DateAndTime start, + Types::Core::DateAndTime stop, EventList &output) const; - void filterByTimeAtSample(Mantid::Types::DateAndTime start, - Mantid::Types::DateAndTime stop, double tofFactor, + void filterByTimeAtSample(Types::Core::DateAndTime start, + Types::Core::DateAndTime stop, double tofFactor, double tofOffset, EventList &output) const; void filterInPlace(Kernel::TimeSplitterType &splitter); @@ -372,8 +373,8 @@ private: /// Histogram object holding the histogram data. Currently only X. HistogramData::Histogram m_histogram; - /// List of Types::TofEvent (no weights). - mutable std::vector<Types::TofEvent> events; + /// List of TofEvent (no weights). + mutable std::vector<Types::Event::TofEvent> events; /// List of WeightedEvent's mutable std::vector<WeightedEvent> weightedEvents; @@ -472,19 +473,19 @@ private: template <class T> static void getPulseTimesHelper(const std::vector<T> &events, - std::vector<Mantid::Types::DateAndTime> ×); + std::vector<Mantid::Types::Core::DateAndTime> ×); template <class T> static void setTofsHelper(std::vector<T> &events, const std::vector<double> &tofs); template <class T> static void filterByPulseTimeHelper(std::vector<T> &events, - Mantid::Types::DateAndTime start, - Mantid::Types::DateAndTime stop, + Types::Core::DateAndTime start, + Types::Core::DateAndTime stop, std::vector<T> &output); template <class T> static void filterByTimeAtSampleHelper(std::vector<T> &events, - Mantid::Types::DateAndTime start, - Mantid::Types::DateAndTime stop, + Types::Core::DateAndTime start, + Types::Core::DateAndTime stop, double tofFactor, double tofOffset, std::vector<T> &output); template <class T> @@ -546,9 +547,10 @@ private: // Methods overloaded to get event vectors. DLLExport void getEventsFrom(EventList &el, - std::vector<Types::TofEvent> *&events); -DLLExport void getEventsFrom(const EventList &el, - std::vector<Types::TofEvent> const *&events); + std::vector<Types::Event::TofEvent> *&events); +DLLExport void +getEventsFrom(const EventList &el, + std::vector<Types::Event::TofEvent> const *&events); DLLExport void getEventsFrom(EventList &el, std::vector<WeightedEvent> *&events); DLLExport void getEventsFrom(const EventList &el, diff --git a/Framework/DataObjects/inc/MantidDataObjects/EventWorkspace.h b/Framework/DataObjects/inc/MantidDataObjects/EventWorkspace.h index 419e400b30b..582294715e9 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/EventWorkspace.h +++ b/Framework/DataObjects/inc/MantidDataObjects/EventWorkspace.h @@ -76,15 +76,15 @@ public: double getTofMax() const override; - Mantid::Types::DateAndTime getPulseTimeMin() const override; - Mantid::Types::DateAndTime getPulseTimeMax() const override; - void getPulseTimeMinMax(Mantid::Types::DateAndTime &xmin, - Mantid::Types::DateAndTime &xmax) const; + Mantid::Types::Core::DateAndTime getPulseTimeMin() const override; + Mantid::Types::Core::DateAndTime getPulseTimeMax() const override; + void getPulseTimeMinMax(Mantid::Types::Core::DateAndTime &xmin, + Mantid::Types::Core::DateAndTime &xmax) const; - Mantid::Types::DateAndTime + Mantid::Types::Core::DateAndTime getTimeAtSampleMin(double tofOffset = 0) const override; - Mantid::Types::DateAndTime + Mantid::Types::Core::DateAndTime getTimeAtSampleMax(double tofOffset = 0) const override; double getEventXMin() const; diff --git a/Framework/DataObjects/inc/MantidDataObjects/Events.h b/Framework/DataObjects/inc/MantidDataObjects/Events.h index d6d04faa74c..84d26d3769d 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/Events.h +++ b/Framework/DataObjects/inc/MantidDataObjects/Events.h @@ -8,8 +8,7 @@ #include "MantidKernel/System.h" #include "MantidKernel/TimeSplitter.h" #include "MantidKernel/cow_ptr.h" -#include "MantidTypes/DateAndTime.h" -#include "MantidTypes/TofEvent.h" +#include "MantidTypes/Event/TofEvent.h" #include <cstddef> #include <iosfwd> #include <set> @@ -23,7 +22,6 @@ class LoadEventNexus; } namespace DataObjects { - //========================================================================================== /** Info about a single neutron detection event, including a weight and error *value: @@ -33,7 +31,7 @@ namespace DataObjects { * - weight of the neutron (float, can be */ #pragma pack(push, 4) // Ensure the structure is no larger than it needs to -class DLLExport WeightedEvent : public Types::TofEvent { +class DLLExport WeightedEvent : public Types::Event::TofEvent { /// EventList has the right to mess with WeightedEvent. friend class EventList; @@ -53,9 +51,9 @@ public: WeightedEvent(double time_of_flight); /// Constructor, full - WeightedEvent(double tof, const Mantid::Types::DateAndTime pulsetime, + WeightedEvent(double tof, const Mantid::Types::Core::DateAndTime pulsetime, double weight, double errorSquared); - WeightedEvent(double tof, const Mantid::Types::DateAndTime pulsetime, + WeightedEvent(double tof, const Mantid::Types::Core::DateAndTime pulsetime, float weight, float errorSquared); WeightedEvent(const TofEvent &, double weight, double errorSquared); @@ -114,19 +112,21 @@ public: WeightedEventNoTime(double tof, double weight, double errorSquared); WeightedEventNoTime(double tof, float weight, float errorSquared); - WeightedEventNoTime(double tof, const Mantid::Types::DateAndTime pulsetime, + WeightedEventNoTime(double tof, + const Mantid::Types::Core::DateAndTime pulsetime, double weight, double errorSquared); - WeightedEventNoTime(double tof, const Mantid::Types::DateAndTime pulsetime, + WeightedEventNoTime(double tof, + const Mantid::Types::Core::DateAndTime pulsetime, float weight, float errorSquared); - WeightedEventNoTime(const Types::TofEvent &, double weight, + WeightedEventNoTime(const Types::Event::TofEvent &, double weight, double errorSquared); - WeightedEventNoTime(const Types::TofEvent &, float weight, + WeightedEventNoTime(const Types::Event::TofEvent &, float weight, float errorSquared); WeightedEventNoTime(const WeightedEvent &); - WeightedEventNoTime(const Types::TofEvent &); + WeightedEventNoTime(const Types::Event::TofEvent &); WeightedEventNoTime(); @@ -138,7 +138,7 @@ public: double operator()() const; double tof() const; - Mantid::Types::DateAndTime pulseTime() const; + Mantid::Types::Core::DateAndTime pulseTime() const; double weight() const; double error() const; double errorSquared() const; @@ -181,7 +181,7 @@ inline double WeightedEventNoTime::tof() const { return m_tof; } /** Return the pulse time; this returns 0 since this * type of Event has no time associated. */ -inline Mantid::Types::DateAndTime WeightedEventNoTime::pulseTime() const { +inline Types::Core::DateAndTime WeightedEventNoTime::pulseTime() const { return 0; } diff --git a/Framework/DataObjects/inc/MantidDataObjects/PeaksWorkspace.h b/Framework/DataObjects/inc/MantidDataObjects/PeaksWorkspace.h index 96610eaaa68..9d122261e5c 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/PeaksWorkspace.h +++ b/Framework/DataObjects/inc/MantidDataObjects/PeaksWorkspace.h @@ -9,7 +9,7 @@ #include "MantidDataObjects/PeakColumn.h" #include "MantidDataObjects/TableWorkspace.h" #include "MantidGeometry/Instrument.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/Exception.h" #include "MantidKernel/Logger.h" #include "MantidKernel/Matrix.h" diff --git a/Framework/DataObjects/inc/MantidDataObjects/ScanningWorkspaceBuilder.h b/Framework/DataObjects/inc/MantidDataObjects/ScanningWorkspaceBuilder.h index fcf7878fcb5..01823a0ba14 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/ScanningWorkspaceBuilder.h +++ b/Framework/DataObjects/inc/MantidDataObjects/ScanningWorkspaceBuilder.h @@ -4,7 +4,7 @@ #include "MantidAPI/MatrixWorkspace.h" #include "MantidDataObjects/DllConfig.h" #include "MantidIndexing/IndexInfo.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/V3D.h" #include "MantidKernel/Quat.h" @@ -64,9 +64,9 @@ public: void setHistogram(HistogramData::Histogram histogram); void - setTimeRanges(std::vector<std::pair<Mantid::Types::DateAndTime, Mantid::Types::DateAndTime>> + setTimeRanges(std::vector<std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime>> timeRanges); - void setTimeRanges(const Mantid::Types::DateAndTime &startTime, + void setTimeRanges(const Types::Core::DateAndTime &startTime, const std::vector<double> &durations); void setPositions(std::vector<std::vector<Kernel::V3D>> positions); void setRotations(std::vector<std::vector<Kernel::Quat>> rotations); @@ -87,7 +87,7 @@ private: HistogramData::Histogram m_histogram; - std::vector<std::pair<Mantid::Types::DateAndTime, Mantid::Types::DateAndTime>> m_timeRanges; + std::vector<std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime>> m_timeRanges; std::vector<std::vector<Kernel::V3D>> m_positions; std::vector<std::vector<Kernel::Quat>> m_rotations; diff --git a/Framework/DataObjects/src/EventList.cpp b/Framework/DataObjects/src/EventList.cpp index 77999da08a7..98eb60ffa88 100644 --- a/Framework/DataObjects/src/EventList.cpp +++ b/Framework/DataObjects/src/EventList.cpp @@ -1,7 +1,7 @@ #include "MantidDataObjects/EventList.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidDataObjects/EventWorkspaceMRU.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/Exception.h" #include "MantidKernel/Logger.h" #include "MantidKernel/Unit.h" @@ -29,8 +29,8 @@ using std::vector; namespace Mantid { namespace DataObjects { using Kernel::Exception::NotImplementedError; -using Mantid::Types::DateAndTime; -using Mantid::Types::TofEvent; +using Types::Core::DateAndTime; +using Types::Event::TofEvent; using namespace Mantid::API; namespace { @@ -2714,7 +2714,7 @@ std::vector<double> EventList::getWeightErrors() const { template <class T> void EventList::getPulseTimesHelper( const std::vector<T> &events, - std::vector<Mantid::Types::DateAndTime> ×) { + std::vector<Mantid::Types::Core::DateAndTime> ×) { times.clear(); for (const auto &event : events) { times.push_back(event.pulseTime()); @@ -2725,8 +2725,8 @@ void EventList::getPulseTimesHelper( * * @return by copy a vector of DateAndTime times */ -std::vector<Mantid::Types::DateAndTime> EventList::getPulseTimes() const { - std::vector<Mantid::Types::DateAndTime> times; +std::vector<Mantid::Types::Core::DateAndTime> EventList::getPulseTimes() const { + std::vector<Mantid::Types::Core::DateAndTime> times; // Set the capacity of the vector to avoid multiple resizes times.reserve(this->getNumberEvents()); @@ -2925,8 +2925,8 @@ DateAndTime EventList::getPulseTimeMax() const { return tMax; } -void EventList::getPulseTimeMinMax(Mantid::Types::DateAndTime &tMin, - Mantid::Types::DateAndTime &tMax) const { +void EventList::getPulseTimeMinMax(Mantid::Types::Core::DateAndTime &tMin, + Mantid::Types::Core::DateAndTime &tMax) const { // set up as the minimum available date time. tMax = DateAndTime::minimum(); tMin = DateAndTime::maximum(); @@ -3621,8 +3621,8 @@ void EventList::filterByPulseTime(DateAndTime start, DateAndTime stop, } } -void EventList::filterByTimeAtSample(Mantid::Types::DateAndTime start, - Mantid::Types::DateAndTime stop, double tofFactor, +void EventList::filterByTimeAtSample(Types::Core::DateAndTime start, + Types::Core::DateAndTime stop, double tofFactor, double tofOffset, EventList &output) const { if (this == &output) { @@ -4278,7 +4278,7 @@ void EventList::splitByPulseTimeHelper(Kernel::TimeSplitterType &splitter, // Prepare to TimeSplitter Iterate through the splitter at the same time auto itspl = splitter.begin(); auto itspl_end = splitter.end(); - Mantid::Types::DateAndTime start, stop; + Types::Core::DateAndTime start, stop; // Prepare to Events Iterate through all events (sorted by tof) auto itev = events.begin(); diff --git a/Framework/DataObjects/src/EventWorkspace.cpp b/Framework/DataObjects/src/EventWorkspace.cpp index 5a9545c28f3..a794ec3f760 100644 --- a/Framework/DataObjects/src/EventWorkspace.cpp +++ b/Framework/DataObjects/src/EventWorkspace.cpp @@ -10,7 +10,7 @@ #include "MantidGeometry/IDetector.h" #include "MantidGeometry/Instrument.h" #include "MantidKernel/CPUTimer.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/Exception.h" #include "MantidKernel/FunctionTask.h" #include "MantidKernel/IPropertyManager.h" @@ -24,7 +24,7 @@ using namespace boost::posix_time; using Mantid::API::ISpectrum; -using Mantid::Types::DateAndTime; +using Mantid::Types::Core::DateAndTime; namespace Mantid { namespace DataObjects { @@ -192,7 +192,7 @@ double EventWorkspace::getTofMax() const { return this->getEventXMax(); } */ DateAndTime EventWorkspace::getPulseTimeMin() const { // set to crazy values to start - Mantid::Types::DateAndTime tMin = DateAndTime::maximum(); + Mantid::Types::Core::DateAndTime tMin = DateAndTime::maximum(); size_t numWorkspace = this->data.size(); DateAndTime temp; for (size_t workspaceIndex = 0; workspaceIndex < numWorkspace; @@ -211,7 +211,7 @@ DateAndTime EventWorkspace::getPulseTimeMin() const { */ DateAndTime EventWorkspace::getPulseTimeMax() const { // set to crazy values to start - Mantid::Types::DateAndTime tMax = DateAndTime::minimum(); + Mantid::Types::Core::DateAndTime tMax = DateAndTime::minimum(); size_t numWorkspace = this->data.size(); DateAndTime temp; for (size_t workspaceIndex = 0; workspaceIndex < numWorkspace; @@ -229,8 +229,8 @@ Get the maximum and mimumum pulse time for events accross the entire workspace. @param Tmax maximal pulse time as a DateAndTime. */ void EventWorkspace::getPulseTimeMinMax( - Mantid::Types::DateAndTime &Tmin, - Mantid::Types::DateAndTime &Tmax) const { + Mantid::Types::Core::DateAndTime &Tmin, + Mantid::Types::Core::DateAndTime &Tmax) const { Tmax = DateAndTime::minimum(); Tmin = DateAndTime::maximum(); @@ -267,7 +267,7 @@ DateAndTime EventWorkspace::getTimeAtSampleMin(double tofOffset) const { const auto L1 = specInfo.l1(); // set to crazy values to start - Mantid::Types::DateAndTime tMin = DateAndTime::maximum(); + Mantid::Types::Core::DateAndTime tMin = DateAndTime::maximum(); size_t numWorkspace = this->data.size(); DateAndTime temp; @@ -294,7 +294,7 @@ DateAndTime EventWorkspace::getTimeAtSampleMax(double tofOffset) const { const auto L1 = specInfo.l1(); // set to crazy values to start - Mantid::Types::DateAndTime tMax = DateAndTime::minimum(); + Mantid::Types::Core::DateAndTime tMax = DateAndTime::minimum(); size_t numWorkspace = this->data.size(); DateAndTime temp; for (size_t workspaceIndex = 0; workspaceIndex < numWorkspace; diff --git a/Framework/DataObjects/src/Events.cpp b/Framework/DataObjects/src/Events.cpp index fa54cdc4005..d5a7ba46fa1 100644 --- a/Framework/DataObjects/src/Events.cpp +++ b/Framework/DataObjects/src/Events.cpp @@ -1,8 +1,8 @@ #include "MantidDataObjects/Events.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidDataObjects/EventList.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/Exception.h" -#include "MantidTypes/DateAndTime.h" #include <cmath> #include <functional> #include <stdexcept> @@ -15,8 +15,7 @@ using std::vector; namespace Mantid { namespace DataObjects { using Kernel::Exception::NotImplementedError; -using Mantid::Types::DateAndTime; -using Mantid::Types::TofEvent; +using Types::Event::TofEvent; //========================================================================== /// --------------------- WeightedEvent stuff ------------------------------ @@ -35,7 +34,7 @@ WeightedEvent::WeightedEvent(double time_of_flight) * @param errorSquared: the square of the error on the event */ WeightedEvent::WeightedEvent(double tof, - const Mantid::Types::DateAndTime pulsetime, + const Mantid::Types::Core::DateAndTime pulsetime, double weight, double errorSquared) : TofEvent(tof, pulsetime), m_weight(static_cast<float>(weight)), m_errorSquared(static_cast<float>(errorSquared)) {} @@ -47,7 +46,7 @@ WeightedEvent::WeightedEvent(double tof, * @param errorSquared: the square of the error on the event */ WeightedEvent::WeightedEvent(double tof, - const Mantid::Types::DateAndTime pulsetime, + const Mantid::Types::Core::DateAndTime pulsetime, float weight, float errorSquared) : TofEvent(tof, pulsetime), m_weight(weight), m_errorSquared(errorSquared) { } @@ -165,7 +164,7 @@ WeightedEventNoTime::WeightedEventNoTime(double tof, float weight, * @param errorSquared: the square of the error on the event */ WeightedEventNoTime::WeightedEventNoTime(double tof, - const Mantid::Types::DateAndTime, + const Mantid::Types::Core::DateAndTime, double weight, double errorSquared) : m_tof(tof), m_weight(static_cast<float>(weight)), m_errorSquared(static_cast<float>(errorSquared)) {} @@ -177,7 +176,7 @@ WeightedEventNoTime::WeightedEventNoTime(double tof, * @param errorSquared: the square of the error on the event */ WeightedEventNoTime::WeightedEventNoTime(double tof, - const Mantid::Types::DateAndTime, + const Mantid::Types::Core::DateAndTime, float weight, float errorSquared) : m_tof(tof), m_weight(weight), m_errorSquared(errorSquared) {} diff --git a/Framework/DataObjects/src/PeaksWorkspace.cpp b/Framework/DataObjects/src/PeaksWorkspace.cpp index dec6dfbae28..d38c71e1347 100644 --- a/Framework/DataObjects/src/PeaksWorkspace.cpp +++ b/Framework/DataObjects/src/PeaksWorkspace.cpp @@ -11,7 +11,7 @@ #include "MantidDataObjects/TableWorkspace.h" #include "MantidGeometry/Crystal/OrientedLattice.h" #include "MantidGeometry/Instrument/Goniometer.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/Logger.h" #include "MantidKernel/PhysicalConstants.h" #include "MantidKernel/Quat.h" diff --git a/Framework/DataObjects/src/ScanningWorkspaceBuilder.cpp b/Framework/DataObjects/src/ScanningWorkspaceBuilder.cpp index f3bd097a830..11bcd38ef2d 100644 --- a/Framework/DataObjects/src/ScanningWorkspaceBuilder.cpp +++ b/Framework/DataObjects/src/ScanningWorkspaceBuilder.cpp @@ -62,7 +62,7 @@ void ScanningWorkspaceBuilder::setHistogram( *and end times */ void ScanningWorkspaceBuilder::setTimeRanges(const std::vector< - std::pair<Mantid::Types::DateAndTime, Mantid::Types::DateAndTime>> timeRanges) { + std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime>> timeRanges) { verifyTimeIndexSize(timeRanges.size(), "start time, end time pairs"); m_timeRanges = std::move(timeRanges); } @@ -75,18 +75,18 @@ void ScanningWorkspaceBuilder::setTimeRanges(const std::vector< * @param durations A vector of doubles containing the duration in seconds */ void ScanningWorkspaceBuilder::setTimeRanges( - const Mantid::Types::DateAndTime &startTime, + const Types::Core::DateAndTime &startTime, const std::vector<double> &durations) { verifyTimeIndexSize(durations.size(), "time durations"); - std::vector<std::pair<Mantid::Types::DateAndTime, Mantid::Types::DateAndTime>> timeRanges = - {std::pair<Mantid::Types::DateAndTime, Mantid::Types::DateAndTime>( + std::vector<std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime>> timeRanges = + {std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime>( startTime, startTime + durations[0])}; for (size_t i = 1; i < m_nTimeIndexes; ++i) { const auto newStartTime = timeRanges[i - 1].second; const auto endTime = newStartTime + durations[i]; - timeRanges.push_back(std::pair<Mantid::Types::DateAndTime, Mantid::Types::DateAndTime>( + timeRanges.push_back(std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime>( newStartTime, endTime)); } diff --git a/Framework/DataObjects/src/SplittersWorkspace.cpp b/Framework/DataObjects/src/SplittersWorkspace.cpp index e73431f2b15..e56ed22b3b7 100644 --- a/Framework/DataObjects/src/SplittersWorkspace.cpp +++ b/Framework/DataObjects/src/SplittersWorkspace.cpp @@ -41,8 +41,8 @@ Kernel::SplittingInterval SplittersWorkspace::getSplitter(size_t index) { row >> stop; row >> wsgroup; - Kernel::SplittingInterval splitter(Mantid::Types::DateAndTime(start), - Mantid::Types::DateAndTime(stop), wsgroup); + Kernel::SplittingInterval splitter(Types::Core::DateAndTime(start), + Types::Core::DateAndTime(stop), wsgroup); return splitter; } diff --git a/Framework/DataObjects/test/CMakeLists.txt b/Framework/DataObjects/test/CMakeLists.txt index a264a7f8914..70da5ac765c 100644 --- a/Framework/DataObjects/test/CMakeLists.txt +++ b/Framework/DataObjects/test/CMakeLists.txt @@ -18,7 +18,6 @@ if ( CXXTEST_FOUND ) cxxtest_add_test ( DataObjectsTest ${TEST_FILES} ) target_link_libraries( DataObjectsTest LINK_PRIVATE ${TCMALLOC_LIBRARIES_LINKTIME} ${MANTIDLIBS} - Types DataObjects ${NEXUS_LIBRARIES} ${JSONCPP_LIBRARIES} diff --git a/Framework/DataObjects/test/EventListTest.h b/Framework/DataObjects/test/EventListTest.h index ab06626bab6..93b909c7eff 100644 --- a/Framework/DataObjects/test/EventListTest.h +++ b/Framework/DataObjects/test/EventListTest.h @@ -16,10 +16,9 @@ using namespace Mantid::API; using namespace Mantid::Kernel; using namespace Mantid::HistogramData; using namespace Mantid::DataObjects; -using Mantid::Types::DateAndTime; -using Mantid::Types::TofEvent; - +using Mantid::Types::Core::DateAndTime; +using Mantid::Types::Event::TofEvent; using std::runtime_error; using std::size_t; using std::vector; @@ -2379,7 +2378,7 @@ public: for (int time = 0; time < 1000; time++) { // All pulse times from 0 to 999 in seconds el += TofEvent(rand() % 1000, - time); // Mantid::Types::DateAndTime(time*1.0, 0.0) ); + time); // Types::Core::DateAndTime(time*1.0, 0.0) ); } } @@ -2396,7 +2395,7 @@ public: // All pulse times from 0 to 999 in seconds DateAndTime pulsetime(static_cast<int64_t>(time * 1000000)); el += TofEvent(rand() % 1000, - pulsetime); // Mantid::Types::DateAndTime(time*1.0, 0.0) ); + pulsetime); // Types::Core::DateAndTime(time*1.0, 0.0) ); } } diff --git a/Framework/DataObjects/test/EventWorkspaceTest.h b/Framework/DataObjects/test/EventWorkspaceTest.h index d7d7d81bd96..77eb86f905d 100644 --- a/Framework/DataObjects/test/EventWorkspaceTest.h +++ b/Framework/DataObjects/test/EventWorkspaceTest.h @@ -8,23 +8,22 @@ #ifndef EVENTWORKSPACETEST_H_ #define EVENTWORKSPACETEST_H_ +#include <cxxtest/TestSuite.h> #include <boost/date_time/gregorian/gregorian.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/scoped_ptr.hpp> -#include <cxxtest/TestSuite.h> #include <string> +#include "MantidHistogramData/LinearGenerator.h" #include "MantidAPI/Axis.h" #include "MantidAPI/SpectrumInfo.h" #include "MantidDataObjects/EventList.h" #include "MantidDataObjects/EventWorkspace.h" -#include "MantidHistogramData/LinearGenerator.h" +#include "MantidTestHelpers/WorkspaceCreationHelper.h" +#include "MantidTestHelpers/ComponentCreationHelper.h" #include "MantidKernel/Memory.h" #include "MantidKernel/Timer.h" -#include "MantidTestHelpers/ComponentCreationHelper.h" -#include "MantidTestHelpers/WorkspaceCreationHelper.h" -#include "MantidTypes/DateAndTime.h" #include "PropertyManagerHelper.h" using namespace Mantid; @@ -33,17 +32,17 @@ using namespace Mantid::Kernel; using namespace Mantid::Kernel::Exception; using namespace Mantid::API; -using std::cout; using std::runtime_error; using std::size_t; using std::vector; +using std::cout; using namespace boost::posix_time; using Mantid::HistogramData::BinEdges; using Mantid::HistogramData::Histogram; using Mantid::HistogramData::HistogramX; using Mantid::HistogramData::LinearGenerator; -using Mantid::Types::DateAndTime; -using Mantid::Types::TofEvent; +using Mantid::Types::Core::DateAndTime; +using Mantid::Types::Event::TofEvent; class EventWorkspaceTest : public CxxTest::TestSuite { private: @@ -621,7 +620,7 @@ public: * Test that parallelization is thread-safe * */ - void xtestSegFault() ///< Disabled because ~2.5 seconds. + void xtestSegFault() ///<Disabled because ~2.5 seconds. { int numpix = 100000; EventWorkspace_const_sptr ew1 = @@ -683,8 +682,8 @@ public: } /** - * Test declaring an input EventWorkspace and retrieving as const_sptr or sptr - */ + * Test declaring an input EventWorkspace and retrieving as const_sptr or sptr + */ void testGetProperty_const_sptr() { const std::string wsName = "InputWorkspace"; EventWorkspace_sptr wsInput(new EventWorkspace()); @@ -714,9 +713,8 @@ public: } /** - * Test declaring an input IEventWorkspace and retrieving as const_sptr or - * sptr - */ + * Test declaring an input IEventWorkspace and retrieving as const_sptr or sptr + */ void testGetProperty_IEventWS_const_sptr() { const std::string wsName = "InputWorkspace"; IEventWorkspace_sptr wsInput(new EventWorkspace()); diff --git a/Framework/DataObjects/test/EventsTest.h b/Framework/DataObjects/test/EventsTest.h index 965daebbb2d..9506f960170 100644 --- a/Framework/DataObjects/test/EventsTest.h +++ b/Framework/DataObjects/test/EventsTest.h @@ -2,15 +2,13 @@ #define EVENTSTEST_H_ 1 #include "MantidDataObjects/Events.h" -#include "MantidKernel/DateAndTimeHelpers.h" -#include "MantidTypes/TofEvent.h" #include <cxxtest/TestSuite.h> using namespace Mantid; using namespace Mantid::API; using namespace Mantid::Kernel; using namespace Mantid::DataObjects; -using Mantid::Types::TofEvent; +using Mantid::Types::Event::TofEvent; using std::runtime_error; using std::size_t; @@ -24,11 +22,9 @@ public: void test_Compare() { // tof event TofEvent tofEvent1(20.0, - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "1990-01-02 00:00:02.000")); - TofEvent tofEvent2(20.05, - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "1990-01-02 00:00:02.000000001")); + Types::Core::DateAndTime("1990-01-02 00:00:02.000")); + TofEvent tofEvent2( + 20.05, Types::Core::DateAndTime("1990-01-02 00:00:02.000000001")); TS_ASSERT(tofEvent1 == tofEvent1); TS_ASSERT(!(tofEvent1 == tofEvent2)); @@ -36,15 +32,10 @@ public: // weighted WeightedEvent wghtEvent1( - 20.0, - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "1990-01-02 00:00:02.000"), - 1., 1.); + 20.0, Types::Core::DateAndTime("1990-01-02 00:00:02.000"), 1., 1.); WeightedEvent wghtEvent2( - 20.05, - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "1990-01-02 00:00:02.000000001"), - 1.05, 1.); + 20.05, Types::Core::DateAndTime("1990-01-02 00:00:02.000000001"), 1.05, + 1.); TS_ASSERT(wghtEvent1 == wghtEvent1); TS_ASSERT(!(wghtEvent1 == wghtEvent2)); diff --git a/Framework/DataObjects/test/ScanningWorkspaceBuilderTest.h b/Framework/DataObjects/test/ScanningWorkspaceBuilderTest.h index a17a8ee920a..d68f8ba5986 100644 --- a/Framework/DataObjects/test/ScanningWorkspaceBuilderTest.h +++ b/Framework/DataObjects/test/ScanningWorkspaceBuilderTest.h @@ -21,7 +21,7 @@ using namespace Mantid::Geometry; using namespace Mantid::HistogramData; using namespace Mantid::Kernel; using Mantid::DataObjects::ScanningWorkspaceBuilder; -using Mantid::Types::DateAndTime; +using Mantid::Types::Core::DateAndTime; namespace { Instrument_const_sptr createSimpleInstrument(size_t nDetectors, size_t nBins) { diff --git a/Framework/DataObjects/test/SplittersWorkspaceTest.h b/Framework/DataObjects/test/SplittersWorkspaceTest.h index 27836848c00..4b4d336d0e6 100644 --- a/Framework/DataObjects/test/SplittersWorkspaceTest.h +++ b/Framework/DataObjects/test/SplittersWorkspaceTest.h @@ -24,12 +24,12 @@ public: void testClone() { SplittersWorkspace splitterws; - Kernel::SplittingInterval s1(Mantid::Types::DateAndTime(10000), - Mantid::Types::DateAndTime(15000), 1); - Kernel::SplittingInterval s2(Mantid::Types::DateAndTime(20000), - Mantid::Types::DateAndTime(30000), 3); - Kernel::SplittingInterval s3(Mantid::Types::DateAndTime(40000), - Mantid::Types::DateAndTime(50000), 2); + Kernel::SplittingInterval s1(Types::Core::DateAndTime(10000), + Types::Core::DateAndTime(15000), 1); + Kernel::SplittingInterval s2(Types::Core::DateAndTime(20000), + Types::Core::DateAndTime(30000), 3); + Kernel::SplittingInterval s3(Types::Core::DateAndTime(40000), + Types::Core::DateAndTime(50000), 2); splitterws.addSplitter(s1); splitterws.addSplitter(s2); @@ -46,12 +46,12 @@ public: void test_Add() { DataObjects::SplittersWorkspace splitterws; - Kernel::SplittingInterval s1(Mantid::Types::DateAndTime(10000), - Mantid::Types::DateAndTime(15000), 1); - Kernel::SplittingInterval s2(Mantid::Types::DateAndTime(20000), - Mantid::Types::DateAndTime(30000), 3); - Kernel::SplittingInterval s3(Mantid::Types::DateAndTime(40000), - Mantid::Types::DateAndTime(50000), 2); + Kernel::SplittingInterval s1(Types::Core::DateAndTime(10000), + Types::Core::DateAndTime(15000), 1); + Kernel::SplittingInterval s2(Types::Core::DateAndTime(20000), + Types::Core::DateAndTime(30000), 3); + Kernel::SplittingInterval s3(Types::Core::DateAndTime(40000), + Types::Core::DateAndTime(50000), 2); TS_ASSERT_THROWS_NOTHING(splitterws.addSplitter(s1)); TS_ASSERT_THROWS_NOTHING(splitterws.addSplitter(s2)); @@ -63,12 +63,12 @@ public: void test_AddGet() { DataObjects::SplittersWorkspace splitterws; - Kernel::SplittingInterval s1(Mantid::Types::DateAndTime(10000), - Mantid::Types::DateAndTime(15000), 1); - Kernel::SplittingInterval s2(Mantid::Types::DateAndTime(20000), - Mantid::Types::DateAndTime(30000), 3); - Kernel::SplittingInterval s3(Mantid::Types::DateAndTime(40000), - Mantid::Types::DateAndTime(50000), 2); + Kernel::SplittingInterval s1(Types::Core::DateAndTime(10000), + Types::Core::DateAndTime(15000), 1); + Kernel::SplittingInterval s2(Types::Core::DateAndTime(20000), + Types::Core::DateAndTime(30000), 3); + Kernel::SplittingInterval s3(Types::Core::DateAndTime(40000), + Types::Core::DateAndTime(50000), 2); std::vector<Kernel::SplittingInterval> splitters; splitters.push_back(s1); diff --git a/Framework/DataObjects/test/WeightedEventNoTimeTest.h b/Framework/DataObjects/test/WeightedEventNoTimeTest.h index d14e0680897..10f5526182a 100644 --- a/Framework/DataObjects/test/WeightedEventNoTimeTest.h +++ b/Framework/DataObjects/test/WeightedEventNoTimeTest.h @@ -9,7 +9,7 @@ using namespace Mantid; using namespace Mantid::Kernel; using namespace Mantid::DataObjects; -using Mantid::Types::TofEvent; +using Mantid::Types::Event::TofEvent; using std::runtime_error; using std::size_t; diff --git a/Framework/DataObjects/test/WeightedEventTest.h b/Framework/DataObjects/test/WeightedEventTest.h index 4e73740183b..cfce5764277 100644 --- a/Framework/DataObjects/test/WeightedEventTest.h +++ b/Framework/DataObjects/test/WeightedEventTest.h @@ -9,11 +9,11 @@ using namespace Mantid; using namespace Mantid::Kernel; using namespace Mantid::DataObjects; -using Mantid::Types::TofEvent; using std::runtime_error; using std::size_t; using std::vector; +using Mantid::Types::Event::TofEvent; //========================================================================================== class WeightedEventTest : public CxxTest::TestSuite { diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument.h b/Framework/Geometry/inc/MantidGeometry/Instrument.h index d7cc324d1e4..82c605c140a 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument.h @@ -7,7 +7,7 @@ #include "MantidGeometry/Instrument/CompAssembly.h" #include "MantidGeometry/Instrument/ObjComponent.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include <string> #include <map> @@ -196,18 +196,18 @@ public: boost::shared_ptr<ParameterMap> getParameterMap() const; /// @return the date from which the instrument definition begins to be valid. - Mantid::Types::DateAndTime getValidFromDate() const { return m_ValidFrom; } + Types::Core::DateAndTime getValidFromDate() const { return m_ValidFrom; } /// @return the date at which the instrument definition is no longer valid. - Mantid::Types::DateAndTime getValidToDate() const { return m_ValidTo; } + Types::Core::DateAndTime getValidToDate() const { return m_ValidTo; } /// Set the date from which the instrument definition begins to be valid. /// @param val :: date - void setValidFromDate(const Mantid::Types::DateAndTime &val); + void setValidFromDate(const Types::Core::DateAndTime &val); /// Set the date at which the instrument definition is no longer valid. /// @param val :: date - void setValidToDate(const Mantid::Types::DateAndTime &val) { m_ValidTo = val; } + void setValidToDate(const Types::Core::DateAndTime &val) { m_ValidTo = val; } // Methods for use with indirect geometry instruments, // where the physical instrument differs from the 'neutronic' one @@ -313,9 +313,9 @@ private: boost::shared_ptr<ParameterMap> m_map_nonconst; /// the date from which the instrument definition begins to be valid. - Mantid::Types::DateAndTime m_ValidFrom; + Types::Core::DateAndTime m_ValidFrom; /// the date at which the instrument definition is no longer valid. - Mantid::Types::DateAndTime m_ValidTo; + Types::Core::DateAndTime m_ValidTo; /// Path to the original IDF .xml file that was loaded for this instrument mutable std::string m_filename; diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/DetectorInfo.h b/Framework/Geometry/inc/MantidGeometry/Instrument/DetectorInfo.h index 311bfd7cc89..c96ea3e1aff 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/DetectorInfo.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/DetectorInfo.h @@ -2,7 +2,7 @@ #define MANTID_GEOMETRY_DETECTORINFO_H_ #include "MantidGeometry/DllConfig.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/Quat.h" #include "MantidKernel/V3D.h" @@ -119,13 +119,13 @@ public: size_t indexOf(const detid_t id) const { return m_detIDToIndex->at(id); } size_t scanCount(const size_t index) const; - std::pair<Mantid::Types::DateAndTime, Mantid::Types::DateAndTime> + std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime> scanInterval(const std::pair<size_t, size_t> &index) const; void setScanInterval( const size_t index, - const std::pair<Mantid::Types::DateAndTime, Mantid::Types::DateAndTime> &interval); + const std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime> &interval); void setScanInterval( - const std::pair<Mantid::Types::DateAndTime, Mantid::Types::DateAndTime> &interval); + const std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime> &interval); void merge(const DetectorInfo &other); diff --git a/Framework/Geometry/inc/MantidGeometry/PrecompiledHeader.h b/Framework/Geometry/inc/MantidGeometry/PrecompiledHeader.h index f81fff60eb6..5103f70d301 100644 --- a/Framework/Geometry/inc/MantidGeometry/PrecompiledHeader.h +++ b/Framework/Geometry/inc/MantidGeometry/PrecompiledHeader.h @@ -9,7 +9,7 @@ #include "MantidKernel/Matrix.h" #include "MantidKernel/Exception.h" #include "MantidKernel/Logger.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/Interpolation.h" // STL diff --git a/Framework/Geometry/src/Instrument.cpp b/Framework/Geometry/src/Instrument.cpp index a0f66d6ee77..cffba155f0f 100644 --- a/Framework/Geometry/src/Instrument.cpp +++ b/Framework/Geometry/src/Instrument.cpp @@ -1,29 +1,27 @@ #include "MantidGeometry/Instrument.h" -#include "MantidBeamline/ComponentInfo.h" -#include "MantidBeamline/DetectorInfo.h" -#include "MantidGeometry/Instrument/ComponentInfo.h" -#include "MantidGeometry/Instrument/DetectorGroup.h" -#include "MantidGeometry/Instrument/DetectorInfo.h" -#include "MantidGeometry/Instrument/InstrumentVisitor.h" #include "MantidGeometry/Instrument/ParComponentFactory.h" +#include "MantidGeometry/Instrument/DetectorGroup.h" +#include "MantidGeometry/Instrument/ReferenceFrame.h" #include "MantidGeometry/Instrument/RectangularDetector.h" #include "MantidGeometry/Instrument/RectangularDetectorPixel.h" -#include "MantidGeometry/Instrument/ReferenceFrame.h" -#include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidGeometry/Instrument/ComponentInfo.h" +#include "MantidGeometry/Instrument/DetectorInfo.h" +#include "MantidGeometry/Instrument/InstrumentVisitor.h" #include "MantidKernel/EigenConversionHelpers.h" #include "MantidKernel/Exception.h" #include "MantidKernel/Logger.h" #include "MantidKernel/PhysicalConstants.h" #include "MantidKernel/make_unique.h" +#include "MantidBeamline/ComponentInfo.h" +#include "MantidBeamline/DetectorInfo.h" -#include <boost/make_shared.hpp> #include <nexus/NeXusFile.hpp> +#include <boost/make_shared.hpp> #include <queue> -using namespace Mantid::Types; using namespace Mantid::Kernel; -using Mantid::Kernel::Exception::InstrumentDefinitionError; using Mantid::Kernel::Exception::NotFoundError; +using Mantid::Kernel::Exception::InstrumentDefinitionError; namespace Mantid { namespace Geometry { @@ -199,8 +197,8 @@ void Instrument::setPhysicalInstrument(std::unique_ptr<Instrument> physInst) { //------------------------------------------------------------------------------------------ /** Fills a copy of the detector cache - * @returns a map of the detectors hold by the instrument - */ +* @returns a map of the detectors hold by the instrument +*/ void Instrument::getDetectors(detid2det_map &out_map) const { if (m_map) { // Get the base instrument detectors @@ -410,9 +408,9 @@ IComponent_const_sptr Instrument::getSample() const { } /** Gets the beam direction (i.e. source->sample direction). - * Not virtual because it relies the getSample() & getPos() virtual functions - * @returns A unit vector denoting the direction of the beam - */ +* Not virtual because it relies the getSample() & getPos() virtual functions +* @returns A unit vector denoting the direction of the beam +*/ Kernel::V3D Instrument::getBeamDirection() const { V3D retval = getSample()->getPos() - getSource()->getPos(); retval.normalize(); @@ -421,9 +419,9 @@ Kernel::V3D Instrument::getBeamDirection() const { //------------------------------------------------------------------------------------------ /** Get a shared pointer to a component by its ID, const version - * @param id :: ID - * @return A pointer to the component. - */ +* @param id :: ID +* @return A pointer to the component. +*/ boost::shared_ptr<const IComponent> Instrument::getComponentByID(const IComponent *id) const { const IComponent *base = static_cast<const IComponent *>(id); @@ -499,18 +497,18 @@ auto find(T &map, const detid_t key) -> decltype(map.begin()) { return it; return map.end(); } -} // namespace +} /** Gets a pointer to the detector from its ID - * Note that for getting the detector associated with a spectrum, the - * MatrixWorkspace::getDetector - * method should be used rather than this one because it takes account of the - * possibility of more - * than one detector contributing to a single spectrum - * @param detector_id The requested detector ID - * @returns A pointer to the detector object - * @throw NotFoundError If no detector is found for the detector ID given - */ +* Note that for getting the detector associated with a spectrum, the +* MatrixWorkspace::getDetector +* method should be used rather than this one because it takes account of the +* possibility of more +* than one detector contributing to a single spectrum +* @param detector_id The requested detector ID +* @returns A pointer to the detector object +* @throw NotFoundError If no detector is found for the detector ID given +*/ IDetector_const_sptr Instrument::getDetector(const detid_t &detector_id) const { const auto &baseInstr = m_map ? *m_instr : *this; const auto it = find(baseInstr.m_detectorCache, detector_id); @@ -530,10 +528,10 @@ IDetector_const_sptr Instrument::getDetector(const detid_t &detector_id) const { } /** Gets a pointer to the base (non-parametrized) detector from its ID - * returns null if the detector has not been found - * @param detector_id The requested detector ID - * @returns A const pointer to the detector object - */ + * returns null if the detector has not been found + * @param detector_id The requested detector ID + * @returns A const pointer to the detector object + */ const IDetector *Instrument::getBaseDetector(const detid_t &detector_id) const { auto it = find(m_instr->m_detectorCache, detector_id); if (it == m_instr->m_detectorCache.end()) { @@ -696,13 +694,13 @@ void Instrument::markAsSource(const IComponent *comp) { } /** Mark a Component which has already been added to the Instrument (as a child - *component) - * to be a Detector by adding it to a detector cache. - * - * @param det :: Component to be marked (stored for later retrieval) as a - *detector Component - * - */ +*component) +* to be a Detector by adding it to a detector cache. +* +* @param det :: Component to be marked (stored for later retrieval) as a +*detector Component +* +*/ void Instrument::markAsDetector(const IDetector *det) { if (m_map) throw std::runtime_error("Instrument::markAsDetector() called on a " @@ -739,12 +737,10 @@ void Instrument::markAsDetectorFinalize() { // detectors, even if the actual detector is different. We mimic this behavior // in this final sort by using stable_sort and removing duplicates. This will // effectively favor the first detector with a certain ID that was added. - std::stable_sort( - m_detectorCache.begin(), m_detectorCache.end(), - [](const std::tuple<detid_t, IDetector_const_sptr, bool> &a, - const std::tuple<detid_t, IDetector_const_sptr, bool> &b) -> bool { - return std::get<0>(a) < std::get<0>(b); - }); + std::stable_sort(m_detectorCache.begin(), m_detectorCache.end(), + [](const std::tuple<detid_t, IDetector_const_sptr, bool> &a, + const std::tuple<detid_t, IDetector_const_sptr, bool> &b) + -> bool { return std::get<0>(a) < std::get<0>(b); }); m_detectorCache.erase( std::unique(m_detectorCache.begin(), m_detectorCache.end(), [](const std::tuple<detid_t, IDetector_const_sptr, bool> &a, @@ -754,13 +750,13 @@ void Instrument::markAsDetectorFinalize() { } /** Mark a Component which has already been added to the Instrument class - * as a monitor and add it to the detector cache. - * - * @param det :: Component to be marked (stored for later retrieval) as a - *detector Component - * - * @throw Exception::ExistsError if cannot add detector to cache - */ +* as a monitor and add it to the detector cache. +* +* @param det :: Component to be marked (stored for later retrieval) as a +*detector Component +* +* @throw Exception::ExistsError if cannot add detector to cache +*/ void Instrument::markAsMonitor(const IDetector *det) { if (m_map) throw std::runtime_error("Instrument::markAsMonitor() called on a " @@ -1049,12 +1045,12 @@ void Instrument::saveNexus(::NeXus::File *file, } /* A private helper function so save information about a set of detectors to - * Nexus - * @param file :: open Nexus file ready to recieve the info about the set of - * detectors - * a group must be open that has only one call of this function. - * @param detIDs :: the dectector IDs of the detectors belonging to the set - */ +* Nexus +* @param file :: open Nexus file ready to recieve the info about the set of +* detectors +* a group must be open that has only one call of this function. +* @param detIDs :: the dectector IDs of the detectors belonging to the set +*/ void Instrument::saveDetectorSetInfoToNexus( ::NeXus::File *file, const std::vector<detid_t> &detIDs) const { @@ -1099,9 +1095,9 @@ void Instrument::saveDetectorSetInfoToNexus( //-------------------------------------------------------------------------------------------- /** Load the object from an open NeXus file. - * @param file :: open NeXus file - * @param group :: name of the group to open - */ +* @param file :: open NeXus file +* @param group :: name of the group to open +*/ void Instrument::loadNexus(::NeXus::File *file, const std::string &group) { file->openGroup(group, "NXinstrument"); file->closeGroup(); @@ -1156,9 +1152,8 @@ void Instrument::setDefaultView(const std::string &type) { /// @param val :: date and time /// @throw InstrumentDefinitionError Thrown if date is earlier than 1900-01-31 /// 23:59:01 -void Instrument::setValidFromDate(const Mantid::Types::DateAndTime &val) { - DateAndTime earliestAllowedDate = - DateAndTimeHelpers::createFromISO8601("1900-01-31 23:59:01"); +void Instrument::setValidFromDate(const Types::Core::DateAndTime &val) { + Types::Core::DateAndTime earliestAllowedDate("1900-01-31 23:59:01"); if (val < earliestAllowedDate) { throw Kernel::Exception::InstrumentDefinitionError( "The valid-from <instrument> tag date must be from 1900-01-31 23:59:01 " @@ -1467,6 +1462,6 @@ double tofToDSpacingFactor(const double l1, const double l2, } return factor / static_cast<double>(detectors.size()); } -} // namespace Conversion +} } // namespace Geometry } // Namespace Mantid diff --git a/Framework/Geometry/src/Instrument/DetectorInfo.cpp b/Framework/Geometry/src/Instrument/DetectorInfo.cpp index 17fa7defb40..3e0ddec4d58 100644 --- a/Framework/Geometry/src/Instrument/DetectorInfo.cpp +++ b/Framework/Geometry/src/Instrument/DetectorInfo.cpp @@ -324,8 +324,8 @@ size_t DetectorInfo::scanCount(const size_t index) const { /** Returns the scan interval of the detector with given index. * * The interval start and end values would typically correspond to nanoseconds - * since 1990, as in Mantid::Types::DateAndTime. */ -std::pair<Mantid::Types::DateAndTime, Mantid::Types::DateAndTime> + * since 1990, as in Types::Core::DateAndTime. */ +std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime> DetectorInfo::scanInterval(const std::pair<size_t, size_t> &index) const { const auto &interval = m_detectorInfo->scanInterval(index); return {interval.first, interval.second}; @@ -334,13 +334,13 @@ DetectorInfo::scanInterval(const std::pair<size_t, size_t> &index) const { /** Set the scan interval of the detector with given detector index. * * The interval start and end values would typically correspond to nanoseconds - * since 1990, as in Mantid::Types::DateAndTime. Note that it is currently not possible + * since 1990, as in Types::Core::DateAndTime. Note that it is currently not possible * to modify scan intervals for a DetectorInfo with time-dependent detectors, * i.e., time intervals must be set with this method before merging individual * scans. */ void DetectorInfo::setScanInterval( const size_t index, - const std::pair<Mantid::Types::DateAndTime, Mantid::Types::DateAndTime> &interval) { + const std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime> &interval) { m_detectorInfo->setScanInterval(index, {interval.first.totalNanoseconds(), interval.second.totalNanoseconds()}); } @@ -350,7 +350,7 @@ void DetectorInfo::setScanInterval( * Prefer this over setting intervals for individual detectors since it enables * internal performance optimization. See also overload for other details. */ void DetectorInfo::setScanInterval( - const std::pair<Mantid::Types::DateAndTime, Mantid::Types::DateAndTime> &interval) { + const std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime> &interval) { m_detectorInfo->setScanInterval( {interval.first.totalNanoseconds(), interval.second.totalNanoseconds()}); } diff --git a/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp b/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp index b83a92e5477..c79b38a28ab 100644 --- a/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp +++ b/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp @@ -18,7 +18,6 @@ #include "MantidKernel/Strings.h" #include "MantidKernel/UnitFactory.h" #include "MantidKernel/make_unique.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include <Poco/DOM/DOMParser.h> #include <Poco/DOM/DOMWriter.h> @@ -38,7 +37,7 @@ using namespace Mantid; using namespace Mantid::Kernel; -using namespace Mantid::Types; +using namespace Mantid::Types::Core; using Poco::XML::DOMParser; using Poco::XML::Document; using Poco::XML::Element; @@ -930,7 +929,7 @@ void InstrumentDefinitionParser::setValidityRange( "<instrument> element must contain a valid-from tag", filename); } else { try { - DateAndTime d = DateAndTimeHelpers::createFromISO8601(pRootElem->getAttribute("valid-from")); + DateAndTime d(pRootElem->getAttribute("valid-from")); m_instrument->setValidFromDate(d); } catch (...) { throw Kernel::Exception::InstrumentDefinitionError( @@ -946,7 +945,7 @@ void InstrumentDefinitionParser::setValidityRange( // must contain a valid-to tag", filename); } else { try { - DateAndTime d = DateAndTimeHelpers::createFromISO8601(pRootElem->getAttribute("valid-to")); + DateAndTime d(pRootElem->getAttribute("valid-to")); m_instrument->setValidToDate(d); } catch (...) { throw Kernel::Exception::InstrumentDefinitionError( diff --git a/Framework/Geometry/src/Instrument/ParameterMap.cpp b/Framework/Geometry/src/Instrument/ParameterMap.cpp index 8dc00a18a15..21c62087af1 100644 --- a/Framework/Geometry/src/Instrument/ParameterMap.cpp +++ b/Framework/Geometry/src/Instrument/ParameterMap.cpp @@ -1125,7 +1125,7 @@ void ParameterMap::saveNexus(::NeXus::File *file, file->putAttr("version", 1); file->writeData("author", ""); file->writeData("date", - Mantid::Types::DateAndTime::getCurrentTime().toISO8601String()); + Types::Core::DateAndTime::getCurrentTime().toISO8601String()); file->writeData("description", "A string representation of the parameter " "map. The format is either: " "|detID:id-value;param-type;param-name;param-" diff --git a/Framework/Geometry/test/InstrumentTest.h b/Framework/Geometry/test/InstrumentTest.h index ef3342cf5e8..6484c48b07a 100644 --- a/Framework/Geometry/test/InstrumentTest.h +++ b/Framework/Geometry/test/InstrumentTest.h @@ -2,17 +2,17 @@ #define INSTRUMENTTEST_H_ #include "MantidGeometry/Instrument.h" +#include "MantidKernel/EigenConversionHelpers.h" +#include "MantidKernel/Exception.h" +#include "MantidTestHelpers/ComponentCreationHelper.h" #include "MantidGeometry/Instrument/ComponentInfo.h" #include "MantidGeometry/Instrument/DetectorGroup.h" #include "MantidGeometry/Instrument/DetectorInfo.h" -#include "MantidGeometry/Instrument/ParameterMap.h" #include "MantidGeometry/Instrument/RectangularDetector.h" -#include "MantidKernel/DateAndTimeHelpers.h" -#include "MantidKernel/EigenConversionHelpers.h" -#include "MantidKernel/Exception.h" -#include "MantidTestHelpers/ComponentCreationHelper.h" -#include <boost/make_shared.hpp> #include <cxxtest/TestSuite.h> +#include "MantidKernel/DateAndTime.h" +#include "MantidGeometry/Instrument/ParameterMap.h" +#include <boost/make_shared.hpp> using namespace Mantid; using namespace Mantid::Kernel; @@ -419,12 +419,8 @@ public: void test_getValidFromDate() { Instrument_sptr inst = ComponentCreationHelper::createTestInstrumentRectangular(5, 6); - Mantid::Types::DateAndTime validFrom = - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "1900-01-31T23:59:59"); - Mantid::Types::DateAndTime validTo = - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2100-01-31 23:59:59"); + Types::Core::DateAndTime validFrom("1900-01-31T23:59:59"); + Types::Core::DateAndTime validTo("2100-01-31 23:59:59"); inst->setValidFromDate(validFrom); inst->setValidToDate(validTo); TS_ASSERT_EQUALS(inst->getValidFromDate(), validFrom); @@ -596,10 +592,9 @@ public: TS_ASSERT(toQuaterniond(legacyInstrument.getDetector(19)->getRotation()) .isApprox(toQuaterniond(detRot * bankRot), 1e-10)); // Check the scale factor - TS_ASSERT( - toVector3d( - legacyInstrument.getComponentByName("bank3")->getScaleFactor()) - .isApprox(toVector3d(newScaleFactor), 1e-10)); + TS_ASSERT(toVector3d(legacyInstrument.getComponentByName("bank3") + ->getScaleFactor()) + .isApprox(toVector3d(newScaleFactor), 1e-10)); } void test_makeLegacyParameterMap_scaled_RectangularDetector() { diff --git a/Framework/ICat/inc/MantidICat/ICat4/ICat4Catalog.h b/Framework/ICat/inc/MantidICat/ICat4/ICat4Catalog.h index 970ba84d5e7..2ac16c89d90 100644 --- a/Framework/ICat/inc/MantidICat/ICat4/ICat4Catalog.h +++ b/Framework/ICat/inc/MantidICat/ICat4/ICat4Catalog.h @@ -5,7 +5,6 @@ #include "MantidAPI/ICatalogInfoService.h" #include "MantidAPI/TableRow.h" #include "MantidICat/CatalogSearchParam.h" -#include "MantidICat/ICat4/GSoapGenerated/ICat4ICATPortBindingProxy.h" namespace Mantid { namespace ICat { diff --git a/Framework/ICat/src/CatalogKeepAlive.cpp b/Framework/ICat/src/CatalogKeepAlive.cpp index 49eef32ca6c..a5b169645fc 100644 --- a/Framework/ICat/src/CatalogKeepAlive.cpp +++ b/Framework/ICat/src/CatalogKeepAlive.cpp @@ -1,6 +1,6 @@ #include "MantidICat/CatalogKeepAlive.h" #include "MantidAPI/CatalogManager.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include <Poco/Thread.h> @@ -22,7 +22,7 @@ void CatalogKeepAlive::exec() { if (timePeriod <= 0) throw std::runtime_error("TimePeriod must be greater than zero."); - Mantid::Types::DateAndTime lastTimeExecuted = Mantid::Types::DateAndTime::getCurrentTime(); + Types::Core::DateAndTime lastTimeExecuted = Types::Core::DateAndTime::getCurrentTime(); // Keep going until cancelled while (true) { @@ -31,14 +31,14 @@ void CatalogKeepAlive::exec() { // Exit if the user presses cancel this->interruption_point(); - double secondsSinceExecuted = Mantid::Types::DateAndTime::secondsFromDuration( - Mantid::Types::DateAndTime::getCurrentTime() - lastTimeExecuted); + double secondsSinceExecuted = Types::Core::DateAndTime::secondsFromDuration( + Types::Core::DateAndTime::getCurrentTime() - lastTimeExecuted); if (secondsSinceExecuted > timePeriod) { API::CatalogManager::Instance() .getCatalog(getPropertyValue("Session")) ->keepAlive(); - lastTimeExecuted = Mantid::Types::DateAndTime::getCurrentTime(); + lastTimeExecuted = Types::Core::DateAndTime::getCurrentTime(); } } } diff --git a/Framework/ICat/src/CatalogSearchParam.cpp b/Framework/ICat/src/CatalogSearchParam.cpp index 54db9200343..f78374ff5b8 100644 --- a/Framework/ICat/src/CatalogSearchParam.cpp +++ b/Framework/ICat/src/CatalogSearchParam.cpp @@ -1,5 +1,5 @@ #include "MantidICat/CatalogSearchParam.h" -#include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidKernel/DateAndTime.h" #include <boost/algorithm/string/regex.hpp> namespace Mantid { @@ -222,8 +222,7 @@ time_t CatalogSearchParam::getTimevalue(const std::string &inputDate) { std::string isoDate = dateSegments.at(2) + "-" + dateSegments.at(1) + "-" + dateSegments.at(0) + " 0:00:00.000"; // Return the date as time_t value. - return Mantid::Types::DateAndTimeHelpers::createFromISO8601(isoDate) - .to_time_t(); + return Types::Core::DateAndTime(isoDate).to_time_t(); +} +} } -} // namespace ICat -} // namespace Mantid diff --git a/Framework/ICat/src/ICat4/ICat4Catalog.cpp b/Framework/ICat/src/ICat4/ICat4Catalog.cpp index 2248d2c5f6e..e89b60397bf 100644 --- a/Framework/ICat/src/ICat4/ICat4Catalog.cpp +++ b/Framework/ICat/src/ICat4/ICat4Catalog.cpp @@ -1,23 +1,25 @@ -#include "MantidICat/ICat4/ICat4Catalog.h" -#include "MantidAPI/CatalogFactory.h" #include "MantidAPI/ITableWorkspace.h" +#include "MantidAPI/CatalogFactory.h" #include "MantidAPI/Progress.h" #include "MantidAPI/WorkspaceFactory.h" +#include "MantidICat/ICat4/GSoapGenerated/ICat4ICATPortBindingProxy.h" +#include "MantidICat/ICat4/ICat4Catalog.h" #include "MantidKernel/ConfigService.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/FacilityInfo.h" #include "MantidKernel/Logger.h" #include "MantidKernel/Strings.h" -#include "MantidTypes/DateAndTime.h" namespace Mantid { namespace ICat { using namespace Kernel; using namespace ICat4; +using Types::Core::DateAndTime; namespace { /// static logger Logger g_log("ICat4Catalog"); -} // namespace +} DECLARE_CATALOG(ICat4Catalog) @@ -779,7 +781,7 @@ std::string ICat4Catalog::bytesToString(int64_t &fileSize) { */ std::string ICat4Catalog::formatDateTime(const time_t ×tamp, const std::string &format) { - auto dateTime = Types::DateAndTime(boost::posix_time::from_time_t(timestamp)); + auto dateTime = DateAndTime(boost::posix_time::from_time_t(timestamp)); return (dateTime.toFormattedString(format)); } @@ -947,5 +949,5 @@ bool ICat4Catalog::isAccessAllowed(ns1__accessType accessType, T &bean) { throwErrorMessage(icat); return false; } -} // namespace ICat -} // namespace Mantid +} +} diff --git a/Framework/Kernel/inc/MantidKernel/DateAndTimeHelpers.h b/Framework/Kernel/inc/MantidKernel/DateAndTimeHelpers.h index f7628aa3b9a..225ab3b1d01 100644 --- a/Framework/Kernel/inc/MantidKernel/DateAndTimeHelpers.h +++ b/Framework/Kernel/inc/MantidKernel/DateAndTimeHelpers.h @@ -8,7 +8,7 @@ namespace Mantid { namespace Kernel { namespace DateAndTimeHelpers { -MANTID_KERNEL_DLL DateAndTime +MANTID_KERNEL_DLL Types::Core::DateAndTime createFromSanitizedISO8601(const std::string &date); MANTID_KERNEL_DLL bool stringIsISO8601(const std::string &date); diff --git a/Framework/Kernel/inc/MantidKernel/IPropertyManager.h b/Framework/Kernel/inc/MantidKernel/IPropertyManager.h index 76b497fe93d..0cae67e8549 100644 --- a/Framework/Kernel/inc/MantidKernel/IPropertyManager.h +++ b/Framework/Kernel/inc/MantidKernel/IPropertyManager.h @@ -1,11 +1,11 @@ #ifndef MANTID_KERNEL_IPROPERTYMANAGER_H_ #define MANTID_KERNEL_IPROPERTYMANAGER_H_ +#include "MantidKernel/PropertyWithValue.h" +#include "MantidKernel/make_unique.h" #include "MantidKernel/DllConfig.h" #include "MantidKernel/IValidator.h" #include "MantidKernel/NullValidator.h" -#include "MantidKernel/PropertyWithValue.h" -#include "MantidKernel/make_unique.h" #ifndef Q_MOC_RUN #include <boost/make_shared.hpp> @@ -24,8 +24,10 @@ class Value; namespace Mantid { namespace Types { +namespace Core { class DateAndTime; } +} // namespace Types namespace Kernel { class DataItem; @@ -90,8 +92,8 @@ public: */ virtual void setPropertiesWithString( const std::string &propertiesString, - const std::unordered_set<std::string> &ignoreProperties = - std::unordered_set<std::string>()) = 0; + const std::unordered_set<std::string> & + ignoreProperties = std::unordered_set<std::string>()) = 0; /** Sets all the declared properties from a string. @param propertiesJson :: A string of name = value pairs formatted @@ -101,8 +103,8 @@ public: */ virtual void setProperties(const std::string &propertiesJson, - const std::unordered_set<std::string> &ignoreProperties = - std::unordered_set<std::string>()) = 0; + const std::unordered_set<std::string> & + ignoreProperties = std::unordered_set<std::string>()) = 0; /** Sets all the declared properties from a json object @param jsonValue :: A json name value pair collection @@ -111,8 +113,8 @@ public: */ virtual void setProperties(const ::Json::Value &jsonValue, - const std::unordered_set<std::string> &ignoreProperties = - std::unordered_set<std::string>()) = 0; + const std::unordered_set<std::string> & + ignoreProperties = std::unordered_set<std::string>()) = 0; /** Sets property value from a string @param name :: Property name @@ -170,24 +172,24 @@ public: } /** Specialised version of setProperty template method to handle const char * - * @param name :: The name of the property (case insensitive) - * @param value :: The value to assign to the property - * @throw Exception::NotFoundError If the named property is unknown - * @throw std::invalid_argument If an attempt is made to assign to a property - * of different type - */ + * @param name :: The name of the property (case insensitive) + * @param value :: The value to assign to the property + * @throw Exception::NotFoundError If the named property is unknown + * @throw std::invalid_argument If an attempt is made to assign to a property + * of different type + */ IPropertyManager *setProperty(const std::string &name, const char *value) { this->setPropertyValue(name, std::string(value)); return this; } /** Specialised version of setProperty template method to handle std::string - * @param name :: The name of the property (case insensitive) - * @param value :: The value to assign to the property - * @throw Exception::NotFoundError If the named property is unknown - * @throw std::invalid_argument If an attempt is made to assign to a property - * of different type - */ + * @param name :: The name of the property (case insensitive) + * @param value :: The value to assign to the property + * @throw Exception::NotFoundError If the named property is unknown + * @throw std::invalid_argument If an attempt is made to assign to a property + * of different type + */ IPropertyManager *setProperty(const std::string &name, const std::string &value) { this->setPropertyValue(name, value); @@ -218,8 +220,8 @@ public: /// Get the list of managed properties in a given group. std::vector<Property *> getPropertiesInGroup(const std::string &group) const; - virtual void filterByTime(const Types::DateAndTime & /*start*/, - const Types::DateAndTime & /*stop*/) = 0; + virtual void filterByTime(const Types::Core::DateAndTime & /*start*/, + const Types::Core::DateAndTime & /*stop*/) = 0; virtual void splitByTime(std::vector<SplittingInterval> & /*splitter*/, std::vector<PropertyManager *> /* outputs*/) const = 0; @@ -227,16 +229,16 @@ public: protected: /** Add a property of the template type to the list of managed properties - * @param name :: The name to assign to the property - * @param value :: The initial value to assign to the property - * @param validator :: Pointer to the (optional) validator. - * @param doc :: The (optional) documentation string - * @param direction :: The (optional) direction of the property, in, out or - * inout - * @throw Exception::ExistsError if a property with the given name already - * exists - * @throw std::invalid_argument if the name argument is empty - */ + * @param name :: The name to assign to the property + * @param value :: The initial value to assign to the property + * @param validator :: Pointer to the (optional) validator. + * @param doc :: The (optional) documentation string + * @param direction :: The (optional) direction of the property, in, out or + * inout + * @throw Exception::ExistsError if a property with the given name already + * exists + * @throw std::invalid_argument if the name argument is empty + */ template <typename T> void declareProperty( const std::string &name, T value, @@ -250,15 +252,15 @@ protected: } /** Add a property to the list of managed properties with no validator - * @param name :: The name to assign to the property - * @param value :: The initial value to assign to the property - * @param doc :: The documentation string - * @param direction :: The (optional) direction of the property, in - * (default), out or inout - * @throw Exception::ExistsError if a property with the given name already - * exists - * @throw std::invalid_argument if the name argument is empty - */ + * @param name :: The name to assign to the property + * @param value :: The initial value to assign to the property + * @param doc :: The documentation string + * @param direction :: The (optional) direction of the property, in (default), + * out or inout + * @throw Exception::ExistsError if a property with the given name already + * exists + * @throw std::invalid_argument if the name argument is empty + */ template <typename T> void declareProperty(const std::string &name, T value, const std::string &doc, const unsigned int direction = Direction::Input) { @@ -269,13 +271,13 @@ protected: } /** Add a property of the template type to the list of managed properties - * @param name :: The name to assign to the property - * @param value :: The initial value to assign to the property - * @param direction :: The direction of the property, in, out or inout - * @throw Exception::ExistsError if a property with the given name already - * exists - * @throw std::invalid_argument if the name argument is empty - */ + * @param name :: The name to assign to the property + * @param value :: The initial value to assign to the property + * @param direction :: The direction of the property, in, out or inout + * @throw Exception::ExistsError if a property with the given name already + * exists + * @throw std::invalid_argument if the name argument is empty + */ template <typename T> void declareProperty(const std::string &name, T value, const unsigned int direction) { @@ -286,22 +288,22 @@ protected: } /** Specialised version of declareProperty template method to prevent the - * creation of a - * PropertyWithValue of type const char* if an argument in quotes is passed - * (it will be - * converted to a string). The validator, if provided, needs to be a string - * validator. - * @param name :: The name to assign to the property - * @param value :: The initial value to assign to the property - * @param validator :: Pointer to the (optional) validator. Ownership will be - * taken over. - * @param doc :: The (optional) documentation string - * @param direction :: The (optional) direction of the property, in, out or - * inout - * @throw Exception::ExistsError if a property with the given name already - * exists - * @throw std::invalid_argument if the name argument is empty - */ + * creation of a + * PropertyWithValue of type const char* if an argument in quotes is passed + * (it will be + * converted to a string). The validator, if provided, needs to be a string + * validator. + * @param name :: The name to assign to the property + * @param value :: The initial value to assign to the property + * @param validator :: Pointer to the (optional) validator. Ownership will be + * taken over. + * @param doc :: The (optional) documentation string + * @param direction :: The (optional) direction of the property, in, out or + * inout + * @throw Exception::ExistsError if a property with the given name already + * exists + * @throw std::invalid_argument if the name argument is empty + */ void declareProperty( const std::string &name, const char *value, IValidator_sptr validator = boost::make_shared<NullValidator>(), @@ -313,22 +315,22 @@ protected: } /** Specialised version of declareProperty template method to prevent the - * creation of a - * PropertyWithValue of type const char* if an argument in quotes is passed - * (it will be - * converted to a string). The validator, if provided, needs to be a string - * validator. - * @param name :: The name to assign to the property - * @param value :: The initial value to assign to the property - * @param doc :: The (optional) documentation string - * @param validator :: Pointer to the (optional) validator. Ownership will be - * taken over. - * @param direction :: The (optional) direction of the property, in, out or - * inout - * @throw Exception::ExistsError if a property with the given name already - * exists - * @throw std::invalid_argument if the name argument is empty - */ + * creation of a + * PropertyWithValue of type const char* if an argument in quotes is passed + * (it will be + * converted to a string). The validator, if provided, needs to be a string + * validator. + * @param name :: The name to assign to the property + * @param value :: The initial value to assign to the property + * @param doc :: The (optional) documentation string + * @param validator :: Pointer to the (optional) validator. Ownership will be + * taken over. + * @param direction :: The (optional) direction of the property, in, out or + * inout + * @throw Exception::ExistsError if a property with the given name already + * exists + * @throw std::invalid_argument if the name argument is empty + */ void declareProperty( const std::string &name, const char *value, const std::string &doc, IValidator_sptr validator = boost::make_shared<NullValidator>(), @@ -339,13 +341,13 @@ protected: } /** Add a property of string type to the list of managed properties - * @param name :: The name to assign to the property - * @param value :: The initial value to assign to the property - * @param direction :: The direction of the property, in, out or inout - * @throw Exception::ExistsError if a property with the given name already - * exists - * @throw std::invalid_argument if the name argument is empty - */ + * @param name :: The name to assign to the property + * @param value :: The initial value to assign to the property + * @param direction :: The direction of the property, in, out or inout + * @throw Exception::ExistsError if a property with the given name already + * exists + * @throw std::invalid_argument if the name argument is empty + */ void declareProperty(const std::string &name, const char *value, const unsigned int direction) { declareProperty(name, std::string(value), diff --git a/Framework/Kernel/inc/MantidKernel/ITimeSeriesProperty.h b/Framework/Kernel/inc/MantidKernel/ITimeSeriesProperty.h index f594f879dcf..5f1477ffd4a 100644 --- a/Framework/Kernel/inc/MantidKernel/ITimeSeriesProperty.h +++ b/Framework/Kernel/inc/MantidKernel/ITimeSeriesProperty.h @@ -5,8 +5,10 @@ namespace Mantid { namespace Types { +namespace Core { class DateAndTime; } +} // namespace Types namespace Kernel { //--------------------------------------------------------------------------- // Forward Declarations @@ -52,7 +54,7 @@ public: virtual double averageValueInFilter(const std::vector<SplittingInterval> &filter) const = 0; /// Return the time series's times as a vector<DateAndTime> - virtual std::vector<Types::DateAndTime> timesAsVector() const = 0; + virtual std::vector<Types::Core::DateAndTime> timesAsVector() const = 0; /// Returns the calculated time weighted average value virtual double timeAverageValue() const = 0; /// Returns the real size of the time series property map: diff --git a/Framework/Kernel/inc/MantidKernel/LogParser.h b/Framework/Kernel/inc/MantidKernel/LogParser.h index 9eb5b9e376a..f74caf20812 100644 --- a/Framework/Kernel/inc/MantidKernel/LogParser.h +++ b/Framework/Kernel/inc/MantidKernel/LogParser.h @@ -15,14 +15,15 @@ namespace Mantid { namespace Types { +namespace Core { class DateAndTime; } +} // namespace Types namespace Kernel { //------------------------------------------------------------------------- // Forward declarations //------------------------------------------------------------------------- - class Property; template <typename T> class TimeSeriesProperty; @@ -66,7 +67,7 @@ public: const std::string &name); /// Check if the icp log commands are in the new style static bool isICPEventLogNewStyle( - const std::multimap<Mantid::Types::DateAndTime, std::string> &logm); + const std::multimap<Types::Core::DateAndTime, std::string> &logm); public: /// Create given the icpevent log property @@ -91,13 +92,13 @@ public: private: /// Parse the icp event log with old style commands void parseOldStyleCommands( - const std::multimap<Mantid::Types::DateAndTime, std::string> &logm, + const std::multimap<Types::Core::DateAndTime, std::string> &logm, Kernel::TimeSeriesProperty<int> *periods, Kernel::TimeSeriesProperty<bool> *status); /// Parse the icp event log with new style commands void parseNewStyleCommands( - const std::multimap<Mantid::Types::DateAndTime, std::string> &logm, + const std::multimap<Types::Core::DateAndTime, std::string> &logm, Kernel::TimeSeriesProperty<int> *periods, Kernel::TimeSeriesProperty<bool> *status); @@ -121,7 +122,8 @@ private: CommandMap createCommandMap(bool newStyle) const; /// Try to parse period data. - void tryParsePeriod(const std::string &scom, const Types::DateAndTime &time, + void tryParsePeriod(const std::string &scom, + const Types::Core::DateAndTime &time, std::istringstream &idata, Kernel::TimeSeriesProperty<int> *const periods); }; diff --git a/Framework/Kernel/inc/MantidKernel/Property.h b/Framework/Kernel/inc/MantidKernel/Property.h index c4feb181c0b..cbecbebeebe 100644 --- a/Framework/Kernel/inc/MantidKernel/Property.h +++ b/Framework/Kernel/inc/MantidKernel/Property.h @@ -23,14 +23,15 @@ class typeinfo; namespace Mantid { namespace Types { +namespace Core { class DateAndTime; } +} // namespace Types namespace Kernel { //----------------------------------------------------------------------------- // Forward declarations //----------------------------------------------------------------------------- class DataItem; - class IPropertySettings; class PropertyHistory; class SplittingInterval; @@ -160,8 +161,8 @@ public: virtual std::string getDefault() const = 0; /** Is Multiple Selection Allowed - * @return true if multiple selection is allowed - */ + * @return true if multiple selection is allowed + */ virtual bool isMultipleSelectionAllowed() { return false; }; virtual std::vector<std::string> allowedValues() const; @@ -178,8 +179,8 @@ public: /// Add to this virtual Property &operator+=(Property const *rhs) = 0; - virtual void filterByTime(const Mantid::Types::DateAndTime &start, - const Mantid::Types::DateAndTime &stop); + virtual void filterByTime(const Types::Core::DateAndTime &start, + const Types::Core::DateAndTime &stop); virtual void splitByTime(std::vector<SplittingInterval> &splitter, std::vector<Property *> outputs, bool isProtonCharge = true) const; @@ -193,8 +194,8 @@ public: virtual size_t getMemorySize() const { return sizeof(Property); } /** Just returns the property (*this) unless overridden - * @return a property with the value - */ + * @return a property with the value + */ virtual Property &merge(Property *) { return *this; } /// Set the group this property belongs to diff --git a/Framework/Kernel/inc/MantidKernel/PropertyManager.h b/Framework/Kernel/inc/MantidKernel/PropertyManager.h index 6f189cc1e53..dc1d192135b 100644 --- a/Framework/Kernel/inc/MantidKernel/PropertyManager.h +++ b/Framework/Kernel/inc/MantidKernel/PropertyManager.h @@ -62,8 +62,8 @@ public: PropertyManager &operator=(const PropertyManager &); PropertyManager &operator+=(const PropertyManager &rhs); - void filterByTime(const Mantid::Types::DateAndTime &start, - const Mantid::Types::DateAndTime &stop) override; + void filterByTime(const Types::Core::DateAndTime &start, + const Types::Core::DateAndTime &stop) override; void splitByTime(std::vector<SplittingInterval> &splitter, std::vector<PropertyManager *> outputs) const override; void filterByProperty(const TimeSeriesProperty<bool> &filter) override; diff --git a/Framework/Kernel/inc/MantidKernel/PropertyManagerOwner.h b/Framework/Kernel/inc/MantidKernel/PropertyManagerOwner.h index 8a25a30c7a1..b8ae6d7a680 100644 --- a/Framework/Kernel/inc/MantidKernel/PropertyManagerOwner.h +++ b/Framework/Kernel/inc/MantidKernel/PropertyManagerOwner.h @@ -111,8 +111,8 @@ public: /// The argument is the property name. Default - do nothing. void afterPropertySet(const std::string &) override; - void filterByTime(const Types::DateAndTime & /*start*/, - const Types::DateAndTime & /*stop*/) override { + void filterByTime(const Types::Core::DateAndTime & /*start*/, + const Types::Core::DateAndTime & /*stop*/) override { throw(std::runtime_error("Not yet implmented")); } void splitByTime(std::vector<SplittingInterval> & /*splitter*/, diff --git a/Framework/Kernel/inc/MantidKernel/TimeSeriesProperty.h b/Framework/Kernel/inc/MantidKernel/TimeSeriesProperty.h index eef3f5a5d68..1f39d3d73a9 100644 --- a/Framework/Kernel/inc/MantidKernel/TimeSeriesProperty.h +++ b/Framework/Kernel/inc/MantidKernel/TimeSeriesProperty.h @@ -4,11 +4,11 @@ //---------------------------------------------------------------------- // Includes //---------------------------------------------------------------------- +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/DllConfig.h" #include "MantidKernel/ITimeSeriesProperty.h" #include "MantidKernel/Property.h" #include "MantidKernel/Statistics.h" -#include "MantidTypes/DateAndTime.h" #include <cstdint> #include <utility> @@ -49,11 +49,11 @@ struct TimeSeriesPropertyStatistics { */ template <class TYPE> class TimeValueUnit { private: - Mantid::Types::DateAndTime mtime; + Types::Core::DateAndTime mtime; TYPE mvalue; public: - TimeValueUnit(const Mantid::Types::DateAndTime &time, TYPE value) { + TimeValueUnit(const Types::Core::DateAndTime &time, TYPE value) { mtime = time; mvalue = value; } @@ -78,9 +78,9 @@ public: return (lhs.mtime < rhs.mtime); } - Mantid::Types::DateAndTime time() const { return mtime; } + Types::Core::DateAndTime time() const { return mtime; } - void setTime(Mantid::Types::DateAndTime newtime) { mtime = newtime; } + void setTime(Types::Core::DateAndTime newtime) { mtime = newtime; } TYPE value() const { return mvalue; } @@ -154,8 +154,8 @@ public: void setName(const std::string name); /// Filter out a run by time. - void filterByTime(const Mantid::Types::DateAndTime &start, - const Mantid::Types::DateAndTime &stop) override; + void filterByTime(const Types::Core::DateAndTime &start, + const Types::Core::DateAndTime &stop) override; /// Filter by a range of times void filterByTimes(const std::vector<SplittingInterval> &splittervec); @@ -166,7 +166,7 @@ public: /// New split method void - splitByTimeVector(std::vector<Mantid::Types::DateAndTime> &splitter_time_vec, + splitByTimeVector(std::vector<Types::Core::DateAndTime> &splitter_time_vec, std::vector<int> &target_vec, std::vector<TimeSeriesProperty *> outputs); @@ -184,47 +184,47 @@ public: /// Calculate the time-weighted average of a property double timeAverageValue() const override; /// generate constant time-step histogram from the property values - void histogramData(const Mantid::Types::DateAndTime &tMin, - const Mantid::Types::DateAndTime &tMax, + void histogramData(const Types::Core::DateAndTime &tMin, + const Types::Core::DateAndTime &tMax, std::vector<double> &counts) const; /// Return the time series as a correct C++ map<DateAndTime, TYPE>. All /// values - std::map<Mantid::Types::DateAndTime, TYPE> valueAsCorrectMap() const; + std::map<Types::Core::DateAndTime, TYPE> valueAsCorrectMap() const; /// Return the time series's values (unfiltered) as a vector<TYPE> std::vector<TYPE> valuesAsVector() const; /// Return the time series as a correct C++ multimap<DateAndTime, TYPE>. All /// values - std::multimap<Mantid::Types::DateAndTime, TYPE> valueAsMultiMap() const; + std::multimap<Types::Core::DateAndTime, TYPE> valueAsMultiMap() const; /// Get filtered values as a vector std::vector<TYPE> filteredValuesAsVector() const; /// Return the time series's times as a vector<DateAndTime> - std::vector<Mantid::Types::DateAndTime> timesAsVector() const override; + std::vector<Types::Core::DateAndTime> timesAsVector() const override; /// Return the series as list of times, where the time is the number of /// seconds since the start. std::vector<double> timesAsVectorSeconds() const; /// Add a value to the map using a DateAndTime object - void addValue(const Mantid::Types::DateAndTime &time, const TYPE value); + void addValue(const Types::Core::DateAndTime &time, const TYPE value); /// Add a value to the map using a string time void addValue(const std::string &time, const TYPE value); /// Add a value to the map using a time_t void addValue(const std::time_t &time, const TYPE value); /// Adds vectors of values to the map. Should be much faster than repeated /// calls to addValue. - void addValues(const std::vector<Mantid::Types::DateAndTime> ×, + void addValues(const std::vector<Types::Core::DateAndTime> ×, const std::vector<TYPE> &values); /// Replaces the time series with new values time series values - void replaceValues(const std::vector<Mantid::Types::DateAndTime> ×, + void replaceValues(const std::vector<Types::Core::DateAndTime> ×, const std::vector<TYPE> &values); /// Returns the last time - Mantid::Types::DateAndTime lastTime() const; + Types::Core::DateAndTime lastTime() const; /// Returns the first value regardless of filter TYPE firstValue() const; /// Returns the first time regardless of filter - Mantid::Types::DateAndTime firstTime() const; + Types::Core::DateAndTime firstTime() const; /// Returns the last value TYPE lastValue() const; @@ -245,7 +245,7 @@ public: /// New method to return time series value pairs as std::vector<std::string> std::vector<std::string> time_tValue() const; /// Return the time series as a C++ map<DateAndTime, TYPE> - std::map<Mantid::Types::DateAndTime, TYPE> valueAsMap() const; + std::map<Types::Core::DateAndTime, TYPE> valueAsMap() const; // ============================================================================================ /// Set a property from a string @@ -258,24 +258,24 @@ public: /// Deletes all but the 'last entry' in the property void clearOutdated() override; /// Clears and creates a TimeSeriesProperty from these parameters - void create(const Mantid::Types::DateAndTime &start_time, + void create(const Types::Core::DateAndTime &start_time, const std::vector<double> &time_sec, const std::vector<TYPE> &new_values); /// Clears and creates a TimeSeriesProperty from these parameters - void create(const std::vector<Mantid::Types::DateAndTime> &new_times, + void create(const std::vector<Types::Core::DateAndTime> &new_times, const std::vector<TYPE> &new_values); /// Returns the value at a particular time - TYPE getSingleValue(const Mantid::Types::DateAndTime &t) const; + TYPE getSingleValue(const Types::Core::DateAndTime &t) const; /// Returns the value at a particular time - TYPE getSingleValue(const Mantid::Types::DateAndTime &t, int &index) const; + TYPE getSingleValue(const Types::Core::DateAndTime &t, int &index) const; /// Returns n-th valid time interval, in a very inefficient way. TimeInterval nthInterval(int n) const; /// Returns n-th value of n-th interval in an incredibly inefficient way. TYPE nthValue(int n) const; /// Returns n-th time. NOTE: Complexity is order(n)! regardless of filter - Mantid::Types::DateAndTime nthTime(int n) const; + Types::Core::DateAndTime nthTime(int n) const; /// Divide the property into allowed and disallowed time intervals according /// to \a filter. @@ -321,9 +321,9 @@ private: /// Sort the property into increasing times, if not already sorted void sortIfNecessary() const; /// Find the index of the entry of time t in the mP vector (sorted) - int findIndex(Mantid::Types::DateAndTime t) const; + int findIndex(Types::Core::DateAndTime t) const; /// Find the upper_bound of time t in container. - int upperBound(Mantid::Types::DateAndTime t, int istart, int iend) const; + int upperBound(Types::Core::DateAndTime t, int istart, int iend) const; /// Apply a filter void applyFilter() const; /// A new algorithm to find Nth index. It is simple and leave a lot work to @@ -332,7 +332,7 @@ private: /// Set a value from another property std::string setValueFromProperty(const Property &right) override; /// Find if time lies in a filtered region - bool isTimeFiltered(const Mantid::Types::DateAndTime &time) const; + bool isTimeFiltered(const Types::Core::DateAndTime &time) const; /// Holds the time series data mutable std::vector<TimeValueUnit<TYPE>> m_values; @@ -345,7 +345,7 @@ private: mutable TimeSeriesSortStatus m_propSortedFlag; /// The filter - mutable std::vector<std::pair<Mantid::Types::DateAndTime, bool>> m_filter; + mutable std::vector<std::pair<Types::Core::DateAndTime, bool>> m_filter; /// Quick reference regions for filter mutable std::vector<std::pair<size_t, size_t>> m_filterQuickRef; /// True if a filter has been applied diff --git a/Framework/Kernel/inc/MantidKernel/TimeSplitter.h b/Framework/Kernel/inc/MantidKernel/TimeSplitter.h index 73cac82324b..53c6af492c4 100644 --- a/Framework/Kernel/inc/MantidKernel/TimeSplitter.h +++ b/Framework/Kernel/inc/MantidKernel/TimeSplitter.h @@ -1,8 +1,7 @@ #ifndef TIMESPLITTER_H #define TIMESPLITTER_H -#include "MantidKernel/DllConfig.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" namespace Mantid { namespace Kernel { @@ -21,12 +20,11 @@ public: /// Default constructor SplittingInterval(); - SplittingInterval(const Mantid::Types::DateAndTime &start, - const Mantid::Types::DateAndTime &stop, - const int index = 0); + SplittingInterval(const Types::Core::DateAndTime &start, + const Types::Core::DateAndTime &stop, const int index = 0); - Mantid::Types::DateAndTime start() const; - Mantid::Types::DateAndTime stop() const; + Types::Core::DateAndTime start() const; + Types::Core::DateAndTime stop() const; double duration() const; @@ -43,9 +41,9 @@ public: private: /// begin - Mantid::Types::DateAndTime m_start; + Types::Core::DateAndTime m_start; /// end - Mantid::Types::DateAndTime m_stop; + Types::Core::DateAndTime m_stop; /// Index of the destination int m_index; }; @@ -58,12 +56,12 @@ private: typedef std::vector<SplittingInterval> TimeSplitterType; // -------------- Operators --------------------- -MANTID_KERNEL_DLL TimeSplitterType operator+(const TimeSplitterType &a, - const TimeSplitterType &b); -MANTID_KERNEL_DLL TimeSplitterType operator&(const TimeSplitterType &a, - const TimeSplitterType &b); -MANTID_KERNEL_DLL TimeSplitterType operator|(const TimeSplitterType &a, - const TimeSplitterType &b); +MANTID_KERNEL_DLL TimeSplitterType +operator+(const TimeSplitterType &a, const TimeSplitterType &b); +MANTID_KERNEL_DLL TimeSplitterType +operator&(const TimeSplitterType &a, const TimeSplitterType &b); +MANTID_KERNEL_DLL TimeSplitterType +operator|(const TimeSplitterType &a, const TimeSplitterType &b); MANTID_KERNEL_DLL TimeSplitterType operator~(const TimeSplitterType &a); } // Namespace Kernel diff --git a/Framework/Kernel/src/ConfigService.cpp b/Framework/Kernel/src/ConfigService.cpp index 9cd1e744df1..3515cf2ce93 100644 --- a/Framework/Kernel/src/ConfigService.cpp +++ b/Framework/Kernel/src/ConfigService.cpp @@ -3,30 +3,30 @@ //---------------------------------------------------------------------- #include "MantidKernel/ConfigService.h" -#include "MantidKernel/Exception.h" -#include "MantidKernel/FacilityInfo.h" -#include "MantidKernel/FilterChannel.h" -#include "MantidKernel/Logger.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/MantidVersion.h" -#include "MantidKernel/NetworkProxy.h" -#include "MantidKernel/StdoutChannel.h" #include "MantidKernel/Strings.h" +#include "MantidKernel/Logger.h" +#include "MantidKernel/FilterChannel.h" +#include "MantidKernel/StdoutChannel.h" #include "MantidKernel/System.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/Exception.h" +#include "MantidKernel/FacilityInfo.h" +#include "MantidKernel/NetworkProxy.h" +#include <Poco/Util/LoggingConfigurator.h> +#include <Poco/Util/SystemConfiguration.h> +#include <Poco/Util/PropertyFileConfiguration.h> +#include <Poco/LoggingFactory.h> +#include <Poco/Path.h> +#include <Poco/File.h> #include <MantidKernel/StringTokenizer.h> #include <Poco/DOM/DOMParser.h> #include <Poco/DOM/Document.h> #include <Poco/DOM/NodeList.h> #include <Poco/Environment.h> -#include <Poco/File.h> -#include <Poco/LoggingFactory.h> -#include <Poco/Path.h> #include <Poco/Process.h> #include <Poco/URI.h> -#include <Poco/Util/LoggingConfigurator.h> -#include <Poco/Util/PropertyFileConfiguration.h> -#include <Poco/Util/SystemConfiguration.h> #include <Poco/AutoPtr.h> #include <Poco/Channel.h> @@ -34,25 +34,25 @@ #include <Poco/DOM/Node.h> #include <Poco/Exception.h> #include <Poco/Instantiator.h> +#include <Poco/Pipe.h> +#include <Poco/Platform.h> +#include <Poco/String.h> #include <Poco/Logger.h> #include <Poco/LoggingRegistry.h> -#include <Poco/Pipe.h> #include <Poco/PipeStream.h> -#include <Poco/Platform.h> #include <Poco/StreamCopier.h> -#include <Poco/String.h> #include <boost/algorithm/string/join.hpp> #include <boost/regex.hpp> #include <algorithm> -#include <ctype.h> #include <exception> #include <fstream> #include <functional> #include <iostream> #include <stdexcept> #include <utility> +#include <ctype.h> #ifdef __APPLE__ #include <mach-o/dyld.h> @@ -242,7 +242,7 @@ ConfigServiceImpl::ConfigServiceImpl() g_log.information() << "This is Mantid version " << MantidVersion::version() << " revision " << MantidVersion::revision() << '\n'; g_log.information() << "running on " << getComputerName() << " starting " - << Mantid::Types::DateAndTime::getCurrentTime() + << Types::Core::DateAndTime::getCurrentTime() .toFormattedString("%Y-%m-%dT%H:%MZ") << "\n"; g_log.information() << "Properties file(s) loaded: " << propertiesFilesList @@ -428,11 +428,11 @@ bool ConfigServiceImpl::readFile(const std::string &filename, } /** Registers additional logging filter channels - * @param filterChannelName The name to refer to the filter channel, this should - * be unique - * @param pChannel a pointer to the channel to be registered, if blank, then the - * channel must already be registered with the logging registry in Poco - */ +* @param filterChannelName The name to refer to the filter channel, this should +* be unique +* @param pChannel a pointer to the channel to be registered, if blank, then the +* channel must already be registered with the logging registry in Poco +*/ void ConfigServiceImpl::registerLoggingFilterChannel( const std::string &filterChannelName, Poco::Channel *pChannel) { m_filterChannels.push_back(filterChannelName); @@ -1003,13 +1003,13 @@ void ConfigServiceImpl::getKeysRecursive( } /** - * Recursively gets a list of all config options. - * - * This function is needed as Boost Python does not like calling function with - * default arguments. - * - * @return Vector containing all config options - */ +* Recursively gets a list of all config options. +* +* This function is needed as Boost Python does not like calling function with +* default arguments. +* +* @return Vector containing all config options +*/ std::vector<std::string> ConfigServiceImpl::keys() const { std::vector<std::string> allKeys; getKeysRecursive("", allKeys); @@ -1388,9 +1388,9 @@ std::string ConfigServiceImpl::getTempDir() { } /** Gets the absolute path of the appdata directory - * - * @returns The absolute path of the appdata directory - */ +* +* @returns The absolute path of the appdata directory +*/ std::string ConfigServiceImpl::getAppDataDir() { const std::string applicationName = "mantid"; #if POCO_OS == POCO_OS_WINDOWS_NT @@ -1418,10 +1418,10 @@ std::string ConfigServiceImpl::getDirectoryOfExecutable() const { } /** - * Get the full path to the executing program (i.e. whatever Mantid is embedded + * Get the full path to the executing program (i.e. whatever Mantid is embedded * in) - * @returns A string containing the full path the the executable - */ + * @returns A string containing the full path the the executable + */ std::string ConfigServiceImpl::getPathToExecutable() const { std::string execpath; const size_t LEN(1024); @@ -1658,9 +1658,9 @@ const std::vector<std::string> &ConfigServiceImpl::getUserSearchDirs() const { } /** - * Sets the search directories for XML instrument definition files (IDFs) - * @param directories An ordered list of paths for instrument searching - */ +* Sets the search directories for XML instrument definition files (IDFs) +* @param directories An ordered list of paths for instrument searching +*/ void ConfigServiceImpl::setInstrumentDirectories( const std::vector<std::string> &directories) { m_InstrumentDirs = directories; @@ -2041,27 +2041,24 @@ Kernel::ProxyInfo &ConfigServiceImpl::getProxy(const std::string &url) { } /** Sets the log level priority for the File log channel - * @param logLevel the integer value of the log level to set, 1=Critical, - * 7=Debug - */ +* @param logLevel the integer value of the log level to set, 1=Critical, 7=Debug +*/ void ConfigServiceImpl::setFileLogLevel(int logLevel) { setFilterChannelLogLevel(m_filterChannels[0], logLevel); } /** Sets the log level priority for the Console log channel - * @param logLevel the integer value of the log level to set, 1=Critical, - * 7=Debug - */ +* @param logLevel the integer value of the log level to set, 1=Critical, 7=Debug +*/ void ConfigServiceImpl::setConsoleLogLevel(int logLevel) { setFilterChannelLogLevel(m_filterChannels[1], logLevel); } /** Sets the Log level for a filter channel - * @param filterChannelName the channel name of the filter channel to change - * @param logLevel the integer value of the log level to set, 1=Critical, - * 7=Debug - * @throws std::invalid_argument if the channel name is incorrect or it is not a - * filterChannel - */ +* @param filterChannelName the channel name of the filter channel to change +* @param logLevel the integer value of the log level to set, 1=Critical, 7=Debug +* @throws std::invalid_argument if the channel name is incorrect or it is not a +* filterChannel +*/ void ConfigServiceImpl::setFilterChannelLogLevel( const std::string &filterChannelName, int logLevel) { Poco::Channel *channel = nullptr; @@ -2092,7 +2089,7 @@ void ConfigServiceImpl::setFilterChannelLogLevel( } /** Finds the lowest Log level for all registered filter channels - */ +*/ int ConfigServiceImpl::FindLowestFilterLevel() const { int lowestPriority = Logger::Priority::PRIO_FATAL; // Find the lowest level of all of the filter channels diff --git a/Framework/Kernel/src/DateAndTimeHelpers.cpp b/Framework/Kernel/src/DateAndTimeHelpers.cpp index 8ca84da8ab7..7964f796aac 100644 --- a/Framework/Kernel/src/DateAndTimeHelpers.cpp +++ b/Framework/Kernel/src/DateAndTimeHelpers.cpp @@ -27,8 +27,8 @@ Logger g_log("DateAndTime"); *@param date Date used to create DateAndTime object. May be sanitized first. * */ -DateAndTime createFromSanitizedISO8601(const std::string &date) { - return DateAndTime(verifyAndSanitizeISO8601(date)); +Types::Core::DateAndTime createFromSanitizedISO8601(const std::string &date) { + return Types::Core::DateAndTime(verifyAndSanitizeISO8601(date)); } /** Check if a string is iso8601 format. diff --git a/Framework/Kernel/src/DateTimeValidator.cpp b/Framework/Kernel/src/DateTimeValidator.cpp index 600c12fa248..9577feb0097 100644 --- a/Framework/Kernel/src/DateTimeValidator.cpp +++ b/Framework/Kernel/src/DateTimeValidator.cpp @@ -40,7 +40,7 @@ std::string DateTimeValidator::checkValidity(const std::string &value) const { } else { std::string error; try { - DateAndTime timestamp(value); + Types::Core::DateAndTime timestamp(value); UNUSED_ARG(timestamp); } catch (std::invalid_argument &exc) { error = exc.what(); diff --git a/Framework/Kernel/src/GitHubApiHelper.cpp b/Framework/Kernel/src/GitHubApiHelper.cpp index 90a125426f9..d4c7be49072 100644 --- a/Framework/Kernel/src/GitHubApiHelper.cpp +++ b/Framework/Kernel/src/GitHubApiHelper.cpp @@ -1,11 +1,11 @@ #include "MantidKernel/GitHubApiHelper.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/Logger.h" -#include "MantidTypes/DateAndTime.h" -#include <Poco/Net/HTTPClientSession.h> -#include <Poco/Net/HTTPRequest.h> -#include <Poco/Net/HTTPResponse.h> #include <Poco/StreamCopier.h> #include <Poco/URI.h> +#include <Poco/Net/HTTPRequest.h> +#include <Poco/Net/HTTPResponse.h> +#include <Poco/Net/HTTPClientSession.h> #include <boost/lexical_cast.hpp> @@ -14,6 +14,7 @@ #include <string> namespace Mantid { +using namespace Types::Core; namespace Kernel { // Forward declare @@ -27,18 +28,18 @@ namespace { // anonymous namespace for some utility functions /// static Logger object Logger g_log("InternetHelper"); -} // namespace +} //---------------------------------------------------------------------------------------------- /** Constructor - */ +*/ GitHubApiHelper::GitHubApiHelper() : InternetHelper() { addAuthenticationToken(); } //---------------------------------------------------------------------------------------------- /** Constructor - */ +*/ GitHubApiHelper::GitHubApiHelper(const Kernel::ProxyInfo &proxy) : InternetHelper(proxy) { addAuthenticationToken(); @@ -58,7 +59,7 @@ void GitHubApiHelper::processResponseHeaders( // get github api rate limit information if available; int rateLimitRemaining = 0; int rateLimitLimit; - Mantid::Types::DateAndTime rateLimitReset; + DateAndTime rateLimitReset; try { rateLimitLimit = boost::lexical_cast<int>(res.get("X-RateLimit-Limit", "-1")); diff --git a/Framework/Kernel/src/InternetHelper.cpp b/Framework/Kernel/src/InternetHelper.cpp index 060830db602..a0f90782641 100644 --- a/Framework/Kernel/src/InternetHelper.cpp +++ b/Framework/Kernel/src/InternetHelper.cpp @@ -1,16 +1,16 @@ #include "MantidKernel/InternetHelper.h" #include "MantidKernel/ConfigService.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/Exception.h" #include "MantidKernel/Logger.h" -#include "MantidTypes/DateAndTime.h" // Poco #include <Poco/Net/AcceptCertificateHandler.h> +#include <Poco/Net/NetException.h> #include <Poco/Net/HTMLForm.h> #include <Poco/Net/HTTPRequest.h> #include <Poco/Net/HTTPResponse.h> #include <Poco/Net/HTTPSClientSession.h> -#include <Poco/Net/NetException.h> #include <Poco/Net/PrivateKeyPassphraseHandler.h> #include <Poco/Net/SSLManager.h> #include <Poco/StreamCopier.h> @@ -35,13 +35,12 @@ #include <boost/lexical_cast.hpp> // std -#include <fstream> #include <mutex> +#include <fstream> #include <utility> -using Mantid::Types::DateAndTime; - namespace Mantid { +using namespace Types::Core; namespace Kernel { using namespace Poco::Net; @@ -79,11 +78,11 @@ void doSSLInit() { * initialization only happens once per process. */ void initializeSSL() { std::call_once(SSL_INIT_FLAG, doSSLInit); } -} // namespace +} //---------------------------------------------------------------------------------------------- /** Constructor - */ +*/ InternetHelper::InternetHelper() : m_proxyInfo(), m_isProxySet(false), m_timeout(30), m_isTimeoutSet(false), m_contentLength(0), m_method(HTTPRequest::HTTP_GET), @@ -92,7 +91,7 @@ InternetHelper::InternetHelper() //---------------------------------------------------------------------------------------------- /** Constructor - */ +*/ InternetHelper::InternetHelper(const Kernel::ProxyInfo &proxy) : m_proxyInfo(proxy), m_isProxySet(true), m_timeout(30), m_isTimeoutSet(false), m_contentLength(0), @@ -101,7 +100,7 @@ InternetHelper::InternetHelper(const Kernel::ProxyInfo &proxy) //---------------------------------------------------------------------------------------------- /** Destructor - */ +*/ InternetHelper::~InternetHelper() { if (m_request != nullptr) { delete m_request; @@ -190,9 +189,9 @@ int InternetHelper::processRelocation(const HTTPResponse &response, } /** Performs a request using http or https depending on the url - * @param url the address to the network resource - * @param responseStream The stream to fill with the reply on success - **/ +* @param url the address to the network resource +* @param responseStream The stream to fill with the reply on success +**/ int InternetHelper::sendRequest(const std::string &url, std::ostream &responseStream) { @@ -232,9 +231,9 @@ void InternetHelper::logDebugRequestSending(const std::string &schemeName, } /** Performs a request using http - * @param url the address to the network resource - * @param responseStream The stream to fill with the reply on success - **/ +* @param url the address to the network resource +* @param responseStream The stream to fill with the reply on success +**/ int InternetHelper::sendHTTPRequest(const std::string &url, std::ostream &responseStream) { int retStatus = 0; @@ -262,9 +261,9 @@ int InternetHelper::sendHTTPRequest(const std::string &url, } /** Performs a request using https - * @param url the address to the network resource - * @param responseStream The stream to fill with the reply on success - **/ +* @param url the address to the network resource +* @param responseStream The stream to fill with the reply on success +**/ int InternetHelper::sendHTTPSRequest(const std::string &url, std::ostream &responseStream) { int retStatus = 0; @@ -313,7 +312,7 @@ Kernel::ProxyInfo &InternetHelper::getProxy(const std::string &url) { } /** Clears cached proxy details. - */ +*/ void InternetHelper::clearProxy() { m_isProxySet = false; } /** sets the proxy details. @@ -443,8 +442,8 @@ int InternetHelper::downloadFile(const std::string &urlFile, } /** Sets the timeout in seconds - * @param seconds The value in seconds for the timeout - **/ +* @param seconds The value in seconds for the timeout +**/ void InternetHelper::setTimeout(int seconds) { m_timeout = seconds; m_isTimeoutSet = true; @@ -474,8 +473,8 @@ void InternetHelper::throwNotConnected(const std::string &url, } /** Gets the timeout in seconds - * @returns The value in seconds for the timeout - **/ +* @returns The value in seconds for the timeout +**/ int InternetHelper::getTimeout() { if (!m_isTimeoutSet) { if (!ConfigService::Instance().getValue("network.default.timeout", @@ -487,9 +486,9 @@ int InternetHelper::getTimeout() { } /** Sets the Method - * @param method A string of GET or POST, anything other than POST is considered - *GET - **/ +* @param method A string of GET or POST, anything other than POST is considered +*GET +**/ void InternetHelper::setMethod(const std::string &method) { if (method == "POST") { m_method = method; @@ -499,39 +498,39 @@ void InternetHelper::setMethod(const std::string &method) { } /** Gets the method - * @returns either "GET" or "POST" - **/ +* @returns either "GET" or "POST" +**/ const std::string &InternetHelper::getMethod() { return m_method; } /** Sets the Content Type - * @param contentType A string of the content type - **/ +* @param contentType A string of the content type +**/ void InternetHelper::setContentType(const std::string &contentType) { m_contentType = contentType; } /** Gets the Content Type - * @returns A string of the content type - **/ +* @returns A string of the content type +**/ const std::string &InternetHelper::getContentType() { return m_contentType; } /** Sets the content length - * @param length The content length in bytes - **/ +* @param length The content length in bytes +**/ void InternetHelper::setContentLength(std::streamsize length) { m_contentLength = length; } /** Gets the content length - * @returns The content length in bytes - **/ +* @returns The content length in bytes +**/ std::streamsize InternetHelper::getContentLength() { return m_contentLength; } /** Sets the body & content length for future requests, this will also - * set the method to POST is the body is not empty - * and GET if it is. - * @param body A string of the body - **/ +* set the method to POST is the body is not empty +* and GET if it is. +* @param body A string of the body +**/ void InternetHelper::setBody(const std::string &body) { m_body = body; if (m_body.empty()) { @@ -543,19 +542,19 @@ void InternetHelper::setBody(const std::string &body) { } /** Sets the body & content length for future requests, this will also - * set the method to POST is the body is not empty - * and GET if it is. - * @param body A stringstream of the body - **/ +* set the method to POST is the body is not empty +* and GET if it is. +* @param body A stringstream of the body +**/ void InternetHelper::setBody(const std::ostringstream &body) { setBody(body.str()); } /** Sets the body & content length for future requests, this will also - * set the method to POST is the body is not empty - * and GET if it is. - * @param form A HTMLform - **/ +* set the method to POST is the body is not empty +* and GET if it is. +* @param form A HTMLform +**/ void InternetHelper::setBody(Poco::Net::HTMLForm &form) { setMethod("POST"); @@ -573,58 +572,58 @@ void InternetHelper::setBody(Poco::Net::HTMLForm &form) { } /** Gets the body set for future requests - * @returns A string of the content type - **/ +* @returns A string of the content type +**/ const std::string &InternetHelper::getBody() { return m_body; } /** Gets the body set for future requests - * @returns A string of the content type - **/ +* @returns A string of the content type +**/ int InternetHelper::getResponseStatus() { return m_response->getStatus(); } /** Gets the body set for future requests - * @returns A string of the content type - **/ +* @returns A string of the content type +**/ const std::string &InternetHelper::getResponseReason() { return m_response->getReason(); } /** Adds a header - * @param key The key to refer to the value - * @param value The value in seconds for the timeout - **/ +* @param key The key to refer to the value +* @param value The value in seconds for the timeout +**/ void InternetHelper::addHeader(const std::string &key, const std::string &value) { m_headers.emplace(key, value); } /** Removes a header - * @param key The key to refer to the value - **/ +* @param key The key to refer to the value +**/ void InternetHelper::removeHeader(const std::string &key) { m_headers.erase(key); } /** Gets the value of a header - * @param key The key to refer to the value - * @returns the value as a string - **/ +* @param key The key to refer to the value +* @returns the value as a string +**/ const std::string &InternetHelper::getHeader(const std::string &key) { return m_headers[key]; } /** Clears all headers - **/ +**/ void InternetHelper::clearHeaders() { m_headers.clear(); } /** Returns a reference to the headers map - **/ +**/ std::map<std::string, std::string> &InternetHelper::headers() { return m_headers; } /** Resets properties to defaults (except the proxy) - **/ +**/ void InternetHelper::reset() { m_headers.clear(); m_timeout = 30; diff --git a/Framework/Kernel/src/LogFilter.cpp b/Framework/Kernel/src/LogFilter.cpp index 710d1f1c50a..3a868ba2b31 100644 --- a/Framework/Kernel/src/LogFilter.cpp +++ b/Framework/Kernel/src/LogFilter.cpp @@ -1,6 +1,5 @@ #include "MantidKernel/LogFilter.h" #include "MantidKernel/TimeSeriesProperty.h" -#include "MantidKernel/TimeInterval.h" namespace Mantid { namespace Kernel { diff --git a/Framework/Kernel/src/LogParser.cpp b/Framework/Kernel/src/LogParser.cpp index e742feea311..7fddaf23f6c 100644 --- a/Framework/Kernel/src/LogParser.cpp +++ b/Framework/Kernel/src/LogParser.cpp @@ -2,10 +2,9 @@ // Includes //---------------------------------------------------------------------- #include "MantidKernel/LogParser.h" +#include "MantidKernel/Strings.h" #include "MantidKernel/Logger.h" #include "MantidKernel/PropertyWithValue.h" -#include "MantidKernel/Strings.h" -#include "MantidKernel/TimeInterval.h" #include "MantidKernel/TimeSeriesProperty.h" #include <fstream> @@ -14,15 +13,16 @@ const char *START_COLLECTION = "START_COLLECTION"; const char *STOP_COLLECTION = "STOP_COLLECTION"; -using Mantid::Types::DateAndTime; using std::size_t; namespace Mantid { + +using Types::Core::DateAndTime; namespace Kernel { namespace { /// static logger Logger g_log("LogParser"); -} // namespace +} /// @returns the name of the log created that defines the status during a run const std::string LogParser::statusLogName() { return std::string("running"); } @@ -159,8 +159,7 @@ Try to pass the periods @param idata : stream of input data @param periods : periods data to update */ -void LogParser::tryParsePeriod(const std::string &scom, - const Types::DateAndTime &time, +void LogParser::tryParsePeriod(const std::string &scom, const DateAndTime &time, std::istringstream &idata, Kernel::TimeSeriesProperty<int> *const periods) { int ip = -1; @@ -190,8 +189,8 @@ void LogParser::tryParsePeriod(const std::string &scom, } /** Create given the icpevent log property. - * @param log :: A pointer to the property - */ +* @param log :: A pointer to the property +*/ LogParser::LogParser(const Kernel::Property *log) : m_nOfPeriods(1) { Kernel::TimeSeriesProperty<int> *periods = new Kernel::TimeSeriesProperty<int>(periodsLogName()); @@ -203,14 +202,14 @@ LogParser::LogParser(const Kernel::Property *log) : m_nOfPeriods(1) { const Kernel::TimeSeriesProperty<std::string> *icpLog = dynamic_cast<const Kernel::TimeSeriesProperty<std::string> *>(log); if (!icpLog || icpLog->size() == 0) { - periods->addValue(Mantid::Types::DateAndTime(), 1); - status->addValue(Mantid::Types::DateAndTime(), true); + periods->addValue(Types::Core::DateAndTime(), 1); + status->addValue(Types::Core::DateAndTime(), true); g_log.warning() << "Cannot process ICPevent log. Period 1 assumed for all data.\n"; return; } - std::multimap<Mantid::Types::DateAndTime, std::string> logm = + std::multimap<Types::Core::DateAndTime, std::string> logm = icpLog->valueAsMultiMap(); CommandMap command_map = createCommandMap(LogParser::isICPEventLogNewStyle(logm)); @@ -261,7 +260,7 @@ Kernel::TimeSeriesProperty<bool> *LogParser::createPeriodLog(int period) const { ostr << period; Kernel::TimeSeriesProperty<bool> *p = new Kernel::TimeSeriesProperty<bool>("period " + ostr.str()); - std::map<Mantid::Types::DateAndTime, int> pMap = periods->valueAsMap(); + std::map<Types::Core::DateAndTime, int> pMap = periods->valueAsMap(); auto it = pMap.begin(); if (it->second != period) p->addValue(it->first, false); @@ -274,7 +273,7 @@ Kernel::TimeSeriesProperty<bool> *LogParser::createPeriodLog(int period) const { /** * Create a log vale for the current period. * @param period: The period number to create the log entry for. - */ +*/ Kernel::Property *LogParser::createCurrentPeriodLog(const int &period) const { Kernel::PropertyWithValue<int> *currentPeriodProperty = new Kernel::PropertyWithValue<int>("current_period", period); @@ -294,12 +293,13 @@ Kernel::TimeSeriesProperty<bool> *LogParser::createRunningLog() const { namespace { /// Define operator for checking for new-style icp events struct hasNewStyleCommands { - bool operator()(const std::pair<Mantid::Types::DateAndTime, std::string> &p) { + bool + operator()(const std::pair<Mantid::Types::Core::DateAndTime, std::string> &p) { return p.second.find(START_COLLECTION) != std::string::npos || p.second.find(STOP_COLLECTION) != std::string::npos; } }; -} // namespace +} /** * Check if the icp log commands are in the new style. The new style is the one @@ -308,7 +308,7 @@ struct hasNewStyleCommands { * @param logm :: A log map created from a icp-event log. */ bool LogParser::isICPEventLogNewStyle( - const std::multimap<Mantid::Types::DateAndTime, std::string> &logm) { + const std::multimap<Types::Core::DateAndTime, std::string> &logm) { hasNewStyleCommands checker; return std::find_if(logm.begin(), logm.end(), checker) != logm.end(); @@ -324,7 +324,7 @@ bool LogParser::isICPEventLogNewStyle( * TimeSeriesProperty<double>. * @return The mean value over time. * @throw runtime_error if the property is not TimeSeriesProperty<double> - */ +*/ double timeMean(const Kernel::Property *p) { const Kernel::TimeSeriesProperty<double> *dp = dynamic_cast<const Kernel::TimeSeriesProperty<double> *>(p); @@ -338,17 +338,17 @@ double timeMean(const Kernel::Property *p) { return dp->nthValue(1); } double res = 0.; - Types::time_duration total(0, 0, 0, 0); + Types::Core::time_duration total(0, 0, 0, 0); size_t dp_size = dp->size(); for (size_t i = 0; i < dp_size; i++) { Kernel::TimeInterval t = dp->nthInterval(static_cast<int>(i)); - Types::time_duration dt = t.length(); + Types::Core::time_duration dt = t.length(); total += dt; res += dp->nthValue(static_cast<int>(i)) * - Mantid::Types::DateAndTime::secondsFromDuration(dt); + Types::Core::DateAndTime::secondsFromDuration(dt); } - double total_seconds = Mantid::Types::DateAndTime::secondsFromDuration(total); + double total_seconds = Types::Core::DateAndTime::secondsFromDuration(total); // If all the time stamps were the same, just return the first value. if (total_seconds == 0.0) @@ -360,5 +360,5 @@ double timeMean(const Kernel::Property *p) { return res; } -} // namespace Kernel +} // namespace Geometry } // namespace Mantid diff --git a/Framework/Kernel/src/Property.cpp b/Framework/Kernel/src/Property.cpp index 1f27cf0a400..af71f7051b1 100644 --- a/Framework/Kernel/src/Property.cpp +++ b/Framework/Kernel/src/Property.cpp @@ -1,6 +1,6 @@ #include "MantidKernel/Property.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/Exception.h" #include "MantidKernel/IPropertySettings.h" #include "MantidKernel/OptionalBool.h" @@ -209,8 +209,8 @@ void Property::setUnits(const std::string &unit) { m_units = unit; } * @param start :: the beginning time to filter from * @param stop :: the ending time to filter to * */ -void Property::filterByTime(const Mantid::Types::DateAndTime &start, - const Mantid::Types::DateAndTime &stop) { +void Property::filterByTime(const Types::Core::DateAndTime &start, + const Types::Core::DateAndTime &stop) { UNUSED_ARG(start); UNUSED_ARG(stop); // Do nothing in general diff --git a/Framework/Kernel/src/PropertyManager.cpp b/Framework/Kernel/src/PropertyManager.cpp index d5a185661bb..f7cb867d3ce 100644 --- a/Framework/Kernel/src/PropertyManager.cpp +++ b/Framework/Kernel/src/PropertyManager.cpp @@ -97,8 +97,8 @@ PropertyManager &PropertyManager::operator+=(const PropertyManager &rhs) { * @param stop :: Absolute stop time. Any log entries at times < than this time *are kept. */ -void PropertyManager::filterByTime(const Mantid::Types::DateAndTime &start, - const Mantid::Types::DateAndTime &stop) { +void PropertyManager::filterByTime(const Types::Core::DateAndTime &start, + const Types::Core::DateAndTime &stop) { // Iterate through all properties PropertyMap::const_iterator it; for (it = this->m_properties.begin(); it != this->m_properties.end(); ++it) { diff --git a/Framework/Kernel/src/PropertyNexus.cpp b/Framework/Kernel/src/PropertyNexus.cpp index 34cbe390757..9f4b47e4256 100644 --- a/Framework/Kernel/src/PropertyNexus.cpp +++ b/Framework/Kernel/src/PropertyNexus.cpp @@ -1,10 +1,10 @@ #include "MantidKernel/PropertyNexus.h" -#include <nexus/NeXusException.hpp> #include <nexus/NeXusFile.hpp> +#include <nexus/NeXusException.hpp> #include "MantidKernel/ArrayProperty.h" -#include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/Property.h" #include "MantidKernel/PropertyWithValue.h" #include "MantidKernel/TimeSeriesProperty.h" @@ -43,7 +43,7 @@ namespace PropertyNexus { template <typename NumT> std::unique_ptr<Property> makeProperty(::NeXus::File *file, const std::string &name, - const std::vector<Mantid::Types::DateAndTime> ×) { + const std::vector<Types::Core::DateAndTime> ×) { std::vector<NumT> values; file->getData(values); if (times.empty()) { @@ -61,15 +61,15 @@ makeProperty(::NeXus::File *file, const std::string &name, } /** Helper method to create a time series property from a boolean - * - * @param file :: nexus file handle - * @param name :: name of the property being created - * @param times :: vector of times, empty = single property with value - * @return Property * - */ -std::unique_ptr<Property> makeTimeSeriesBoolProperty( - ::NeXus::File *file, const std::string &name, - const std::vector<Mantid::Types::DateAndTime> ×) { +* +* @param file :: nexus file handle +* @param name :: name of the property being created +* @param times :: vector of times, empty = single property with value +* @return Property * +*/ +std::unique_ptr<Property> +makeTimeSeriesBoolProperty(::NeXus::File *file, const std::string &name, + const std::vector<Types::Core::DateAndTime> ×) { std::vector<uint8_t> savedValues; file->getData(savedValues); const size_t nvals = savedValues.size(); @@ -85,7 +85,7 @@ std::unique_ptr<Property> makeTimeSeriesBoolProperty( /** Make a string/vector\<string\> property */ std::unique_ptr<Property> makeStringProperty(::NeXus::File *file, const std::string &name, - const std::vector<Mantid::Types::DateAndTime> ×) { + const std::vector<Types::Core::DateAndTime> ×) { std::vector<std::string> values; if (times.empty()) { std::string bigString = file->getStrData(); @@ -147,13 +147,13 @@ std::unique_ptr<Property> loadProperty(::NeXus::File *file, typeIsBool = true; } - std::vector<Mantid::Types::DateAndTime> times; + std::vector<Types::Core::DateAndTime> times; if (!timeSec.empty()) { // Use a default start time if (startStr.empty()) startStr = "2000-01-01T00:00:00"; // Convert time in seconds to DateAndTime - auto start = Mantid::Types::DateAndTimeHelpers::createFromISO8601(startStr); + Types::Core::DateAndTime start(startStr); times.reserve(timeSec.size()); for (double time : timeSec) { times.push_back(start + time); @@ -216,5 +216,5 @@ std::unique_ptr<Property> loadProperty(::NeXus::File *file, } // namespace PropertyNexus -} // namespace Kernel } // namespace Mantid +} // namespace API diff --git a/Framework/Kernel/src/TimeSeriesProperty.cpp b/Framework/Kernel/src/TimeSeriesProperty.cpp index 61faecbb646..7534e9346e7 100644 --- a/Framework/Kernel/src/TimeSeriesProperty.cpp +++ b/Framework/Kernel/src/TimeSeriesProperty.cpp @@ -1,24 +1,20 @@ #include "MantidKernel/TimeSeriesProperty.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/EmptyValues.h" #include "MantidKernel/Exception.h" #include "MantidKernel/Logger.h" -#include "MantidKernel/TimeInterval.h" #include "MantidKernel/TimeSplitter.h" #include "MantidKernel/make_unique.h" #include <nexus/NeXusFile.hpp> #include <boost/regex.hpp> -using namespace Mantid::Types; -using Mantid::Types::time_duration; - namespace Mantid { +using namespace Types::Core; namespace Kernel { namespace { /// static Logger definition Logger g_log("TimeSeriesProperty"); -} // namespace +} /** * Constructor @@ -60,12 +56,13 @@ TimeSeriesProperty<TYPE>::cloneWithTimeShift(const double timeShift) const { } /** Return time series property, containing time derivative of current property. - * The property itself and the returned time derivative become sorted by time - * and the derivative is calculated in seconds^-1. (e.g. dValue/dT where - * dT=t2-t1 is time difference in seconds for subsequent time readings and - * dValue=Val1-Val2 is difference in subsequent values) - * - */ +* The property itself and the returned time derivative become sorted by time and +* the derivative is calculated in seconds^-1. +* (e.g. dValue/dT where dT=t2-t1 is time difference in seconds +* for subsequent time readings and dValue=Val1-Val2 is difference in +* subsequent values) +* +*/ template <typename TYPE> std::unique_ptr<TimeSeriesProperty<double>> TimeSeriesProperty<TYPE>::getDerivative() const { @@ -90,7 +87,7 @@ TimeSeriesProperty<TYPE>::getDerivative() const { if (t1 != t0) { double deriv = 1.e+9 * (double(v1 - v0) / double(t1 - t0)); int64_t tm = static_cast<int64_t>((t1 + t0) / 2); - timeSeriesDeriv->addValue(Mantid::Types::DateAndTime(tm), deriv); + timeSeriesDeriv->addValue(Types::Core::DateAndTime(tm), deriv); } t0 = t1; v0 = v1; @@ -261,9 +258,8 @@ void TimeSeriesProperty<TYPE>::setName(const std::string name) { *are kept. */ template <typename TYPE> -void TimeSeriesProperty<TYPE>::filterByTime( - const Mantid::Types::DateAndTime &start, - const Mantid::Types::DateAndTime &stop) { +void TimeSeriesProperty<TYPE>::filterByTime(const Types::Core::DateAndTime &start, + const Types::Core::DateAndTime &stop) { // 0. Sort sortIfNecessary(); @@ -338,8 +334,8 @@ void TimeSeriesProperty<TYPE>::filterByTimes( // 4. Create new for (const auto &splitter : splittervec) { - Mantid::Types::DateAndTime t_start = splitter.start(); - Mantid::Types::DateAndTime t_stop = splitter.stop(); + Types::Core::DateAndTime t_start = splitter.start(); + Types::Core::DateAndTime t_stop = splitter.stop(); int tstartindex = findIndex(t_start); if (tstartindex < 0) { @@ -540,8 +536,7 @@ void TimeSeriesProperty<TYPE>::splitByTimeVector( errss << "Try to split TSP " << this->m_name << ": Input time vector's size " << splitter_time_vec.size() << " does not match (one more larger than) taget " - "workspace index vector's size " - << target_vec.size() << "\n"; + "workspace index vector's size " << target_vec.size() << "\n"; throw std::runtime_error(errss.str()); } // return if the output vector TimeSeriesProperties is not defined @@ -552,7 +547,7 @@ void TimeSeriesProperty<TYPE>::splitByTimeVector( sortIfNecessary(); // work on m_values, m_size, and m_time - std::vector<Mantid::Types::DateAndTime> tsp_time_vec = this->timesAsVector(); + std::vector<Types::Core::DateAndTime> tsp_time_vec = this->timesAsVector(); // go over both filter time vector and time series property time vector size_t index_splitter = 0; @@ -983,11 +978,11 @@ std::vector<TYPE> TimeSeriesProperty<TYPE>::valuesAsVector() const { } /** - * Return the time series as a C++ multimap<DateAndTime, TYPE>. All values. - * This method is used in parsing the ISIS ICPevent log file: different + * Return the time series as a C++ multimap<DateAndTime, TYPE>. All values. + * This method is used in parsing the ISIS ICPevent log file: different * commands - * can be recorded against the same time stamp but all must be present. - */ + * can be recorded against the same time stamp but all must be present. + */ template <typename TYPE> std::multimap<DateAndTime, TYPE> TimeSeriesProperty<TYPE>::valueAsMultiMap() const { @@ -1033,7 +1028,7 @@ std::vector<double> TimeSeriesProperty<TYPE>::timesAsVectorSeconds() const { std::vector<double> out; out.reserve(m_values.size()); - Mantid::Types::DateAndTime start = m_values[0].time(); + Types::Core::DateAndTime start = m_values[0].time(); for (size_t i = 0; i < m_values.size(); i++) { out.push_back(DateAndTime::secondsFromDuration(m_values[i].time() - start)); } @@ -1047,7 +1042,7 @@ std::vector<double> TimeSeriesProperty<TYPE>::timesAsVectorSeconds() const { * @param value The associated value */ template <typename TYPE> -void TimeSeriesProperty<TYPE>::addValue(const Mantid::Types::DateAndTime &time, +void TimeSeriesProperty<TYPE>::addValue(const Types::Core::DateAndTime &time, const TYPE value) { TimeValueUnit<TYPE> newvalue(time, value); // Add the value to the back of the vector @@ -1083,7 +1078,7 @@ void TimeSeriesProperty<TYPE>::addValue(const Mantid::Types::DateAndTime &time, template <typename TYPE> void TimeSeriesProperty<TYPE>::addValue(const std::string &time, const TYPE value) { - return addValue(DateAndTimeHelpers::createFromISO8601(time), value); + return addValue(Types::Core::DateAndTime(time), value); } /** @@ -1095,7 +1090,7 @@ void TimeSeriesProperty<TYPE>::addValue(const std::string &time, template <typename TYPE> void TimeSeriesProperty<TYPE>::addValue(const std::time_t &time, const TYPE value) { - Mantid::Types::DateAndTime dt; + Types::Core::DateAndTime dt; dt.set_from_time_t(time); return addValue(dt, value); } @@ -1107,7 +1102,7 @@ void TimeSeriesProperty<TYPE>::addValue(const std::time_t &time, */ template <typename TYPE> void TimeSeriesProperty<TYPE>::addValues( - const std::vector<Mantid::Types::DateAndTime> ×, + const std::vector<Types::Core::DateAndTime> ×, const std::vector<TYPE> &values) { size_t length = std::min(times.size(), values.size()); m_size += static_cast<int>(length); @@ -1121,12 +1116,12 @@ void TimeSeriesProperty<TYPE>::addValues( /** replace vectors of values to the map. First we clear the vectors * and then we run addValues - * @param times :: The time as a boost::posix_time::ptime value - * @param values :: The associated value - */ +* @param times :: The time as a boost::posix_time::ptime value +* @param values :: The associated value +*/ template <typename TYPE> void TimeSeriesProperty<TYPE>::replaceValues( - const std::vector<Mantid::Types::DateAndTime> ×, + const std::vector<Types::Core::DateAndTime> ×, const std::vector<TYPE> &values) { clear(); addValues(times, values); @@ -1202,14 +1197,12 @@ template <typename TYPE> TYPE TimeSeriesProperty<TYPE>::lastValue() const { template <typename TYPE> TYPE TimeSeriesProperty<TYPE>::minValue() const { return std::min_element(m_values.begin(), m_values.end(), - TimeValueUnit<TYPE>::valueCmp) - ->value(); + TimeValueUnit<TYPE>::valueCmp)->value(); } template <typename TYPE> TYPE TimeSeriesProperty<TYPE>::maxValue() const { return std::max_element(m_values.begin(), m_values.end(), - TimeValueUnit<TYPE>::valueCmp) - ->value(); + TimeValueUnit<TYPE>::valueCmp)->value(); } /// Returns the number of values at UNIQUE time intervals in the time series @@ -1360,9 +1353,9 @@ template <typename TYPE> void TimeSeriesProperty<TYPE>::clearOutdated() { * Vector sizes must match. */ template <typename TYPE> -void TimeSeriesProperty<TYPE>::create( - const Mantid::Types::DateAndTime &start_time, - const std::vector<double> &time_sec, const std::vector<TYPE> &new_values) { +void TimeSeriesProperty<TYPE>::create(const Types::Core::DateAndTime &start_time, + const std::vector<double> &time_sec, + const std::vector<TYPE> &new_values) { if (time_sec.size() != new_values.size()) throw std::invalid_argument("TimeSeriesProperty::create: mismatched size " "for the time and values vectors."); @@ -1566,16 +1559,16 @@ TimeInterval TimeSeriesProperty<TYPE>::nthInterval(int n) const { // 2. n = size of the allowed region, duplicate the last one long ind_t1 = static_cast<long>(m_filterQuickRef.back().first); long ind_t2 = ind_t1 - 1; - Mantid::Types::DateAndTime t1 = (m_values.begin() + ind_t1)->time(); - Mantid::Types::DateAndTime t2 = (m_values.begin() + ind_t2)->time(); + Types::Core::DateAndTime t1 = (m_values.begin() + ind_t1)->time(); + Types::Core::DateAndTime t2 = (m_values.begin() + ind_t2)->time(); time_duration d = t1 - t2; - Mantid::Types::DateAndTime t3 = t1 + d; + Types::Core::DateAndTime t3 = t1 + d; Kernel::TimeInterval dt(t1, t3); deltaT = dt; } else { // 3. n < size - Mantid::Types::DateAndTime t0; - Mantid::Types::DateAndTime tf; + Types::Core::DateAndTime t0; + Types::Core::DateAndTime tf; size_t refindex = this->findNthIndexFromQuickRef(n); if (refindex + 3 >= m_filterQuickRef.size()) @@ -1586,11 +1579,11 @@ TimeInterval TimeSeriesProperty<TYPE>::nthInterval(int n) const { throw std::logic_error("nthInterval: diff cannot be less than 0."); // i) start time - Mantid::Types::DateAndTime ftime0 = + Types::Core::DateAndTime ftime0 = m_filter[m_filterQuickRef[refindex].first].first; size_t iStartIndex = m_filterQuickRef[refindex + 1].first + static_cast<size_t>(diff); - Mantid::Types::DateAndTime ltime0 = m_values[iStartIndex].time(); + Types::Core::DateAndTime ltime0 = m_values[iStartIndex].time(); if (iStartIndex == 0 && ftime0 < ltime0) { // a) Special case that True-filter time starts before log time t0 = ltime0; @@ -1607,13 +1600,13 @@ TimeInterval TimeSeriesProperty<TYPE>::nthInterval(int n) const { size_t iStopIndex = iStartIndex + 1; if (iStopIndex >= m_values.size()) { // a) Last log entry is for the start - Mantid::Types::DateAndTime ftimef = + Types::Core::DateAndTime ftimef = m_filter[m_filterQuickRef[refindex + 3].first].first; tf = ftimef; } else { // b) Using the earlier value of next log entry and next filter entry - Mantid::Types::DateAndTime ltimef = m_values[iStopIndex].time(); - Mantid::Types::DateAndTime ftimef = + Types::Core::DateAndTime ltimef = m_values[iStopIndex].time(); + Types::Core::DateAndTime ftimef = m_filter[m_filterQuickRef[refindex + 3].first].first; if (ltimef < ftimef) tf = ltimef; @@ -1669,8 +1662,8 @@ template <typename TYPE> TYPE TimeSeriesProperty<TYPE>::nthValue(int n) const { value = m_values[ilog].value(); } else { // 2. n < size - Mantid::Types::DateAndTime t0; - Mantid::Types::DateAndTime tf; + Types::Core::DateAndTime t0; + Types::Core::DateAndTime tf; size_t refindex = findNthIndexFromQuickRef(n); if (refindex + 3 >= m_filterQuickRef.size()) { @@ -1692,7 +1685,7 @@ template <typename TYPE> TYPE TimeSeriesProperty<TYPE>::nthValue(int n) const { * @return DateAndTime */ template <typename TYPE> -Mantid::Types::DateAndTime TimeSeriesProperty<TYPE>::nthTime(int n) const { +Types::Core::DateAndTime TimeSeriesProperty<TYPE>::nthTime(int n) const { sortIfNecessary(); if (m_values.empty()) { @@ -1738,7 +1731,7 @@ void TimeSeriesProperty<TYPE>::filterWith( } // 2. Construct mFilter - std::vector<Mantid::Types::DateAndTime> filtertimes = filter->timesAsVector(); + std::vector<Types::Core::DateAndTime> filtertimes = filter->timesAsVector(); std::vector<bool> filtervalues = filter->valuesAsVector(); assert(filtertimes.size() == filtervalues.size()); const size_t nFilterTimes(filtertimes.size()); @@ -1897,9 +1890,9 @@ template <typename TYPE> void TimeSeriesProperty<TYPE>::eliminateDuplicates() { typename std::vector<TimeValueUnit<TYPE>>::iterator vit; vit = m_values.begin() + 1; - Mantid::Types::DateAndTime prevtime = m_values.begin()->time(); + Types::Core::DateAndTime prevtime = m_values.begin()->time(); while (vit != m_values.end()) { - Mantid::Types::DateAndTime currtime = vit->time(); + Types::Core::DateAndTime currtime = vit->time(); if (prevtime == currtime) { // Print out warning g_log.debug() << "Entry @ Time = " << prevtime @@ -1972,7 +1965,7 @@ void TimeSeriesProperty<TYPE>::sortIfNecessary() const { * if t is later (larger) than the ending time, return m_value.size */ template <typename TYPE> -int TimeSeriesProperty<TYPE>::findIndex(Mantid::Types::DateAndTime t) const { +int TimeSeriesProperty<TYPE>::findIndex(Types::Core::DateAndTime t) const { // 0. Return with an empty container if (m_values.empty()) return 0; @@ -2006,8 +1999,8 @@ int TimeSeriesProperty<TYPE>::findIndex(Mantid::Types::DateAndTime t) const { * mP.size(): exceeding upper bound */ template <typename TYPE> -int TimeSeriesProperty<TYPE>::upperBound(Mantid::Types::DateAndTime t, - int istart, int iend) const { +int TimeSeriesProperty<TYPE>::upperBound(Types::Core::DateAndTime t, int istart, + int iend) const { // 0. Check validity if (istart < 0) { throw std::invalid_argument("Start Index cannot be less than 0"); @@ -2300,19 +2293,19 @@ void TimeSeriesProperty<TYPE>::saveProperty(::NeXus::File *file) { file->closeGroup(); } /** Calculate constant step histogram of the time series data. - * @param tMin -- minimal time to include in histogram - * @param tMax -- maximal time to constrain the histogram data - * @param counts -- vector of output histogrammed data. - * On input, the size of the vector defines the number of points in the - * histogram. - * On output, adds all property elements belonging to the time interval - * [tMin+n*dT;tMin+(n+1)*dT] - * to the initial values of each n-th element of the counts vector, - * where dT = (tMax-tMin)/counts.size() */ +* @param tMin -- minimal time to include in histogram +* @param tMax -- maximal time to constrain the histogram data +* @param counts -- vector of output histogrammed data. +* On input, the size of the vector defines the number of points in the +* histogram. +* On output, adds all property elements belonging to the time interval +* [tMin+n*dT;tMin+(n+1)*dT] +* to the initial values of each n-th element of the counts vector, +* where dT = (tMax-tMin)/counts.size() */ template <typename TYPE> void TimeSeriesProperty<TYPE>::histogramData( - const Mantid::Types::DateAndTime &tMin, - const Mantid::Types::DateAndTime &tMax, std::vector<double> &counts) const { + const Types::Core::DateAndTime &tMin, const Types::Core::DateAndTime &tMax, + std::vector<double> &counts) const { size_t nPoints = counts.size(); if (nPoints == 0) @@ -2337,8 +2330,8 @@ void TimeSeriesProperty<TYPE>::histogramData( template <> void TimeSeriesProperty<std::string>::histogramData( - const Mantid::Types::DateAndTime &tMin, - const Mantid::Types::DateAndTime &tMax, std::vector<double> &counts) const { + const Types::Core::DateAndTime &tMin, const Types::Core::DateAndTime &tMax, + std::vector<double> &counts) const { UNUSED_ARG(tMin); UNUSED_ARG(tMax); UNUSED_ARG(counts); @@ -2385,7 +2378,7 @@ std::vector<TYPE> TimeSeriesProperty<TYPE>::filteredValuesAsVector() const { */ template <typename TYPE> bool TimeSeriesProperty<TYPE>::isTimeFiltered( - const Mantid::Types::DateAndTime &time) const { + const Types::Core::DateAndTime &time) const { if (m_filter.empty()) { return false; // no filter } @@ -2397,10 +2390,8 @@ bool TimeSeriesProperty<TYPE>::isTimeFiltered( // Find which range it lives in auto filterEntry = std::lower_bound( m_filter.begin(), m_filter.end(), time, - [](const std::pair<Mantid::Types::DateAndTime, bool> &filterEntry, - const Mantid::Types::DateAndTime &t) { - return filterEntry.first < t; - }); + [](const std::pair<Types::Core::DateAndTime, bool> &filterEntry, + const Types::Core::DateAndTime &t) { return filterEntry.first < t; }); if (filterEntry != m_filter.begin()) { --filterEntry; // get the latest time BEFORE the given time @@ -2524,5 +2515,5 @@ filterByStatistic(TimeSeriesProperty<double> const *const propertyToFilter, }; return singleValue; } -} // namespace Kernel -} // namespace Mantid +} +} diff --git a/Framework/Kernel/src/TimeSplitter.cpp b/Framework/Kernel/src/TimeSplitter.cpp index d6f002c33de..b7ca889e836 100644 --- a/Framework/Kernel/src/TimeSplitter.cpp +++ b/Framework/Kernel/src/TimeSplitter.cpp @@ -1,9 +1,8 @@ #include "MantidKernel/TimeSplitter.h" -#include "MantidTypes/DateAndTime.h" - -using Mantid::Types::DateAndTime; namespace Mantid { + +using namespace Types::Core; namespace Kernel { /// Default constructor @@ -269,5 +268,5 @@ TimeSplitterType operator~(const TimeSplitterType &a) { } return out; } -} // namespace Kernel -} // namespace Mantid +} +} diff --git a/Framework/Kernel/src/UsageService.cpp b/Framework/Kernel/src/UsageService.cpp index 17ba9a5a5da..ba44dd00eab 100644 --- a/Framework/Kernel/src/UsageService.cpp +++ b/Framework/Kernel/src/UsageService.cpp @@ -1,12 +1,12 @@ #include "MantidKernel/UsageService.h" #include "MantidKernel/ChecksumHelper.h" #include "MantidKernel/ConfigService.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/Exception.h" #include "MantidKernel/InternetHelper.h" -#include "MantidKernel/Logger.h" #include "MantidKernel/MantidVersion.h" +#include "MantidKernel/Logger.h" #include "MantidKernel/ParaViewVersion.h" -#include "MantidTypes/DateAndTime.h" #include <Poco/ActiveResult.h> @@ -28,7 +28,7 @@ const std::string FEATURE_URL("http://reports.mantidproject.org/api/feature"); //---------------------------------------------------------------------------------------------- /** FeatureUsage - */ +*/ FeatureUsage::FeatureUsage(const std::string &type, const std::string &name, const bool internal) : type(type), name(name), internal(internal) {} @@ -96,7 +96,7 @@ void UsageServiceImpl::registerStartup() { } /** registerFeatureUsage - */ +*/ void UsageServiceImpl::registerFeatureUsage(const std::string &type, const std::string &name, const bool internal) { @@ -185,8 +185,8 @@ void UsageServiceImpl::timerCallback(Poco::Timer &) { } /** - * This puts together the system information for the json document. - */ +* This puts together the system information for the json document. +*/ ::Json::Value UsageServiceImpl::generateFeatureHeader() { ::Json::Value header; @@ -197,8 +197,8 @@ void UsageServiceImpl::timerCallback(Poco::Timer &) { } /** - * This puts together the system information for the json document. - */ +* This puts together the system information for the json document. +*/ std::string UsageServiceImpl::generateStartupMessage() { ::Json::Value message; @@ -228,7 +228,7 @@ std::string UsageServiceImpl::generateStartupMessage() { // mantid version and sha1 message["dateTime"] = - Mantid::Types::DateAndTime::getCurrentTime().toISO8601String(); + Types::Core::DateAndTime::getCurrentTime().toISO8601String(); message["application"] = m_application; @@ -274,17 +274,17 @@ std::string UsageServiceImpl::generateFeatureUsageMessage() { //-------------------------------------------------------------------------------------------- /** - * Asynchronous execution - */ +* Asynchronous execution +*/ /**Async method for sending startup messages - */ +*/ int UsageServiceImpl::sendStartupAsyncImpl(const std::string &message) { return this->sendReport(message, STARTUP_URL); } /**Async method for sending feature messages - */ +*/ int UsageServiceImpl::sendFeatureAsyncImpl(const std::string &message) { return this->sendReport(message, FEATURE_URL); } @@ -301,8 +301,7 @@ int UsageServiceImpl::sendReport(const std::string &message, } catch (Mantid::Kernel::Exception::InternetError &e) { status = e.errorCode(); g_log.information() << "Call to \"" << url << "\" responded with " << status - << "\n" - << e.what() << "\n"; + << "\n" << e.what() << "\n"; } return status; diff --git a/Framework/Kernel/test/CMakeLists.txt b/Framework/Kernel/test/CMakeLists.txt index 35786b3b63c..cf0f87c12d6 100644 --- a/Framework/Kernel/test/CMakeLists.txt +++ b/Framework/Kernel/test/CMakeLists.txt @@ -10,7 +10,7 @@ if ( CXXTEST_FOUND ) cxxtest_add_test ( KernelTest ${TEST_FILES} ) target_link_libraries( KernelTest LINK_PRIVATE ${TCMALLOC_LIBRARIES_LINKTIME} - Types + Types Kernel ${NEXUS_LIBRARIES} ${Boost_LIBRARIES} diff --git a/Framework/Kernel/test/FilteredTimeSeriesPropertyTest.h b/Framework/Kernel/test/FilteredTimeSeriesPropertyTest.h index f41dd4befea..07ce5cb3002 100644 --- a/Framework/Kernel/test/FilteredTimeSeriesPropertyTest.h +++ b/Framework/Kernel/test/FilteredTimeSeriesPropertyTest.h @@ -3,7 +3,6 @@ #include <cxxtest/TestSuite.h> #include "MantidKernel/FilteredTimeSeriesProperty.h" -#include "MantidKernel/TimeInterval.h" using Mantid::Kernel::FilteredTimeSeriesProperty; diff --git a/Framework/Kernel/test/LogFilterTest.h b/Framework/Kernel/test/LogFilterTest.h index 91c75a915be..eaa80e67fb0 100644 --- a/Framework/Kernel/test/LogFilterTest.h +++ b/Framework/Kernel/test/LogFilterTest.h @@ -5,7 +5,6 @@ #include "MantidKernel/LogFilter.h" #include "MantidKernel/TimeSeriesProperty.h" -#include "MantidKernel/TimeInterval.h" #include <ctime> using namespace Mantid::Kernel; diff --git a/Framework/Kernel/test/LogParserTest.h b/Framework/Kernel/test/LogParserTest.h index 0cd7f7607c7..44f1fbf83b1 100644 --- a/Framework/Kernel/test/LogParserTest.h +++ b/Framework/Kernel/test/LogParserTest.h @@ -6,18 +6,17 @@ #include <fstream> #include <numeric> -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/LogParser.h" +#include "MantidKernel/make_unique.h" #include "MantidKernel/PropertyWithValue.h" #include "MantidKernel/TimeSeriesProperty.h" -#include "MantidKernel/make_unique.h" #include <boost/lexical_cast.hpp> #include <boost/scoped_ptr.hpp> #include <Poco/File.h> using namespace Mantid::Kernel; -using namespace Mantid::Types; +using namespace Mantid::Types::Core; class LogParserTest : public CxxTest::TestSuite { public: @@ -243,18 +242,14 @@ public: // Check the size TS_ASSERT_EQUALS(4, timeseriesprop->size()); // Check the exact time stamps - TS_ASSERT_EQUALS( - DateAndTimeHelpers::createFromISO8601("2000-09-05T12:22:55"), - timeseriesprop->nthTime(0)); - TS_ASSERT_EQUALS( - DateAndTimeHelpers::createFromISO8601("2000-09-05T12:23:08"), - timeseriesprop->nthTime(1)); - TS_ASSERT_EQUALS( - DateAndTimeHelpers::createFromISO8601("2000-09-05T12:23:22"), - timeseriesprop->nthTime(2)); - TS_ASSERT_EQUALS( - DateAndTimeHelpers::createFromISO8601("2000-09-05T12:23:37"), - timeseriesprop->nthTime(3)); + TS_ASSERT_EQUALS(DateAndTime("2000-09-05T12:22:55"), + timeseriesprop->nthTime(0)); + TS_ASSERT_EQUALS(DateAndTime("2000-09-05T12:23:08"), + timeseriesprop->nthTime(1)); + TS_ASSERT_EQUALS(DateAndTime("2000-09-05T12:23:22"), + timeseriesprop->nthTime(2)); + TS_ASSERT_EQUALS(DateAndTime("2000-09-05T12:23:37"), + timeseriesprop->nthTime(3)); } void testConstructionFromPropertyUsingICPVariant_CHANGE_PERIOD() { @@ -279,18 +274,14 @@ public: // Check the size TS_ASSERT_EQUALS(4, timeseriesprop->size()); // Check the exact time stamps - TS_ASSERT_EQUALS( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:15:00"), - timeseriesprop->nthTime(0)); - TS_ASSERT_EQUALS( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:16:00"), - timeseriesprop->nthTime(1)); - TS_ASSERT_EQUALS( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"), - timeseriesprop->nthTime(2)); - TS_ASSERT_EQUALS( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:00"), - timeseriesprop->nthTime(3)); + TS_ASSERT_EQUALS(DateAndTime("2007-11-30T16:15:00"), + timeseriesprop->nthTime(0)); + TS_ASSERT_EQUALS(DateAndTime("2007-11-30T16:16:00"), + timeseriesprop->nthTime(1)); + TS_ASSERT_EQUALS(DateAndTime("2007-11-30T16:17:00"), + timeseriesprop->nthTime(2)); + TS_ASSERT_EQUALS(DateAndTime("2007-11-30T16:18:00"), + timeseriesprop->nthTime(3)); } void testConstructionFromPropertyUsingICPVariant_CHANGE_SPACE_PERIOD() { @@ -315,18 +306,14 @@ public: // Check the size TS_ASSERT_EQUALS(4, timeseriesprop->size()); // Check the exact time stamps - TS_ASSERT_EQUALS( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:15:00"), - timeseriesprop->nthTime(0)); - TS_ASSERT_EQUALS( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:16:00"), - timeseriesprop->nthTime(1)); - TS_ASSERT_EQUALS( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"), - timeseriesprop->nthTime(2)); - TS_ASSERT_EQUALS( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:00"), - timeseriesprop->nthTime(3)); + TS_ASSERT_EQUALS(DateAndTime("2007-11-30T16:15:00"), + timeseriesprop->nthTime(0)); + TS_ASSERT_EQUALS(DateAndTime("2007-11-30T16:16:00"), + timeseriesprop->nthTime(1)); + TS_ASSERT_EQUALS(DateAndTime("2007-11-30T16:17:00"), + timeseriesprop->nthTime(2)); + TS_ASSERT_EQUALS(DateAndTime("2007-11-30T16:18:00"), + timeseriesprop->nthTime(3)); } // Check that periods that don't have a full "CHANGE PERIOD" flag are not @@ -354,15 +341,12 @@ public: // Check the size TS_ASSERT_EQUALS(3, timeseriesprop->size()); // Check the exact time stamps - TS_ASSERT_EQUALS( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:15:00"), - timeseriesprop->nthTime(0)); - TS_ASSERT_EQUALS( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:16:00"), - timeseriesprop->nthTime(1)); - TS_ASSERT_EQUALS( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"), - timeseriesprop->nthTime(2)); + TS_ASSERT_EQUALS(DateAndTime("2007-11-30T16:15:00"), + timeseriesprop->nthTime(0)); + TS_ASSERT_EQUALS(DateAndTime("2007-11-30T16:16:00"), + timeseriesprop->nthTime(1)); + TS_ASSERT_EQUALS(DateAndTime("2007-11-30T16:17:00"), + timeseriesprop->nthTime(2)); } void testCreatesCurrentPeriodLog() { @@ -414,8 +398,7 @@ public: auto log = make_unique<TimeSeriesProperty<double>>("MydoubleLog"); std::vector<double> values(logSize); std::iota(values.begin(), values.end(), 1); - DateAndTime firstTime = - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); + DateAndTime firstTime("2007-11-30T16:17:00"); std::vector<DateAndTime> times(logSize); std::generate(times.begin(), times.end(), [&firstTime] { return firstTime += 10.0; }); @@ -516,10 +499,14 @@ public: {"2013-10-16T19:13:09", 1}}; const std::vector<std::pair<std::string, bool>> checkRunning{ - {"2013-10-16T19:04:48", true}, {"2013-10-16T19:06:53", false}, - {"2013-10-16T19:06:53", true}, {"2013-10-16T19:08:58", false}, - {"2013-10-16T19:08:59", true}, {"2013-10-16T19:11:03", false}, - {"2013-10-16T19:11:04", true}, {"2013-10-16T19:13:09", false}}; + {"2013-10-16T19:04:48", true}, + {"2013-10-16T19:06:53", false}, + {"2013-10-16T19:06:53", true}, + {"2013-10-16T19:08:58", false}, + {"2013-10-16T19:08:59", true}, + {"2013-10-16T19:11:03", false}, + {"2013-10-16T19:11:04", true}, + {"2013-10-16T19:13:09", false}}; const LogParser logparser(log.get()); @@ -636,25 +623,18 @@ public: auto log = make_unique<TimeSeriesProperty<std::string>>("MyICPevent"); // (This is a cut-down version of EMU66122) - const DateAndTime timeZero = - DateAndTimeHelpers::createFromISO8601("2016-10-01T10:01:44"); + const DateAndTime timeZero{"2016-10-01T10:01:44"}; const std::vector<DateAndTime> times{ timeZero, timeZero + 3.0, timeZero + 3.0, timeZero + 3.0, timeZero + 51.0, timeZero + 51.0, timeZero + 57.0, timeZero + 60.0, timeZero + 60.0, timeZero + 60.0, timeZero + 111.0, timeZero + 111.0}; const std::vector<std::string> values{ - "CHANGE_PERIOD 1", - "CHANGE_PERIOD 1", - "START_COLLECTION PERIOD 1 GF 0 RF 0 GUAH 0.000000", - "BEGIN", + "CHANGE_PERIOD 1", "CHANGE_PERIOD 1", + "START_COLLECTION PERIOD 1 GF 0 RF 0 GUAH 0.000000", "BEGIN", "STOP_COLLECTION PERIOD 1 GF 1931 RF 1933 GUAH 0.000000 DUR 48", - "ABORT", - "CHANGE_PERIOD 1", - "CHANGE_PERIOD 1", - "START_COLLECTION PERIOD 1 GF 0 RF 0 GUAH 0.000000", - "BEGIN", - "STOP_COLLECTION PERIOD 1 GF 2062 RF 2064 GUAH 0.000000 DUR 51", - "END"}; + "ABORT", "CHANGE_PERIOD 1", "CHANGE_PERIOD 1", + "START_COLLECTION PERIOD 1 GF 0 RF 0 GUAH 0.000000", "BEGIN", + "STOP_COLLECTION PERIOD 1 GF 2062 RF 2064 GUAH 0.000000 DUR 51", "END"}; log->addValues(times, values); const std::multimap<DateAndTime, bool> expectedRunning{ @@ -681,8 +661,7 @@ public: auto log = make_unique<TimeSeriesProperty<std::string>>("MyICPevent"); // (This is a cut-down version of EMU66122, changed to "old style" commands) - const DateAndTime timeZero = - DateAndTimeHelpers::createFromISO8601("2016-10-01T10:01:44"); + const DateAndTime timeZero{"2016-10-01T10:01:44"}; const std::vector<DateAndTime> times{ timeZero, timeZero + 3.0, timeZero + 3.0, timeZero + 51.0, timeZero + 57.0, timeZero + 60.0, timeZero + 60.0, timeZero + 111.0}; diff --git a/Framework/Kernel/test/PropertyNexusTest.h b/Framework/Kernel/test/PropertyNexusTest.h index 3d94303ba1f..20abca3a06e 100644 --- a/Framework/Kernel/test/PropertyNexusTest.h +++ b/Framework/Kernel/test/PropertyNexusTest.h @@ -1,20 +1,19 @@ #ifndef MANTID_API_PROPERTYNEXUSTEST_H_ #define MANTID_API_PROPERTYNEXUSTEST_H_ -#include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/PropertyNexus.h" #include "MantidKernel/PropertyWithValue.h" #include "MantidKernel/System.h" #include "MantidKernel/TimeSeriesProperty.h" #include "MantidKernel/Timer.h" #include "MantidTestHelpers/NexusTestHelper.h" -#include "MantidTypes/DateAndTime.h" #include <cxxtest/TestSuite.h> using namespace Mantid; using namespace Mantid::API; using namespace Mantid::Kernel; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; class PropertyNexusTest : public CxxTest::TestSuite { public: @@ -51,28 +50,20 @@ public: pvd.saveProperty(th.file); TimeSeriesProperty<int> tspi("int_series"); - tspi.addValue(DateAndTimeHelpers::createFromISO8601("2011-01-01T00:00:01"), - 1234); - tspi.addValue(DateAndTimeHelpers::createFromISO8601("2011-01-01T00:01:02"), - 4567); + tspi.addValue(DateAndTime("2011-01-01T00:00:01"), 1234); + tspi.addValue(DateAndTime("2011-01-01T00:01:02"), 4567); TimeSeriesProperty<double> tspd("double_series"); - tspd.addValue(DateAndTimeHelpers::createFromISO8601("2011-01-01T00:00:01"), - 1234.5); - tspd.addValue(DateAndTimeHelpers::createFromISO8601("2011-01-01T00:01:02"), - 4567.8); + tspd.addValue(DateAndTime("2011-01-01T00:00:01"), 1234.5); + tspd.addValue(DateAndTime("2011-01-01T00:01:02"), 4567.8); TimeSeriesProperty<bool> tspb("bool_series"); - tspb.addValue(DateAndTimeHelpers::createFromISO8601("2011-01-01T00:00:01"), - true); - tspb.addValue(DateAndTimeHelpers::createFromISO8601("2011-01-01T00:01:02"), - false); + tspb.addValue(DateAndTime("2011-01-01T00:00:01"), true); + tspb.addValue(DateAndTime("2011-01-01T00:01:02"), false); TimeSeriesProperty<std::string> tsps("string_series"); - tsps.addValue(DateAndTimeHelpers::createFromISO8601("2011-01-01T00:00:01"), - "help me i"); - tsps.addValue(DateAndTimeHelpers::createFromISO8601("2011-01-01T00:01:02"), - "am stuck in a NXS file"); + tsps.addValue(DateAndTime("2011-01-01T00:00:01"), "help me i"); + tsps.addValue(DateAndTime("2011-01-01T00:01:02"), "am stuck in a NXS file"); tspi.saveProperty(th.file); tspd.saveProperty(th.file); diff --git a/Framework/Kernel/test/TimeSeriesPropertyTest.h b/Framework/Kernel/test/TimeSeriesPropertyTest.h index d0299411a05..9d5bf0578f4 100644 --- a/Framework/Kernel/test/TimeSeriesPropertyTest.h +++ b/Framework/Kernel/test/TimeSeriesPropertyTest.h @@ -1,23 +1,21 @@ #ifndef TIMESERIESPROPERTYTEST_H_ #define TIMESERIESPROPERTYTEST_H_ -#include "MantidKernel/DateAndTimeHelpers.h" +#include <cxxtest/TestSuite.h> +#include "MantidKernel/TimeSeriesProperty.h" #include "MantidKernel/Exception.h" +#include "MantidKernel/make_unique.h" #include "MantidKernel/PropertyWithValue.h" -#include "MantidKernel/TimeInterval.h" -#include "MantidKernel/TimeSeriesProperty.h" #include "MantidKernel/TimeSplitter.h" -#include "MantidKernel/make_unique.h" -#include <cxxtest/TestSuite.h> +#include <cmath> #include <boost/make_shared.hpp> -#include <boost/scoped_ptr.hpp> #include <boost/shared_ptr.hpp> -#include <cmath> +#include <boost/scoped_ptr.hpp> #include <vector> using namespace Mantid::Kernel; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; class TimeSeriesPropertyTest : public CxxTest::TestSuite { // Create a small TSP<double>. Callee owns the returned object. @@ -34,10 +32,9 @@ class TimeSeriesPropertyTest : public CxxTest::TestSuite { // Create a small TSP<int>. Callee owns the returned object. TimeSeriesProperty<int> *createIntegerTSP(int numberOfValues) { TimeSeriesProperty<int> *log = new TimeSeriesProperty<int>("intProp"); - auto startTime = - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); + DateAndTime startTime("2007-11-30T16:17:00"); for (int value = 0; value < numberOfValues; ++value) { - auto time = startTime + value * 10.0; + DateAndTime time = startTime + value * 10.0; TS_ASSERT_THROWS_NOTHING(log->addValue(time, value + 1)); } return log; @@ -172,14 +169,10 @@ public: TS_ASSERT_DELTA(timeSec[3], 30.0, 1e-6); std::vector<DateAndTime> time; time = p->timesAsVector(); - TS_ASSERT_EQUALS( - time[0], DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00")); - TS_ASSERT_EQUALS( - time[1], DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10")); - TS_ASSERT_EQUALS( - time[2], DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:20")); - TS_ASSERT_EQUALS( - time[3], DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30")); + TS_ASSERT_EQUALS(time[0], DateAndTime("2007-11-30T16:17:00")); + TS_ASSERT_EQUALS(time[1], DateAndTime("2007-11-30T16:17:10")); + TS_ASSERT_EQUALS(time[2], DateAndTime("2007-11-30T16:17:20")); + TS_ASSERT_EQUALS(time[3], DateAndTime("2007-11-30T16:17:30")); delete p; } @@ -187,7 +180,7 @@ public: void test_replaceValues() { // Arrange size_t num = 1000; - auto first = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10"); + DateAndTime first("2007-11-30T16:17:10"); std::vector<DateAndTime> times; std::vector<double> values; @@ -214,7 +207,7 @@ public: void test_addValues() { size_t num = 1000; - auto first = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10"); + DateAndTime first("2007-11-30T16:17:10"); std::vector<DateAndTime> times; std::vector<double> values; @@ -257,13 +250,11 @@ public: TS_ASSERT_EQUALS(log->size(), 5); - auto t0 = log->firstTime(); - auto tf = log->lastTime(); + DateAndTime t0 = log->firstTime(); + DateAndTime tf = log->lastTime(); - TS_ASSERT_EQUALS( - t0, DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00")); - TS_ASSERT_EQUALS( - tf, DateAndTimeHelpers::createFromISO8601("2007-11-30T16:19:10")); + TS_ASSERT_EQUALS(t0, DateAndTime("2007-11-30T16:17:00")); + TS_ASSERT_EQUALS(tf, DateAndTime("2007-11-30T16:19:10")); delete log; delete log2; @@ -318,8 +309,8 @@ public: void test_filterByTime() { TimeSeriesProperty<int> *log = createIntegerTSP(6); TS_ASSERT_EQUALS(log->realSize(), 6); - auto start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10"); - auto stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:40"); + DateAndTime start = DateAndTime("2007-11-30T16:17:10"); + DateAndTime stop = DateAndTime("2007-11-30T16:17:40"); // Since the filter is < stop, the last one is not counted, so there are 3 // taken out. @@ -337,8 +328,8 @@ public: TS_ASSERT_EQUALS(log->realSize(), 6); Mantid::Kernel::SplittingInterval interval0( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10"), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:40"), 0); + DateAndTime("2007-11-30T16:17:10"), DateAndTime("2007-11-30T16:17:40"), + 0); Mantid::Kernel::TimeSplitterType splitters; splitters.push_back(interval0); @@ -358,12 +349,12 @@ public: TS_ASSERT_EQUALS(log->realSize(), 10); Mantid::Kernel::SplittingInterval interval0( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10"), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:40"), 0); + DateAndTime("2007-11-30T16:17:10"), DateAndTime("2007-11-30T16:17:40"), + 0); Mantid::Kernel::SplittingInterval interval1( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:05"), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:25"), 0); + DateAndTime("2007-11-30T16:18:05"), DateAndTime("2007-11-30T16:18:25"), + 0); Mantid::Kernel::TimeSplitterType splitters; splitters.push_back(interval0); @@ -385,8 +376,8 @@ public: TimeSeriesProperty<int> *log = createIntegerTSP(1); TS_ASSERT_EQUALS(log->realSize(), 1); - auto start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10"); - auto stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:40"); + DateAndTime start = DateAndTime("2007-11-30T16:17:10"); + DateAndTime stop = DateAndTime("2007-11-30T16:17:40"); log->filterByTime(start, stop); // Still there! @@ -402,8 +393,8 @@ public: TS_ASSERT_THROWS_NOTHING(log->addValue("1990-01-01T00:00:00", 1)); TS_ASSERT_EQUALS(log->realSize(), 1); - auto start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10"); - auto stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:40"); + DateAndTime start = DateAndTime("2007-11-30T16:17:10"); + DateAndTime stop = DateAndTime("2007-11-30T16:17:40"); log->filterByTime(start, stop); // Still there! @@ -434,15 +425,15 @@ public: DateAndTime t; s = splitter[0]; - t = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:09"); + t = DateAndTime("2007-11-30T16:17:09"); TS_ASSERT_DELTA(s.start(), t, 1e-3); - t = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:11"); + t = DateAndTime("2007-11-30T16:17:11"); TS_ASSERT_DELTA(s.stop(), t, 1e-3); s = splitter[1]; - t = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:29"); + t = DateAndTime("2007-11-30T16:17:29"); TS_ASSERT_DELTA(s.start(), t, 1e-3); - t = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:41"); + t = DateAndTime("2007-11-30T16:17:41"); TS_ASSERT_DELTA(s.stop(), t, 1e-3); // Now test with left-aligned log value boundaries @@ -451,15 +442,15 @@ public: TS_ASSERT_EQUALS(splitter.size(), 2); s = splitter[0]; - t = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10"); + t = DateAndTime("2007-11-30T16:17:10"); TS_ASSERT_DELTA(s.start(), t, 1e-3); - t = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:20"); + t = DateAndTime("2007-11-30T16:17:20"); TS_ASSERT_DELTA(s.stop(), t, 1e-3); s = splitter[1]; - t = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30"); + t = DateAndTime("2007-11-30T16:17:30"); TS_ASSERT_DELTA(s.start(), t, 1e-3); - t = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:50"); + t = DateAndTime("2007-11-30T16:17:50"); TS_ASSERT_DELTA(s.stop(), t, 1e-3); // Check throws if min > max @@ -486,84 +477,68 @@ public: TS_ASSERT_THROWS_NOTHING(log.addValue("2007-11-30T16:17:50", 2)); // Create a TimeInterval that's wider than this log - TimeInterval interval( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:16:00"), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:50")); + TimeInterval interval(DateAndTime("2007-11-30T16:16:00"), + DateAndTime("2007-11-30T16:18:50")); TimeSplitterType splitter; // Test good at both ends log.makeFilterByValue(splitter, 1.0, 2.2, 1.0, false); log.expandFilterToRange(splitter, 1.0, 2.2, interval); TS_ASSERT_EQUALS(splitter.size(), 2); - TS_ASSERT_DELTA( - splitter[0].start(), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:16:00"), 1e-3); - TS_ASSERT_DELTA( - splitter[0].stop(), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:20"), 1e-3); - TS_ASSERT_DELTA( - splitter[1].start(), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:50"), 1e-3); - TS_ASSERT_DELTA( - splitter[1].stop(), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:50"), 1e-3); + TS_ASSERT_DELTA(splitter[0].start(), DateAndTime("2007-11-30T16:16:00"), + 1e-3); + TS_ASSERT_DELTA(splitter[0].stop(), DateAndTime("2007-11-30T16:17:20"), + 1e-3); + TS_ASSERT_DELTA(splitter[1].start(), DateAndTime("2007-11-30T16:17:50"), + 1e-3); + TS_ASSERT_DELTA(splitter[1].stop(), DateAndTime("2007-11-30T16:18:50"), + 1e-3); // Test bad at both ends log.makeFilterByValue(splitter, 2.5, 10.0, 0.0, false); log.expandFilterToRange(splitter, 2.5, 10.0, interval); TS_ASSERT_EQUALS(splitter.size(), 1); - TS_ASSERT_DELTA( - splitter[0].start(), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:20"), 1e-3); - TS_ASSERT_DELTA( - splitter[0].stop(), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:50"), 1e-3); + TS_ASSERT_DELTA(splitter[0].start(), DateAndTime("2007-11-30T16:17:20"), + 1e-3); + TS_ASSERT_DELTA(splitter[0].stop(), DateAndTime("2007-11-30T16:17:50"), + 1e-3); // Test good at start, bad at end log.makeFilterByValue(splitter, -1.0, 1.5, 0.0, false); log.expandFilterToRange(splitter, -1.0, 1.5, interval); TS_ASSERT_EQUALS(splitter.size(), 1); - TS_ASSERT_DELTA( - splitter[0].start(), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:16:00"), 1e-3); - TS_ASSERT_DELTA( - splitter[0].stop(), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10"), 1e-3); + TS_ASSERT_DELTA(splitter[0].start(), DateAndTime("2007-11-30T16:16:00"), + 1e-3); + TS_ASSERT_DELTA(splitter[0].stop(), DateAndTime("2007-11-30T16:17:10"), + 1e-3); // Test good at end, bad at start log.makeFilterByValue(splitter, 1.99, 2.5, 1.0, false); log.expandFilterToRange(splitter, 1.99, 2.5, interval); TS_ASSERT_EQUALS(splitter.size(), 2); - TS_ASSERT_DELTA( - splitter[0].start(), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10"), 1e-3); - TS_ASSERT_DELTA( - splitter[0].stop(), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:20"), 1e-3); - TS_ASSERT_DELTA( - splitter[1].start(), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:50"), 1e-3); - TS_ASSERT_DELTA( - splitter[1].stop(), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:50"), 1e-3); + TS_ASSERT_DELTA(splitter[0].start(), DateAndTime("2007-11-30T16:17:10"), + 1e-3); + TS_ASSERT_DELTA(splitter[0].stop(), DateAndTime("2007-11-30T16:17:20"), + 1e-3); + TS_ASSERT_DELTA(splitter[1].start(), DateAndTime("2007-11-30T16:17:50"), + 1e-3); + TS_ASSERT_DELTA(splitter[1].stop(), DateAndTime("2007-11-30T16:18:50"), + 1e-3); // Check throws if min > max TS_ASSERT_THROWS(log.expandFilterToRange(splitter, 2.0, 1.0, interval), std::invalid_argument); // Test good at both ends, but interval narrower than log range - TimeInterval narrowinterval( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:15"), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:41")); + TimeInterval narrowinterval(DateAndTime("2007-11-30T16:17:15"), + DateAndTime("2007-11-30T16:17:41")); log.makeFilterByValue(splitter, 0.0, 10.0, 0.0, false); log.expandFilterToRange(splitter, 0.0, 10.0, narrowinterval); TS_ASSERT_EQUALS(splitter.size(), 1); - TS_ASSERT_DELTA( - splitter[0].start(), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"), 1e-3); - TS_ASSERT_DELTA( - splitter[0].stop(), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:50"), 1e-3); + TS_ASSERT_DELTA(splitter[0].start(), DateAndTime("2007-11-30T16:17:00"), + 1e-3); + TS_ASSERT_DELTA(splitter[0].stop(), DateAndTime("2007-11-30T16:17:50"), + 1e-3); } void test_expandFilterToRange_throws_for_string_property() { @@ -580,35 +555,30 @@ public: // Test a filter that's fully within the range of both properties TimeSplitterType filter; - filter.push_back(SplittingInterval( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:05"), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:29"))); + filter.push_back(SplittingInterval(DateAndTime("2007-11-30T16:17:05"), + DateAndTime("2007-11-30T16:17:29"))); TS_ASSERT_DELTA(dblLog->averageValueInFilter(filter), 7.308, 0.001); TS_ASSERT_DELTA(intLog->averageValueInFilter(filter), 2.167, 0.001); // Test a filter that starts before the log start time - filter[0] = SplittingInterval( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:16:30"), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:13")); + filter[0] = SplittingInterval(DateAndTime("2007-11-30T16:16:30"), + DateAndTime("2007-11-30T16:17:13")); TS_ASSERT_DELTA(dblLog->averageValueInFilter(filter), 9.820, 0.001); TS_ASSERT_DELTA(intLog->averageValueInFilter(filter), 1.070, 0.001); // How about one that's entirely outside the log range (should just take the // last value) - filter[0] = SplittingInterval( - DateAndTimeHelpers::createFromISO8601("2013-01-01T00:00:00"), - DateAndTimeHelpers::createFromISO8601("2013-01-01T01:00:00")); + filter[0] = SplittingInterval(DateAndTime("2013-01-01T00:00:00"), + DateAndTime("2013-01-01T01:00:00")); TS_ASSERT_DELTA(dblLog->averageValueInFilter(filter), 10.55, 0.001); TS_ASSERT_DELTA(intLog->averageValueInFilter(filter), 5.0, 0.001); // Test a filter with two separate ranges, one of which goes past the end of // the log - filter[0] = SplittingInterval( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:05"), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:15")); - filter.push_back(SplittingInterval( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:25"), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:45"))); + filter[0] = SplittingInterval(DateAndTime("2007-11-30T16:17:05"), + DateAndTime("2007-11-30T16:17:15")); + filter.push_back(SplittingInterval(DateAndTime("2007-11-30T16:17:25"), + DateAndTime("2007-11-30T16:17:45"))); TS_ASSERT_DELTA(dblLog->averageValueInFilter(filter), 9.123, 0.001); TS_ASSERT_DELTA(intLog->averageValueInFilter(filter), 3.167, 0.001); @@ -616,26 +586,22 @@ public: // the first) // It should work fine. filter[0] = filter[1]; - filter[0] = SplittingInterval( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:05"), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:15")); + filter[0] = SplittingInterval(DateAndTime("2007-11-30T16:17:05"), + DateAndTime("2007-11-30T16:17:15")); TS_ASSERT_DELTA(dblLog->averageValueInFilter(filter), 9.123, 0.001); TS_ASSERT_DELTA(intLog->averageValueInFilter(filter), 3.167, 0.001); // What about an overlap between the filters? It's odd, but it's allowed. - filter[0] = SplittingInterval( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:05"), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:15")); - filter[1] = SplittingInterval( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10"), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:20")); + filter[0] = SplittingInterval(DateAndTime("2007-11-30T16:17:05"), + DateAndTime("2007-11-30T16:17:15")); + filter[1] = SplittingInterval(DateAndTime("2007-11-30T16:17:10"), + DateAndTime("2007-11-30T16:17:20")); TS_ASSERT_DELTA(dblLog->averageValueInFilter(filter), 8.16, 0.001); TS_ASSERT_DELTA(intLog->averageValueInFilter(filter), 1.75, 0.001); // Check the correct behaviour of empty of single value logs. TS_ASSERT(std::isnan(dProp->averageValueInFilter(filter))); - iProp->addValue( - DateAndTimeHelpers::createFromISO8601("2010-11-30T16:17:25"), 99); + iProp->addValue(DateAndTime("2010-11-30T16:17:25"), 99); TS_ASSERT_EQUALS(iProp->averageValueInFilter(filter), 99.0); // Clean up @@ -674,24 +640,24 @@ public: // Make a splitter DateAndTime start, stop; TimeSplitterType splitter; - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:40"); + start = DateAndTime("2007-11-30T16:17:10"); + stop = DateAndTime("2007-11-30T16:17:40"); splitter.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:55"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:56"); + start = DateAndTime("2007-11-30T16:17:55"); + stop = DateAndTime("2007-11-30T16:17:56"); splitter.push_back(SplittingInterval(start, stop, 1)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:56"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:01"); + start = DateAndTime("2007-11-30T16:17:56"); + stop = DateAndTime("2007-11-30T16:18:01"); splitter.push_back(SplittingInterval(start, stop, 2)); // just one entry - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:09"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:21"); + start = DateAndTime("2007-11-30T16:18:09"); + stop = DateAndTime("2007-11-30T16:18:21"); splitter.push_back(SplittingInterval(start, stop, 3)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:45"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:22:50"); + start = DateAndTime("2007-11-30T16:18:45"); + stop = DateAndTime("2007-11-30T16:22:50"); splitter.push_back(SplittingInterval(start, stop, 4)); log->splitByTime(splitter, outputs, false); @@ -729,12 +695,12 @@ public: // Make a splitter DateAndTime start, stop; TimeSplitterType splitter; - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:40"); + start = DateAndTime("2007-11-30T16:17:10"); + stop = DateAndTime("2007-11-30T16:17:40"); splitter.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:35"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:59"); + start = DateAndTime("2007-11-30T16:17:35"); + stop = DateAndTime("2007-11-30T16:17:59"); splitter.push_back(SplittingInterval(start, stop, 0)); log->splitByTime(splitter, outputs, false); @@ -757,20 +723,13 @@ public: void test_splitByTimeVector() { // create the splitters std::vector<DateAndTime> split_time_vec; - split_time_vec.push_back( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10")); - split_time_vec.push_back( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:40")); - split_time_vec.push_back( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:55")); - split_time_vec.push_back( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:56")); - split_time_vec.push_back( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:09")); - split_time_vec.push_back( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:45")); - split_time_vec.push_back( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:22:50")); + split_time_vec.push_back(DateAndTime("2007-11-30T16:17:10")); + split_time_vec.push_back(DateAndTime("2007-11-30T16:17:40")); + split_time_vec.push_back(DateAndTime("2007-11-30T16:17:55")); + split_time_vec.push_back(DateAndTime("2007-11-30T16:17:56")); + split_time_vec.push_back(DateAndTime("2007-11-30T16:18:09")); + split_time_vec.push_back(DateAndTime("2007-11-30T16:18:45")); + split_time_vec.push_back(DateAndTime("2007-11-30T16:22:50")); std::vector<int> split_target_vec; split_target_vec.push_back(1); @@ -781,26 +740,16 @@ public: split_target_vec.push_back(3); TimeSeriesProperty<int> log("test log"); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"), - 1); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30"), - 2); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:00"), - 3); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:30"), - 4); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:19:00"), - 5); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:19:30"), - 6); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:20:00"), - 7); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:20:30"), - 8); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:21:00"), - 9); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:21:30"), - 10); + log.addValue(DateAndTime("2007-11-30T16:17:00"), 1); + log.addValue(DateAndTime("2007-11-30T16:17:30"), 2); + log.addValue(DateAndTime("2007-11-30T16:18:00"), 3); + log.addValue(DateAndTime("2007-11-30T16:18:30"), 4); + log.addValue(DateAndTime("2007-11-30T16:19:00"), 5); + log.addValue(DateAndTime("2007-11-30T16:19:30"), 6); + log.addValue(DateAndTime("2007-11-30T16:20:00"), 7); + log.addValue(DateAndTime("2007-11-30T16:20:30"), 8); + log.addValue(DateAndTime("2007-11-30T16:21:00"), 9); + log.addValue(DateAndTime("2007-11-30T16:21:30"), 10); std::vector<TimeSeriesProperty<int> *> outputs; for (int itarget = 0; itarget < 4; ++itarget) { @@ -850,20 +799,13 @@ public: void test_splitByTimeVectorEarlySplitter() { // create the splitters std::vector<DateAndTime> split_time_vec; - split_time_vec.push_back( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:00:10")); - split_time_vec.push_back( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:00:40")); - split_time_vec.push_back( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:07:55")); - split_time_vec.push_back( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:07:56")); - split_time_vec.push_back( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:08:09")); - split_time_vec.push_back( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:08:45")); - split_time_vec.push_back( - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:12:50")); + split_time_vec.push_back(DateAndTime("2007-11-30T16:00:10")); + split_time_vec.push_back(DateAndTime("2007-11-30T16:00:40")); + split_time_vec.push_back(DateAndTime("2007-11-30T16:07:55")); + split_time_vec.push_back(DateAndTime("2007-11-30T16:07:56")); + split_time_vec.push_back(DateAndTime("2007-11-30T16:08:09")); + split_time_vec.push_back(DateAndTime("2007-11-30T16:08:45")); + split_time_vec.push_back(DateAndTime("2007-11-30T16:12:50")); std::vector<int> split_target_vec; split_target_vec.push_back(1); @@ -874,26 +816,16 @@ public: split_target_vec.push_back(3); TimeSeriesProperty<int> log("test log"); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"), - 1); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30"), - 2); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:00"), - 3); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:30"), - 4); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:19:00"), - 5); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:19:30"), - 6); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:20:00"), - 7); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:20:30"), - 8); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:21:00"), - 9); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:21:30"), - 10); + log.addValue(DateAndTime("2007-11-30T16:17:00"), 1); + log.addValue(DateAndTime("2007-11-30T16:17:30"), 2); + log.addValue(DateAndTime("2007-11-30T16:18:00"), 3); + log.addValue(DateAndTime("2007-11-30T16:18:30"), 4); + log.addValue(DateAndTime("2007-11-30T16:19:00"), 5); + log.addValue(DateAndTime("2007-11-30T16:19:30"), 6); + log.addValue(DateAndTime("2007-11-30T16:20:00"), 7); + log.addValue(DateAndTime("2007-11-30T16:20:30"), 8); + log.addValue(DateAndTime("2007-11-30T16:21:00"), 9); + log.addValue(DateAndTime("2007-11-30T16:21:30"), 10); // Initialze the 4 splitters std::vector<TimeSeriesProperty<int> *> outputs; @@ -920,20 +852,13 @@ public: void test_splitByTimeVectorLaterSplitter() { // create the splitters std::vector<DateAndTime> split_time_vec; - split_time_vec.push_back( - DateAndTimeHelpers::createFromISO8601("2007-12-30T16:00:10")); - split_time_vec.push_back( - DateAndTimeHelpers::createFromISO8601("2007-12-30T16:00:40")); - split_time_vec.push_back( - DateAndTimeHelpers::createFromISO8601("2007-12-30T16:07:55")); - split_time_vec.push_back( - DateAndTimeHelpers::createFromISO8601("2007-12-30T16:07:56")); - split_time_vec.push_back( - DateAndTimeHelpers::createFromISO8601("2007-12-30T16:08:09")); - split_time_vec.push_back( - DateAndTimeHelpers::createFromISO8601("2007-12-30T16:08:45")); - split_time_vec.push_back( - DateAndTimeHelpers::createFromISO8601("2007-12-30T16:12:50")); + split_time_vec.push_back(DateAndTime("2007-12-30T16:00:10")); + split_time_vec.push_back(DateAndTime("2007-12-30T16:00:40")); + split_time_vec.push_back(DateAndTime("2007-12-30T16:07:55")); + split_time_vec.push_back(DateAndTime("2007-12-30T16:07:56")); + split_time_vec.push_back(DateAndTime("2007-12-30T16:08:09")); + split_time_vec.push_back(DateAndTime("2007-12-30T16:08:45")); + split_time_vec.push_back(DateAndTime("2007-12-30T16:12:50")); std::vector<int> split_target_vec; split_target_vec.push_back(1); @@ -945,26 +870,16 @@ public: // create test log TimeSeriesProperty<int> log("test log"); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"), - 1); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30"), - 2); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:00"), - 3); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:30"), - 4); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:19:00"), - 5); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:19:30"), - 6); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:20:00"), - 7); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:20:30"), - 8); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:21:00"), - 9); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:21:30"), - 10); + log.addValue(DateAndTime("2007-11-30T16:17:00"), 1); + log.addValue(DateAndTime("2007-11-30T16:17:30"), 2); + log.addValue(DateAndTime("2007-11-30T16:18:00"), 3); + log.addValue(DateAndTime("2007-11-30T16:18:30"), 4); + log.addValue(DateAndTime("2007-11-30T16:19:00"), 5); + log.addValue(DateAndTime("2007-11-30T16:19:30"), 6); + log.addValue(DateAndTime("2007-11-30T16:20:00"), 7); + log.addValue(DateAndTime("2007-11-30T16:20:30"), 8); + log.addValue(DateAndTime("2007-11-30T16:21:00"), 9); + log.addValue(DateAndTime("2007-11-30T16:21:30"), 10); // Initialze the 4 splitters std::vector<TimeSeriesProperty<int> *> outputs; @@ -989,30 +904,19 @@ public: void test_splitByTimeVectorFastLogSplitter() { // create test log TimeSeriesProperty<int> log("test log"); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"), - 1); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30"), - 2); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:00"), - 3); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:30"), - 4); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:19:00"), - 5); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:19:30"), - 6); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:20:00"), - 7); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:20:30"), - 8); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:21:00"), - 9); - log.addValue(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:21:30"), - 10); + log.addValue(DateAndTime("2007-11-30T16:17:00"), 1); + log.addValue(DateAndTime("2007-11-30T16:17:30"), 2); + log.addValue(DateAndTime("2007-11-30T16:18:00"), 3); + log.addValue(DateAndTime("2007-11-30T16:18:30"), 4); + log.addValue(DateAndTime("2007-11-30T16:19:00"), 5); + log.addValue(DateAndTime("2007-11-30T16:19:30"), 6); + log.addValue(DateAndTime("2007-11-30T16:20:00"), 7); + log.addValue(DateAndTime("2007-11-30T16:20:30"), 8); + log.addValue(DateAndTime("2007-11-30T16:21:00"), 9); + log.addValue(DateAndTime("2007-11-30T16:21:30"), 10); // create a high frequency splitter - auto split_time = - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); + DateAndTime split_time("2007-11-30T16:17:00"); int64_t dt = 100 * 1000; std::vector<DateAndTime> vec_split_times; @@ -1164,23 +1068,23 @@ public: void test_getSingleValue() { TimeSeriesProperty<double> *p = createDoubleTSP(); - auto time1 = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:23"); + DateAndTime time1("2007-11-30T16:17:23"); double v1 = p->getSingleValue(time1); TS_ASSERT_DELTA(v1, 5.55, 1e-6); - auto time2 = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:03"); + DateAndTime time2("2007-11-30T16:17:03"); double v2 = p->getSingleValue(time2); TS_ASSERT_DELTA(v2, 9.99, 1e-6); - auto time3 = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:31"); + DateAndTime time3("2007-11-30T16:17:31"); double v3 = p->getSingleValue(time3); TS_ASSERT_DELTA(v3, 10.55, 1e-6); - auto time4 = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); + DateAndTime time4("2007-11-30T16:17:00"); double v4 = p->getSingleValue(time4); TS_ASSERT_DELTA(v4, 9.99, 1e-6); - auto time5 = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:16:59"); + DateAndTime time5("2007-11-30T16:16:59"); double v5 = p->getSingleValue(time5); TS_ASSERT_DELTA(v5, 9.99, 1e-6); @@ -1190,7 +1094,7 @@ public: void test_getSingleValue_emptyPropertyThrows() { const TimeSeriesProperty<int> empty("Empty"); - auto time = DateAndTimeHelpers::createFromISO8601("2013-01-30T16:17:23"); + DateAndTime time("2013-01-30T16:17:23"); TS_ASSERT_THROWS(empty.getSingleValue(time), std::runtime_error); int i; TS_ASSERT_THROWS(empty.getSingleValue(time, i), std::runtime_error); @@ -1199,11 +1103,11 @@ public: void test_firstLastTimeValue() { TimeSeriesProperty<double> *p = createDoubleTSP(); - auto t0 = p->firstTime(); - auto tf = p->lastTime(); + Mantid::Types::Core::DateAndTime t0 = p->firstTime(); + Mantid::Types::Core::DateAndTime tf = p->lastTime(); - auto t0c = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); - auto tfc = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30"); + Mantid::Types::Core::DateAndTime t0c("2007-11-30T16:17:00"); + Mantid::Types::Core::DateAndTime tfc("2007-11-30T16:17:30"); double v0 = p->firstValue(); double vf = p->lastValue(); @@ -1267,9 +1171,9 @@ public: p1->merge(p2); // 3. Verify - auto t0 = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); - auto tf = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:35"); - auto t1 = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:05"); + Mantid::Types::Core::DateAndTime t0("2007-11-30T16:17:00"); + Mantid::Types::Core::DateAndTime tf("2007-11-30T16:17:35"); + Mantid::Types::Core::DateAndTime t1("2007-11-30T16:17:05"); TS_ASSERT_EQUALS(p1->firstTime(), t0); TS_ASSERT_EQUALS(p1->lastTime(), tf); @@ -1359,10 +1263,10 @@ public: dynamic_cast<TimeSeriesProperty<double> *>(p->clone()); // 3. Check - std::vector<Mantid::Types::DateAndTime> times1 = p->timesAsVector(); + std::vector<Mantid::Types::Core::DateAndTime> times1 = p->timesAsVector(); std::vector<double> values1 = p->valuesAsVector(); - std::vector<Mantid::Types::DateAndTime> times2 = newp->timesAsVector(); + std::vector<Mantid::Types::Core::DateAndTime> times2 = newp->timesAsVector(); std::vector<double> values2 = newp->valuesAsVector(); TS_ASSERT_EQUALS(times1, times2); @@ -1453,7 +1357,7 @@ public: TS_ASSERT_EQUALS(p->realSize(), 1); TS_ASSERT_EQUALS(p->lastValue(), 99); - auto t = DateAndTimeHelpers::createFromISO8601("2007-11-30T15:17:00"); + DateAndTime t("2007-11-30T15:17:00"); p->addValue(t, 88); TS_ASSERT_EQUALS(p->size(), 2); @@ -1485,15 +1389,11 @@ public: TS_ASSERT_THROWS_NOTHING(p->addValue("2007-11-30T16:17:30", 4.00)); // 2. Create method 1 - std::vector<Mantid::Types::DateAndTime> times; - times.push_back(Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:00")); - times.push_back(Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:20")); - times.push_back(Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:10")); - times.push_back(Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:30")); + std::vector<Mantid::Types::Core::DateAndTime> times; + times.push_back(Mantid::Types::Core::DateAndTime("2007-11-30T16:17:00")); + times.push_back(Mantid::Types::Core::DateAndTime("2007-11-30T16:17:20")); + times.push_back(Mantid::Types::Core::DateAndTime("2007-11-30T16:17:10")); + times.push_back(Mantid::Types::Core::DateAndTime("2007-11-30T16:17:30")); std::vector<double> values; values.push_back(1.00); values.push_back(3.00); @@ -1506,8 +1406,8 @@ public: TS_ASSERT_EQUALS(p->size(), p1->size()); if (p->size() == p1->size()) { - std::vector<Mantid::Types::DateAndTime> times0 = p->timesAsVector(); - std::vector<Mantid::Types::DateAndTime> times1 = p1->timesAsVector(); + std::vector<Mantid::Types::Core::DateAndTime> times0 = p->timesAsVector(); + std::vector<Mantid::Types::Core::DateAndTime> times1 = p1->timesAsVector(); for (size_t i = 0; i < static_cast<size_t>(p->size()); i++) { TS_ASSERT_EQUALS(times0[i], times1[i]); TS_ASSERT_DELTA(p->getSingleValue(times0[i]), @@ -1516,7 +1416,7 @@ public: } // 3 Create method 2 - auto tStart = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); + Mantid::Types::Core::DateAndTime tStart("2007-11-30T16:17:00"); std::vector<double> deltaTs; std::vector<double> valueXs; @@ -1531,8 +1431,8 @@ public: TS_ASSERT_EQUALS(p->size(), p2->size()); if (p->size() == p2->size()) { - std::vector<Mantid::Types::DateAndTime> times0 = p->timesAsVector(); - std::vector<Mantid::Types::DateAndTime> times1 = p2->timesAsVector(); + std::vector<Mantid::Types::Core::DateAndTime> times0 = p->timesAsVector(); + std::vector<Mantid::Types::Core::DateAndTime> times1 = p2->timesAsVector(); for (size_t i = 0; i < static_cast<size_t>(p->size()); i++) { TS_ASSERT_EQUALS(times0[i], times1[i]); TS_ASSERT_DELTA(p->getSingleValue(times0[i]), @@ -1594,25 +1494,21 @@ public: TS_ASSERT_THROWS_NOTHING(p->addValue("2007-11-30T16:17:30", 4.00)); // 2. Get map - std::map<Mantid::Types::DateAndTime, double> tmap = p->valueAsCorrectMap(); + std::map<Mantid::Types::Core::DateAndTime, double> tmap = p->valueAsCorrectMap(); // 3. Check - std::vector<Mantid::Types::DateAndTime> times; - times.push_back(Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:00")); - times.push_back(Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:10")); - times.push_back(Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:20")); - times.push_back(Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:30")); + std::vector<Mantid::Types::Core::DateAndTime> times; + times.push_back(Mantid::Types::Core::DateAndTime("2007-11-30T16:17:00")); + times.push_back(Mantid::Types::Core::DateAndTime("2007-11-30T16:17:10")); + times.push_back(Mantid::Types::Core::DateAndTime("2007-11-30T16:17:20")); + times.push_back(Mantid::Types::Core::DateAndTime("2007-11-30T16:17:30")); std::vector<double> values; values.push_back(1.00); values.push_back(2.00); values.push_back(3.00); values.push_back(4.00); - std::map<Mantid::Types::DateAndTime, double>::iterator tit; + std::map<Mantid::Types::Core::DateAndTime, double>::iterator tit; size_t index = 0; for (tit = tmap.begin(); tit != tmap.end(); ++tit) { TS_ASSERT_EQUALS(tit->first, times[index]); @@ -1637,21 +1533,16 @@ public: TS_ASSERT_THROWS_NOTHING(p->addValue("2007-11-30T16:17:30", 4.00)); // 2. Get multimap - std::multimap<Mantid::Types::DateAndTime, double> tmap = + std::multimap<Mantid::Types::Core::DateAndTime, double> tmap = p->valueAsMultiMap(); // 3. Check - std::vector<Mantid::Types::DateAndTime> times; - times.push_back(Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:00")); - times.push_back(Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:10")); - times.push_back(Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:10")); - times.push_back(Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:20")); - times.push_back(Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:30")); + std::vector<Mantid::Types::Core::DateAndTime> times; + times.push_back(Mantid::Types::Core::DateAndTime("2007-11-30T16:17:00")); + times.push_back(Mantid::Types::Core::DateAndTime("2007-11-30T16:17:10")); + times.push_back(Mantid::Types::Core::DateAndTime("2007-11-30T16:17:10")); + times.push_back(Mantid::Types::Core::DateAndTime("2007-11-30T16:17:20")); + times.push_back(Mantid::Types::Core::DateAndTime("2007-11-30T16:17:30")); std::vector<double> values; values.push_back(1.00); values.push_back(1.99); @@ -1685,25 +1576,21 @@ public: TS_ASSERT_THROWS_NOTHING(p->addValue("2007-11-30T16:17:30", 4.00)); // 2. Get map - std::map<Mantid::Types::DateAndTime, double> tmap = p->valueAsMap(); + std::map<Mantid::Types::Core::DateAndTime, double> tmap = p->valueAsMap(); // 3. Check - std::vector<Mantid::Types::DateAndTime> times; - times.push_back(Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:00")); - times.push_back(Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:10")); - times.push_back(Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:15")); - times.push_back(Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:30")); + std::vector<Mantid::Types::Core::DateAndTime> times; + times.push_back(Mantid::Types::Core::DateAndTime("2007-11-30T16:17:00")); + times.push_back(Mantid::Types::Core::DateAndTime("2007-11-30T16:17:10")); + times.push_back(Mantid::Types::Core::DateAndTime("2007-11-30T16:17:15")); + times.push_back(Mantid::Types::Core::DateAndTime("2007-11-30T16:17:30")); std::vector<double> values; values.push_back(1.00); values.push_back(2.00); values.push_back(3.00); values.push_back(4.00); - std::map<Mantid::Types::DateAndTime, double>::iterator tit; + std::map<Mantid::Types::Core::DateAndTime, double>::iterator tit; size_t index = 0; for (tit = tmap.begin(); tit != tmap.end(); ++tit) { TS_ASSERT_EQUALS(tit->first, times[index]); @@ -1732,28 +1619,24 @@ public: TS_ASSERT_THROWS_NOTHING(p->addValue("2007-11-30T16:17:30", 4.00)); // 2. Get map - std::map<Mantid::Types::DateAndTime, double> tmap = p->valueAsMap(); + std::map<Mantid::Types::Core::DateAndTime, double> tmap = p->valueAsMap(); // 3. Check TS_ASSERT_EQUALS(tmap.size(), 4); if (tmap.size() == 4) { - std::vector<Mantid::Types::DateAndTime> times; - times.push_back(Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:00")); - times.push_back(Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:10")); - times.push_back(Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:20")); - times.push_back(Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:30")); + std::vector<Mantid::Types::Core::DateAndTime> times; + times.push_back(Mantid::Types::Core::DateAndTime("2007-11-30T16:17:00")); + times.push_back(Mantid::Types::Core::DateAndTime("2007-11-30T16:17:10")); + times.push_back(Mantid::Types::Core::DateAndTime("2007-11-30T16:17:20")); + times.push_back(Mantid::Types::Core::DateAndTime("2007-11-30T16:17:30")); std::vector<double> values; values.push_back(1.00); values.push_back(2.00); values.push_back(3.00); values.push_back(4.00); - std::map<Mantid::Types::DateAndTime, double>::iterator tit; + std::map<Mantid::Types::Core::DateAndTime, double>::iterator tit; size_t index = 0; for (tit = tmap.begin(); tit != tmap.end(); ++tit) { TS_ASSERT_EQUALS(tit->first, times[index]); @@ -1785,20 +1668,20 @@ public: TS_ASSERT_THROWS_NOTHING(p->addValue("2007-11-30T16:17:30", 4.00)); // 3. Test with term - auto t0 = p->nthTime(0); - auto t0c = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); + Mantid::Types::Core::DateAndTime t0 = p->nthTime(0); + Mantid::Types::Core::DateAndTime t0c("2007-11-30T16:17:00"); TS_ASSERT_EQUALS(t0, t0c); - auto t2 = p->nthTime(2); - auto t2c = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:20"); + Mantid::Types::Core::DateAndTime t2 = p->nthTime(2); + Mantid::Types::Core::DateAndTime t2c("2007-11-30T16:17:20"); TS_ASSERT_EQUALS(t2, t2c); - auto t3 = p->nthTime(3); - auto t3c = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30"); + Mantid::Types::Core::DateAndTime t3 = p->nthTime(3); + Mantid::Types::Core::DateAndTime t3c("2007-11-30T16:17:30"); TS_ASSERT_EQUALS(t3, t3c); - auto t100 = p->nthTime(100); - auto t100c = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30"); + Mantid::Types::Core::DateAndTime t100 = p->nthTime(100); + Mantid::Types::Core::DateAndTime t100c("2007-11-30T16:17:30"); TS_ASSERT_EQUALS(t100, t100c); // 4. Double time @@ -1832,27 +1715,21 @@ public: // 3. Test Mantid::Kernel::TimeInterval dt0 = p->nthInterval(0); TS_ASSERT_EQUALS(dt0.begin(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:00")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:17:00")); TS_ASSERT_EQUALS(dt0.end(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:05")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:17:05")); Mantid::Kernel::TimeInterval dt1 = p->nthInterval(1); TS_ASSERT_EQUALS(dt1.begin(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:05")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:17:05")); TS_ASSERT_EQUALS(dt1.end(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:15")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:17:15")); Mantid::Kernel::TimeInterval dt2 = p->nthInterval(2); TS_ASSERT_EQUALS(dt2.begin(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:15")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:17:15")); TS_ASSERT_EQUALS(dt2.end(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:35")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:17:35")); // -1 Clean delete p; @@ -1865,7 +1742,7 @@ public: */ void test_filter() { // 1. Create a base property - auto tStart = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); + Mantid::Types::Core::DateAndTime tStart("2007-11-30T16:17:00"); std::vector<double> deltaTs; std::vector<double> valueXs; for (int i = 0; i < 20; i++) { @@ -1876,7 +1753,7 @@ public: new TimeSeriesProperty<double>("BaseProperty"); p1->create(tStart, deltaTs, valueXs); - std::vector<Mantid::Types::DateAndTime> times = p1->timesAsVector(); + std::vector<Mantid::Types::Core::DateAndTime> times = p1->timesAsVector(); std::vector<double> values = p1->valuesAsVector(); // b) Copy size and interval information in order to verify clearFilter() @@ -1902,19 +1779,15 @@ public: Mantid::Kernel::TimeInterval dt1 = p1->nthInterval(1); TS_ASSERT_EQUALS(dt1.begin(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:10")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:17:10")); TS_ASSERT_EQUALS(dt1.end(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:16")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:17:16")); Mantid::Kernel::TimeInterval dt2 = p1->nthInterval(2); TS_ASSERT_EQUALS(dt2.begin(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:18:40")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:18:40")); TS_ASSERT_EQUALS(dt2.end(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:18:50")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:18:50")); // 4. Clear filter p1->clearFilter(); @@ -1965,7 +1838,7 @@ public: */ void test_filterBoundary1() { // 1. Create a base property - auto tStart = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); + Mantid::Types::Core::DateAndTime tStart("2007-11-30T16:17:00"); std::vector<double> deltaTs; std::vector<double> valueXs; for (int i = 0; i < 20; i++) { @@ -1976,7 +1849,7 @@ public: new TimeSeriesProperty<double>("BaseProperty"); p1->create(tStart, deltaTs, valueXs); - std::vector<Mantid::Types::DateAndTime> times = p1->timesAsVector(); + std::vector<Mantid::Types::Core::DateAndTime> times = p1->timesAsVector(); std::vector<double> values = p1->valuesAsVector(); // 2. Create a filter for T. F. T. F... @@ -1995,41 +1868,33 @@ public: // 4. Check interval & Value Mantid::Kernel::TimeInterval dt0 = p1->nthInterval(0); TS_ASSERT_EQUALS(dt0.begin(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:00")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:17:00")); TS_ASSERT_EQUALS(dt0.end(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:10")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:17:10")); double v0 = p1->nthValue(0); TS_ASSERT_DELTA(v0, 1, 0.00000001); Mantid::Kernel::TimeInterval dt1 = p1->nthInterval(1); TS_ASSERT_EQUALS(dt1.begin(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:10")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:17:10")); TS_ASSERT_EQUALS(dt1.end(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:16")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:17:16")); double v1 = p1->nthValue(1); TS_ASSERT_DELTA(v1, 2, 0.00000001); Mantid::Kernel::TimeInterval dt2 = p1->nthInterval(2); TS_ASSERT_EQUALS(dt2.begin(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:18:40")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:18:40")); TS_ASSERT_EQUALS(dt2.end(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:18:50")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:18:50")); double v2 = p1->nthValue(2); TS_ASSERT_DELTA(v2, 11, 0.00000001); Mantid::Kernel::TimeInterval dt12 = p1->nthInterval(11); TS_ASSERT_EQUALS(dt12.begin(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:20:10")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:20:10")); TS_ASSERT_EQUALS(dt12.end(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T17:19:30")); + Mantid::Types::Core::DateAndTime("2007-11-30T17:19:30")); double v12 = p1->nthValue(11); TS_ASSERT_DELTA(v12, 20, 1.0E-8); @@ -2044,12 +1909,12 @@ public: } /* - * Test filterWith() on different boundary conditions - * Filter_T0 < Log_T0 < LogTf < Filter_Tf, F... T... F... T... F... - */ + * Test filterWith() on different boundary conditions + * Filter_T0 < Log_T0 < LogTf < Filter_Tf, F... T... F... T... F... + */ void test_filterBoundary2() { // 1. Create a base property - auto tStart = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); + Mantid::Types::Core::DateAndTime tStart("2007-11-30T16:17:00"); std::vector<double> deltaTs; std::vector<double> valueXs; for (int i = 0; i < 20; i++) { @@ -2060,7 +1925,7 @@ public: new TimeSeriesProperty<double>("BaseProperty"); p1->create(tStart, deltaTs, valueXs); - std::vector<Mantid::Types::DateAndTime> times = p1->timesAsVector(); + std::vector<Mantid::Types::Core::DateAndTime> times = p1->timesAsVector(); std::vector<double> values = p1->valuesAsVector(); // 2. Create a filter for T. F. T. F... @@ -2079,11 +1944,9 @@ public: // 4. Check interval Mantid::Kernel::TimeInterval dt0 = p1->nthInterval(0); TS_ASSERT_EQUALS(dt0.begin(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:16")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:17:16")); TS_ASSERT_EQUALS(dt0.end(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:20")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:17:20")); double v0 = p1->nthValue(0); TS_ASSERT_DELTA(v0, 2, 1.0E-8); @@ -2098,12 +1961,12 @@ public: } /* - * Test filterWith() on different boundary conditions - * Log_T0 < Filter_T0 < < Filter_Tf LogTf, T... F... T... F... - */ + * Test filterWith() on different boundary conditions + * Log_T0 < Filter_T0 < < Filter_Tf LogTf, T... F... T... F... + */ void test_filterBoundary3() { // 1. Create a base property - auto tStart = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); + Mantid::Types::Core::DateAndTime tStart("2007-11-30T16:17:00"); std::vector<double> deltaTs; std::vector<double> valueXs; for (int i = 0; i < 20; i++) { @@ -2114,7 +1977,7 @@ public: new TimeSeriesProperty<double>("BaseProperty"); p1->create(tStart, deltaTs, valueXs); - std::vector<Mantid::Types::DateAndTime> times = p1->timesAsVector(); + std::vector<Mantid::Types::Core::DateAndTime> times = p1->timesAsVector(); std::vector<double> values = p1->valuesAsVector(); // 2. Create a filter for T. F. T. F... @@ -2133,21 +1996,17 @@ public: // 4. Check interval Mantid::Kernel::TimeInterval dt1 = p1->nthInterval(1); TS_ASSERT_EQUALS(dt1.begin(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:10")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:17:10")); TS_ASSERT_EQUALS(dt1.end(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:16")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:17:16")); double v1 = p1->nthValue(1); TS_ASSERT_DELTA(v1, 2, 1.0E-8); Mantid::Kernel::TimeInterval dt2 = p1->nthInterval(2); TS_ASSERT_EQUALS(dt2.begin(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:18:40")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:18:40")); TS_ASSERT_EQUALS(dt2.end(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:18:50")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:18:50")); double v2 = p1->nthValue(2); TS_ASSERT_DELTA(v2, 11, 1.0E-8); @@ -2164,11 +2023,11 @@ public: /* * Test filterWith() on different boundary conditions * Log_T0 < Filter_T0 < < Filter_Tf LogTf, F... T... F... T... F... - */ + */ void test_filterBoundary4() { // 1. Create a base property - auto tStart = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); + Mantid::Types::Core::DateAndTime tStart("2007-11-30T16:17:00"); std::vector<double> deltaTs; std::vector<double> valueXs; for (int i = 0; i < 20; i++) { @@ -2179,7 +2038,7 @@ public: new TimeSeriesProperty<double>("BaseProperty"); p1->create(tStart, deltaTs, valueXs); - std::vector<Mantid::Types::DateAndTime> times = p1->timesAsVector(); + std::vector<Mantid::Types::Core::DateAndTime> times = p1->timesAsVector(); std::vector<double> values = p1->valuesAsVector(); // 2. Create a filter for T. F. T. F... @@ -2198,11 +2057,9 @@ public: // 4. Check interval Mantid::Kernel::TimeInterval dt0 = p1->nthInterval(0); TS_ASSERT_EQUALS(dt0.begin(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:16")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:17:16")); TS_ASSERT_EQUALS(dt0.end(), - Mantid::Types::DateAndTimeHelpers::createFromISO8601( - "2007-11-30T16:17:20")); + Mantid::Types::Core::DateAndTime("2007-11-30T16:17:20")); double v0 = p1->nthValue(0); TS_ASSERT_DELTA(v0, 2, 1.0E-8); @@ -2340,7 +2197,7 @@ public: //---------------------------------------------------------------------------- /** A test for filter nothing - */ + */ void test_filterByTime_out_of_range_filters_nothing() { TimeSeriesProperty<int> *log = createIntegerTSP(6); @@ -2348,9 +2205,9 @@ public: TS_ASSERT_EQUALS(original_size, 6); - auto start = DateAndTimeHelpers::createFromISO8601( + DateAndTime start = DateAndTime( "2007-11-30T15:00:00"); // Much earlier than first time series value - auto stop = DateAndTimeHelpers::createFromISO8601( + DateAndTime stop = DateAndTime( "2007-11-30T17:00:00"); // Much later than last time series value log->filterByTime(start, stop); @@ -2406,14 +2263,9 @@ public: // Add the filter auto filter = Mantid::Kernel::make_unique<TimeSeriesProperty<bool>>("Filter"); - Mantid::Types::DateAndTime - firstStart = - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"), - firstEnd = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:15"), - secondStart = - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:35"), - secondEnd = - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:40"); + Mantid::Types::Core::DateAndTime firstStart("2007-11-30T16:17:00"), + firstEnd("2007-11-30T16:17:15"), secondStart("2007-11-30T16:18:35"), + secondEnd("2007-11-30T16:18:40"); filter->addValue(firstStart.toISO8601String(), true); filter->addValue(firstEnd.toISO8601String(), false); filter->addValue("2007-11-30T16:17:25", false); @@ -2438,14 +2290,9 @@ public: // Add the filter auto filter = Mantid::Kernel::make_unique<TimeSeriesProperty<bool>>("Filter"); - Mantid::Types::DateAndTime - firstEnd = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:05"), - secondStart = - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10"), - secondEnd = - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:15"), - thirdStart = - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:35"); + Mantid::Types::Core::DateAndTime firstEnd("2007-11-30T16:17:05"), + secondStart("2007-11-30T16:17:10"), secondEnd("2007-11-30T16:17:15"), + thirdStart("2007-11-30T16:18:35"); filter->addValue(log->firstTime(), true); filter->addValue(firstEnd.toISO8601String(), false); filter->addValue(secondStart.toISO8601String(), true); @@ -2470,7 +2317,7 @@ private: // Build the log auto log = Mantid::Kernel::make_unique<TimeSeriesProperty<double>>("DoubleLog"); - auto logTime = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); + Mantid::Types::Core::DateAndTime logTime("2007-11-30T16:17:00"); const double incrementSecs(10.0); for (int i = 1; i < 12; ++i) { const double val = static_cast<double>(i); diff --git a/Framework/Kernel/test/TimeSplitterTest.h b/Framework/Kernel/test/TimeSplitterTest.h index e9635809262..4f7eb2a9044 100644 --- a/Framework/Kernel/test/TimeSplitterTest.h +++ b/Framework/Kernel/test/TimeSplitterTest.h @@ -11,10 +11,10 @@ #include <cxxtest/TestSuite.h> #include <ctime> #include "MantidKernel/TimeSplitter.h" -#include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidKernel/DateAndTime.h" using namespace Mantid::Kernel; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; class TimeSplitterTest : public CxxTest::TestSuite { public: @@ -25,14 +25,14 @@ public: void test_SplittingInterval_AND() { DateAndTime start_a, stop_a, start_b, stop_b; - start_a = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10"); - stop_a = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:20"); + start_a = DateAndTime("2007-11-30T16:17:10"); + stop_a = DateAndTime("2007-11-30T16:17:20"); SplittingInterval a(start_a, stop_a, 0); SplittingInterval b, c; // b is all inside a - start_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:12"); - stop_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:18"); + start_b = DateAndTime("2007-11-30T16:17:12"); + stop_b = DateAndTime("2007-11-30T16:17:18"); b = SplittingInterval(start_b, stop_b, 0); c = a & b; TS_ASSERT(a.overlaps(b)); @@ -40,8 +40,8 @@ public: TS_ASSERT_EQUALS(c.stop(), stop_b); // a is all inside b - start_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:05"); - stop_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:23"); + start_b = DateAndTime("2007-11-30T16:17:05"); + stop_b = DateAndTime("2007-11-30T16:17:23"); b = SplittingInterval(start_b, stop_b, 0); c = a & b; TS_ASSERT(a.overlaps(b)); @@ -49,8 +49,8 @@ public: TS_ASSERT_EQUALS(c.stop(), stop_a); // b goes past the end of a - start_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:12"); - stop_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:25"); + start_b = DateAndTime("2007-11-30T16:17:12"); + stop_b = DateAndTime("2007-11-30T16:17:25"); b = SplittingInterval(start_b, stop_b, 0); c = a & b; TS_ASSERT(a.overlaps(b)); @@ -58,8 +58,8 @@ public: TS_ASSERT_EQUALS(c.stop(), stop_a); // b starts before a and ends before - start_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:05"); - stop_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:15"); + start_b = DateAndTime("2007-11-30T16:17:05"); + stop_b = DateAndTime("2007-11-30T16:17:15"); b = SplittingInterval(start_b, stop_b, 0); c = a & b; TS_ASSERT(a.overlaps(b)); @@ -67,16 +67,16 @@ public: TS_ASSERT_EQUALS(c.stop(), stop_b); // No overlap (b < a) - start_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:01"); - stop_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:02"); + start_b = DateAndTime("2007-11-30T16:17:01"); + stop_b = DateAndTime("2007-11-30T16:17:02"); b = SplittingInterval(start_b, stop_b, 0); c = a & b; TS_ASSERT(!a.overlaps(b)); TS_ASSERT_LESS_THAN_EQUALS(c.duration(), 0.0); // No overlap (a < b) - start_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30"); - stop_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:42"); + start_b = DateAndTime("2007-11-30T16:17:30"); + stop_b = DateAndTime("2007-11-30T16:17:42"); b = SplittingInterval(start_b, stop_b, 0); c = a & b; TS_ASSERT(!a.overlaps(b)); @@ -90,14 +90,14 @@ public: void test_SplittingInterval_OR() { DateAndTime start_a, stop_a, start_b, stop_b; - start_a = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10"); - stop_a = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:20"); + start_a = DateAndTime("2007-11-30T16:17:10"); + stop_a = DateAndTime("2007-11-30T16:17:20"); SplittingInterval a(start_a, stop_a, 0); SplittingInterval b, c; // b is all inside a - start_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:12"); - stop_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:18"); + start_b = DateAndTime("2007-11-30T16:17:12"); + stop_b = DateAndTime("2007-11-30T16:17:18"); b = SplittingInterval(start_b, stop_b, 0); c = a | b; TS_ASSERT(a.overlaps(b)); @@ -105,8 +105,8 @@ public: TS_ASSERT_EQUALS(c.stop(), stop_a); // a is all inside b - start_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:05"); - stop_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:23"); + start_b = DateAndTime("2007-11-30T16:17:05"); + stop_b = DateAndTime("2007-11-30T16:17:23"); b = SplittingInterval(start_b, stop_b, 0); c = a | b; TS_ASSERT(a.overlaps(b)); @@ -114,8 +114,8 @@ public: TS_ASSERT_EQUALS(c.stop(), stop_b); // b goes past the end of a - start_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:12"); - stop_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:25"); + start_b = DateAndTime("2007-11-30T16:17:12"); + stop_b = DateAndTime("2007-11-30T16:17:25"); b = SplittingInterval(start_b, stop_b, 0); c = a | b; TS_ASSERT(a.overlaps(b)); @@ -123,8 +123,8 @@ public: TS_ASSERT_EQUALS(c.stop(), stop_b); // b starts before a and ends before - start_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:05"); - stop_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:15"); + start_b = DateAndTime("2007-11-30T16:17:05"); + stop_b = DateAndTime("2007-11-30T16:17:15"); b = SplittingInterval(start_b, stop_b, 0); c = a | b; TS_ASSERT(a.overlaps(b)); @@ -133,15 +133,15 @@ public: // No overlap (b < a) - This throws an exception because you need two // outputs! - start_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:01"); - stop_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:02"); + start_b = DateAndTime("2007-11-30T16:17:01"); + stop_b = DateAndTime("2007-11-30T16:17:02"); b = SplittingInterval(start_b, stop_b, 0); TS_ASSERT(!a.overlaps(b)); TS_ASSERT_THROWS(c = a | b;, std::invalid_argument); // No overlap (a < b) - start_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30"); - stop_b = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:42"); + start_b = DateAndTime("2007-11-30T16:17:30"); + stop_b = DateAndTime("2007-11-30T16:17:42"); b = SplittingInterval(start_b, stop_b, 0); TS_ASSERT(!a.overlaps(b)); TS_ASSERT_THROWS(c = a | b;, std::invalid_argument); @@ -152,37 +152,37 @@ public: // Make a splitter DateAndTime start, stop; TimeSplitterType a, b; - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10"); + start = DateAndTime("2007-11-30T16:17:00"); + stop = DateAndTime("2007-11-30T16:17:10"); a.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:20"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30"); + start = DateAndTime("2007-11-30T16:17:20"); + stop = DateAndTime("2007-11-30T16:17:30"); a.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:40"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:50"); + start = DateAndTime("2007-11-30T16:17:40"); + stop = DateAndTime("2007-11-30T16:17:50"); a.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:00"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:10"); + start = DateAndTime("2007-11-30T16:18:00"); + stop = DateAndTime("2007-11-30T16:18:10"); a.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:20"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:30"); + start = DateAndTime("2007-11-30T16:18:20"); + stop = DateAndTime("2007-11-30T16:18:30"); a.push_back(SplittingInterval(start, stop, 0)); // Smaller than the first one - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:01"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:25"); + start = DateAndTime("2007-11-30T16:17:01"); + stop = DateAndTime("2007-11-30T16:17:25"); b.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:26"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:27"); + start = DateAndTime("2007-11-30T16:17:26"); + stop = DateAndTime("2007-11-30T16:17:27"); b.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:45"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:15"); + start = DateAndTime("2007-11-30T16:17:45"); + stop = DateAndTime("2007-11-30T16:18:15"); b.push_back(SplittingInterval(start, stop, 0)); // Now AND the splitters (filters) together @@ -195,20 +195,20 @@ public: SplittingInterval i; i = c[0]; - TS_ASSERT_EQUALS(i.start(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:01")); - TS_ASSERT_EQUALS(i.stop(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10")); + TS_ASSERT_EQUALS(i.start(), DateAndTime("2007-11-30T16:17:01")); + TS_ASSERT_EQUALS(i.stop(), DateAndTime("2007-11-30T16:17:10")); i = c[1]; - TS_ASSERT_EQUALS(i.start(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:20")); - TS_ASSERT_EQUALS(i.stop(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:25")); + TS_ASSERT_EQUALS(i.start(), DateAndTime("2007-11-30T16:17:20")); + TS_ASSERT_EQUALS(i.stop(), DateAndTime("2007-11-30T16:17:25")); i = c[2]; - TS_ASSERT_EQUALS(i.start(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:26")); - TS_ASSERT_EQUALS(i.stop(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:27")); + TS_ASSERT_EQUALS(i.start(), DateAndTime("2007-11-30T16:17:26")); + TS_ASSERT_EQUALS(i.stop(), DateAndTime("2007-11-30T16:17:27")); i = c[3]; - TS_ASSERT_EQUALS(i.start(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:45")); - TS_ASSERT_EQUALS(i.stop(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:50")); + TS_ASSERT_EQUALS(i.start(), DateAndTime("2007-11-30T16:17:45")); + TS_ASSERT_EQUALS(i.stop(), DateAndTime("2007-11-30T16:17:50")); i = c[4]; - TS_ASSERT_EQUALS(i.start(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:00")); - TS_ASSERT_EQUALS(i.stop(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:10")); + TS_ASSERT_EQUALS(i.start(), DateAndTime("2007-11-30T16:18:00")); + TS_ASSERT_EQUALS(i.stop(), DateAndTime("2007-11-30T16:18:10")); } //---------------------------------------------------------------------------- @@ -216,41 +216,41 @@ public: // Make a splitter DateAndTime start, stop; TimeSplitterType a, b; - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10"); + start = DateAndTime("2007-11-30T16:17:00"); + stop = DateAndTime("2007-11-30T16:17:10"); a.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:20"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30"); + start = DateAndTime("2007-11-30T16:17:20"); + stop = DateAndTime("2007-11-30T16:17:30"); a.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:40"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:50"); + start = DateAndTime("2007-11-30T16:17:40"); + stop = DateAndTime("2007-11-30T16:17:50"); a.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:00"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:10"); + start = DateAndTime("2007-11-30T16:18:00"); + stop = DateAndTime("2007-11-30T16:18:10"); a.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:20"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:30"); + start = DateAndTime("2007-11-30T16:18:20"); + stop = DateAndTime("2007-11-30T16:18:30"); a.push_back(SplittingInterval(start, stop, 0)); // Smaller than the first one - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:01"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:25"); + start = DateAndTime("2007-11-30T16:17:01"); + stop = DateAndTime("2007-11-30T16:17:25"); b.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:26"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:27"); + start = DateAndTime("2007-11-30T16:17:26"); + stop = DateAndTime("2007-11-30T16:17:27"); b.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:45"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:15"); + start = DateAndTime("2007-11-30T16:17:45"); + stop = DateAndTime("2007-11-30T16:18:15"); b.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:50"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:55"); + start = DateAndTime("2007-11-30T16:18:50"); + stop = DateAndTime("2007-11-30T16:18:55"); b.push_back(SplittingInterval(start, stop, 0)); // Now AND the splitters (filters) together @@ -263,17 +263,17 @@ public: SplittingInterval i; i = c[0]; - TS_ASSERT_EQUALS(i.start(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00")); - TS_ASSERT_EQUALS(i.stop(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30")); + TS_ASSERT_EQUALS(i.start(), DateAndTime("2007-11-30T16:17:00")); + TS_ASSERT_EQUALS(i.stop(), DateAndTime("2007-11-30T16:17:30")); i = c[1]; - TS_ASSERT_EQUALS(i.start(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:40")); - TS_ASSERT_EQUALS(i.stop(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:15")); + TS_ASSERT_EQUALS(i.start(), DateAndTime("2007-11-30T16:17:40")); + TS_ASSERT_EQUALS(i.stop(), DateAndTime("2007-11-30T16:18:15")); i = c[2]; - TS_ASSERT_EQUALS(i.start(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:20")); - TS_ASSERT_EQUALS(i.stop(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:30")); + TS_ASSERT_EQUALS(i.start(), DateAndTime("2007-11-30T16:18:20")); + TS_ASSERT_EQUALS(i.stop(), DateAndTime("2007-11-30T16:18:30")); i = c[3]; - TS_ASSERT_EQUALS(i.start(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:50")); - TS_ASSERT_EQUALS(i.stop(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:55")); + TS_ASSERT_EQUALS(i.start(), DateAndTime("2007-11-30T16:18:50")); + TS_ASSERT_EQUALS(i.stop(), DateAndTime("2007-11-30T16:18:55")); } //---------------------------------------------------------------------------- @@ -282,23 +282,23 @@ public: DateAndTime start, stop; TimeSplitterType a, b; - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:20"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30"); + start = DateAndTime("2007-11-30T16:17:20"); + stop = DateAndTime("2007-11-30T16:17:30"); a.push_back(SplittingInterval(start, stop, 0)); // A bad (reversed) interval - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:32"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:31"); + start = DateAndTime("2007-11-30T16:17:32"); + stop = DateAndTime("2007-11-30T16:17:31"); a.push_back(SplittingInterval(start, stop, 0)); // REVERSED interval that is before the first one - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:15"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); + start = DateAndTime("2007-11-30T16:17:15"); + stop = DateAndTime("2007-11-30T16:17:00"); b.push_back(SplittingInterval(start, stop, 0)); // Another bad interval - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:45"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:35"); + start = DateAndTime("2007-11-30T16:17:45"); + stop = DateAndTime("2007-11-30T16:17:35"); b.push_back(SplittingInterval(start, stop, 0)); // Now AND the splitters (filters) together @@ -311,8 +311,8 @@ public: SplittingInterval i; i = c[0]; - TS_ASSERT_EQUALS(i.start(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:20")); - TS_ASSERT_EQUALS(i.stop(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30")); + TS_ASSERT_EQUALS(i.start(), DateAndTime("2007-11-30T16:17:20")); + TS_ASSERT_EQUALS(i.stop(), DateAndTime("2007-11-30T16:17:30")); } //---------------------------------------------------------------------------- @@ -322,12 +322,12 @@ public: SplittingInterval i; //---- Normal Case ------ - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10"); + start = DateAndTime("2007-11-30T16:17:00"); + stop = DateAndTime("2007-11-30T16:17:10"); a.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:20"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30"); + start = DateAndTime("2007-11-30T16:17:20"); + stop = DateAndTime("2007-11-30T16:17:30"); a.push_back(SplittingInterval(start, stop, 0)); // Perform the NOT operation @@ -339,12 +339,12 @@ public: i = c[0]; TS_ASSERT_EQUALS(i.start(), DateAndTime::minimum()); - TS_ASSERT_EQUALS(i.stop(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00")); + TS_ASSERT_EQUALS(i.stop(), DateAndTime("2007-11-30T16:17:00")); i = c[1]; - TS_ASSERT_EQUALS(i.start(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10")); - TS_ASSERT_EQUALS(i.stop(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:20")); + TS_ASSERT_EQUALS(i.start(), DateAndTime("2007-11-30T16:17:10")); + TS_ASSERT_EQUALS(i.stop(), DateAndTime("2007-11-30T16:17:20")); i = c[2]; - TS_ASSERT_EQUALS(i.start(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30")); + TS_ASSERT_EQUALS(i.start(), DateAndTime("2007-11-30T16:17:30")); TS_ASSERT_EQUALS(i.stop(), DateAndTime::maximum()); } @@ -370,12 +370,12 @@ public: TimeSplitterType a, b, c; SplittingInterval i; // Overlapping case ------ - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:15"); + start = DateAndTime("2007-11-30T16:17:00"); + stop = DateAndTime("2007-11-30T16:17:15"); a.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30"); + start = DateAndTime("2007-11-30T16:17:10"); + stop = DateAndTime("2007-11-30T16:17:30"); a.push_back(SplittingInterval(start, stop, 0)); c = ~a; @@ -385,9 +385,9 @@ public: i = c[0]; TS_ASSERT_EQUALS(i.start(), DateAndTime::minimum()); - TS_ASSERT_EQUALS(i.stop(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00")); + TS_ASSERT_EQUALS(i.stop(), DateAndTime("2007-11-30T16:17:00")); i = c[1]; - TS_ASSERT_EQUALS(i.start(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30")); + TS_ASSERT_EQUALS(i.start(), DateAndTime("2007-11-30T16:17:30")); TS_ASSERT_EQUALS(i.stop(), DateAndTime::maximum()); } @@ -398,41 +398,41 @@ public: SplittingInterval i; // the splitter ------ - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:15:00"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:16:00"); + start = DateAndTime("2007-11-30T16:15:00"); + stop = DateAndTime("2007-11-30T16:16:00"); b.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:00"); + start = DateAndTime("2007-11-30T16:17:00"); + stop = DateAndTime("2007-11-30T16:18:00"); b.push_back(SplittingInterval(start, stop, 1)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:00"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:19:00"); + start = DateAndTime("2007-11-30T16:18:00"); + stop = DateAndTime("2007-11-30T16:19:00"); b.push_back(SplittingInterval(start, stop, 2)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:19:00"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:20:00"); + start = DateAndTime("2007-11-30T16:19:00"); + stop = DateAndTime("2007-11-30T16:20:00"); b.push_back(SplittingInterval(start, stop, 3)); // the filter ------ - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:16:50"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10"); + start = DateAndTime("2007-11-30T16:16:50"); + stop = DateAndTime("2007-11-30T16:17:10"); a.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:20"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30"); + start = DateAndTime("2007-11-30T16:17:20"); + stop = DateAndTime("2007-11-30T16:17:30"); a.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:40"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:10"); + start = DateAndTime("2007-11-30T16:17:40"); + stop = DateAndTime("2007-11-30T16:18:10"); a.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:50"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:55"); + start = DateAndTime("2007-11-30T16:18:50"); + stop = DateAndTime("2007-11-30T16:18:55"); a.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:22:20"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:22:30"); + start = DateAndTime("2007-11-30T16:22:20"); + stop = DateAndTime("2007-11-30T16:22:30"); a.push_back(SplittingInterval(start, stop, 0)); // Do the PLUS operation @@ -443,28 +443,28 @@ public: return; // avoid segfaults if this part of the test fails i = c[0]; - TS_ASSERT_EQUALS(i.start(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00")); - TS_ASSERT_EQUALS(i.stop(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10")); + TS_ASSERT_EQUALS(i.start(), DateAndTime("2007-11-30T16:17:00")); + TS_ASSERT_EQUALS(i.stop(), DateAndTime("2007-11-30T16:17:10")); TS_ASSERT_EQUALS(i.index(), 1); i = c[1]; - TS_ASSERT_EQUALS(i.start(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:20")); - TS_ASSERT_EQUALS(i.stop(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:30")); + TS_ASSERT_EQUALS(i.start(), DateAndTime("2007-11-30T16:17:20")); + TS_ASSERT_EQUALS(i.stop(), DateAndTime("2007-11-30T16:17:30")); TS_ASSERT_EQUALS(i.index(), 1); i = c[2]; - TS_ASSERT_EQUALS(i.start(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:40")); - TS_ASSERT_EQUALS(i.stop(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:00")); + TS_ASSERT_EQUALS(i.start(), DateAndTime("2007-11-30T16:17:40")); + TS_ASSERT_EQUALS(i.stop(), DateAndTime("2007-11-30T16:18:00")); TS_ASSERT_EQUALS(i.index(), 1); i = c[3]; - TS_ASSERT_EQUALS(i.start(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:00")); - TS_ASSERT_EQUALS(i.stop(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:10")); + TS_ASSERT_EQUALS(i.start(), DateAndTime("2007-11-30T16:18:00")); + TS_ASSERT_EQUALS(i.stop(), DateAndTime("2007-11-30T16:18:10")); TS_ASSERT_EQUALS(i.index(), 2); i = c[4]; - TS_ASSERT_EQUALS(i.start(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:50")); - TS_ASSERT_EQUALS(i.stop(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:55")); + TS_ASSERT_EQUALS(i.start(), DateAndTime("2007-11-30T16:18:50")); + TS_ASSERT_EQUALS(i.stop(), DateAndTime("2007-11-30T16:18:55")); TS_ASSERT_EQUALS(i.index(), 2); // This fails since you can't add splitters together @@ -477,28 +477,28 @@ public: TimeSplitterType b; // the splitter ------ - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:15:00"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:16:00"); + start = DateAndTime("2007-11-30T16:15:00"); + stop = DateAndTime("2007-11-30T16:16:00"); b.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:19:00"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:20:00"); + start = DateAndTime("2007-11-30T16:19:00"); + stop = DateAndTime("2007-11-30T16:20:00"); b.push_back(SplittingInterval(start, stop, 3)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:00"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:19:00"); + start = DateAndTime("2007-11-30T16:18:00"); + stop = DateAndTime("2007-11-30T16:19:00"); b.push_back(SplittingInterval(start, stop, 2)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:00"); + start = DateAndTime("2007-11-30T16:17:00"); + stop = DateAndTime("2007-11-30T16:18:00"); b.push_back(SplittingInterval(start, stop, 1)); std::sort(b.begin(), b.end()); - TS_ASSERT_EQUALS(b[0].start(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:15:00")); - TS_ASSERT_EQUALS(b[1].start(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00")); - TS_ASSERT_EQUALS(b[2].start(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:00")); - TS_ASSERT_EQUALS(b[3].start(), DateAndTimeHelpers::createFromISO8601("2007-11-30T16:19:00")); + TS_ASSERT_EQUALS(b[0].start(), DateAndTime("2007-11-30T16:15:00")); + TS_ASSERT_EQUALS(b[1].start(), DateAndTime("2007-11-30T16:17:00")); + TS_ASSERT_EQUALS(b[2].start(), DateAndTime("2007-11-30T16:18:00")); + TS_ASSERT_EQUALS(b[3].start(), DateAndTime("2007-11-30T16:19:00")); } //---------------------------------------------------------------------------- @@ -507,34 +507,34 @@ public: TimeSplitterType b; // the splitter ------ - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:15:00"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:16:00"); + start = DateAndTime("2007-11-30T16:15:00"); + stop = DateAndTime("2007-11-30T16:16:00"); b.push_back(SplittingInterval(start, stop, 0)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:19:00"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:20:00"); + start = DateAndTime("2007-11-30T16:19:00"); + stop = DateAndTime("2007-11-30T16:20:00"); b.push_back(SplittingInterval(start, stop, 3)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:00"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:19:00"); + start = DateAndTime("2007-11-30T16:18:00"); + stop = DateAndTime("2007-11-30T16:19:00"); b.push_back(SplittingInterval(start, stop, 2)); - start = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"); - stop = DateAndTimeHelpers::createFromISO8601("2007-11-30T16:18:00"); + start = DateAndTime("2007-11-30T16:17:00"); + stop = DateAndTime("2007-11-30T16:18:00"); b.push_back(SplittingInterval(start, stop, 1)); std::sort(b.begin(), b.end()); TimeSplitterType::iterator sit; - SplittingInterval temp1(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"), -1); + SplittingInterval temp1(DateAndTime("2007-11-30T16:17:00"), + DateAndTime("2007-11-30T16:17:00"), -1); sit = std::lower_bound(b.begin(), b.end(), temp1); int index1 = int(sit - b.begin()); TS_ASSERT_EQUALS(index1, 1); - SplittingInterval temp2(DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:10"), - DateAndTimeHelpers::createFromISO8601("2007-11-30T16:17:00"), -1); + SplittingInterval temp2(DateAndTime("2007-11-30T16:17:10"), + DateAndTime("2007-11-30T16:17:00"), -1); sit = std::lower_bound(b.begin(), b.end(), temp2); int index2 = int(sit - b.begin()); TS_ASSERT_EQUALS(index2, 2); diff --git a/Framework/LiveData/inc/MantidLiveData/FakeEventDataListener.h b/Framework/LiveData/inc/MantidLiveData/FakeEventDataListener.h index 770701f70e2..b8b3c82e5c6 100644 --- a/Framework/LiveData/inc/MantidLiveData/FakeEventDataListener.h +++ b/Framework/LiveData/inc/MantidLiveData/FakeEventDataListener.h @@ -8,7 +8,7 @@ #include "MantidDataObjects/EventWorkspace.h" #include "MantidKernel/PseudoRandomNumberGenerator.h" #include <Poco/Timer.h> -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include <mutex> namespace Mantid { @@ -46,7 +46,7 @@ public: bool buffersEvents() const override { return true; } bool connect(const Poco::Net::SocketAddress &address) override; - void start(Mantid::Types::DateAndTime startTime = Mantid::Types::DateAndTime()) override; + void start(Types::Core::DateAndTime startTime = Types::Core::DateAndTime()) override; boost::shared_ptr<API::Workspace> extractData() override; bool isConnected() override; @@ -71,7 +71,7 @@ private: int m_numExtractDataCalls; ///< Number of times extractData has been called /// Date and time of the next time to end the run - Mantid::Types::DateAndTime m_nextEndRunTime; + Mantid::Types::Core::DateAndTime m_nextEndRunTime; /// Fake run number to give int m_runNumber; diff --git a/Framework/LiveData/inc/MantidLiveData/FileEventDataListener.h b/Framework/LiveData/inc/MantidLiveData/FileEventDataListener.h index 86ebaf7781b..838154bb48c 100644 --- a/Framework/LiveData/inc/MantidLiveData/FileEventDataListener.h +++ b/Framework/LiveData/inc/MantidLiveData/FileEventDataListener.h @@ -52,7 +52,7 @@ public: bool buffersEvents() const override { return true; } bool connect(const Poco::Net::SocketAddress &address) override; - void start(Mantid::Types::DateAndTime startTime = Mantid::Types::DateAndTime()) override; + void start(Types::Core::DateAndTime startTime = Types::Core::DateAndTime()) override; boost::shared_ptr<API::Workspace> extractData() override; bool isConnected() override; diff --git a/Framework/LiveData/inc/MantidLiveData/ISIS/ISISHistoDataListener.h b/Framework/LiveData/inc/MantidLiveData/ISIS/ISISHistoDataListener.h index 82bfd201476..275bdb8dccf 100644 --- a/Framework/LiveData/inc/MantidLiveData/ISIS/ISISHistoDataListener.h +++ b/Framework/LiveData/inc/MantidLiveData/ISIS/ISISHistoDataListener.h @@ -59,7 +59,7 @@ public: bool buffersEvents() const override { return false; } bool connect(const Poco::Net::SocketAddress &address) override; - void start(Mantid::Types::DateAndTime startTime = Mantid::Types::DateAndTime()) override; + void start(Types::Core::DateAndTime startTime = Types::Core::DateAndTime()) override; boost::shared_ptr<API::Workspace> extractData() override; bool isConnected() override; diff --git a/Framework/LiveData/inc/MantidLiveData/ISIS/ISISLiveEventDataListener.h b/Framework/LiveData/inc/MantidLiveData/ISIS/ISISLiveEventDataListener.h index d414350affd..ce19feb2c09 100644 --- a/Framework/LiveData/inc/MantidLiveData/ISIS/ISISLiveEventDataListener.h +++ b/Framework/LiveData/inc/MantidLiveData/ISIS/ISISLiveEventDataListener.h @@ -95,7 +95,7 @@ public: * The value of 'now' is zero for compatibility with the SNS * live stream. */ - void start(Mantid::Types::DateAndTime startTime = Mantid::Types::DateAndTime()) override; + void start(Types::Core::DateAndTime startTime = Types::Core::DateAndTime()) override; /** Get the data that's been buffered since the last call to this method * (or since start() was called). @@ -147,7 +147,7 @@ protected: void initEventBuffer(const TCPStreamEventDataSetup &setup); // Save received event data in the buffer workspace void saveEvents(const std::vector<TCPStreamEventNeutron> &data, - const Mantid::Types::DateAndTime &pulseTime, size_t period); + const Types::Core::DateAndTime &pulseTime, size_t period); // Set the spectra-detector map void loadSpectraMap(); // Load the instrument @@ -200,7 +200,7 @@ protected: /// Protects m_eventBuffer std::mutex m_mutex; /// Run start time - Mantid::Types::DateAndTime m_startTime; + Types::Core::DateAndTime m_startTime; /// Run number int m_runNumber; diff --git a/Framework/LiveData/inc/MantidLiveData/Kafka/KafkaEventListener.h b/Framework/LiveData/inc/MantidLiveData/Kafka/KafkaEventListener.h index fab3f44a48e..012b34f813a 100644 --- a/Framework/LiveData/inc/MantidLiveData/Kafka/KafkaEventListener.h +++ b/Framework/LiveData/inc/MantidLiveData/Kafka/KafkaEventListener.h @@ -58,7 +58,7 @@ public: //---------------------------------------------------------------------- bool connect(const Poco::Net::SocketAddress &address) override; - void start(Mantid::Types::DateAndTime startTime = Mantid::Types::DateAndTime()) override; + void start(Types::Core::DateAndTime startTime = Types::Core::DateAndTime()) override; boost::shared_ptr<API::Workspace> extractData() override; //---------------------------------------------------------------------- diff --git a/Framework/LiveData/inc/MantidLiveData/Kafka/KafkaEventStreamDecoder.h b/Framework/LiveData/inc/MantidLiveData/Kafka/KafkaEventStreamDecoder.h index 09fb558fa71..214743ef313 100644 --- a/Framework/LiveData/inc/MantidLiveData/Kafka/KafkaEventStreamDecoder.h +++ b/Framework/LiveData/inc/MantidLiveData/Kafka/KafkaEventStreamDecoder.h @@ -114,7 +114,7 @@ private: /// Mapping of spectrum number to workspace index. spec2index_map m_specToIdx; /// Start time of the run - Mantid::Types::DateAndTime m_runStart; + Types::Core::DateAndTime m_runStart; /// Subscriber for the run info stream std::unique_ptr<IKafkaStreamSubscriber> m_runStream; /// Subscriber for the run info stream diff --git a/Framework/LiveData/inc/MantidLiveData/LiveDataAlgorithm.h b/Framework/LiveData/inc/MantidLiveData/LiveDataAlgorithm.h index 27361a12f05..dcbbdc1f7fa 100644 --- a/Framework/LiveData/inc/MantidLiveData/LiveDataAlgorithm.h +++ b/Framework/LiveData/inc/MantidLiveData/LiveDataAlgorithm.h @@ -3,7 +3,7 @@ #include "MantidKernel/System.h" #include "MantidAPI/Algorithm.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidAPI/ILiveListener.h" namespace Mantid { @@ -53,7 +53,7 @@ public: protected: void initProps(); - Mantid::Types::DateAndTime getStartTime() const; + Mantid::Types::Core::DateAndTime getStartTime() const; Mantid::API::IAlgorithm_sptr makeAlgorithm(bool postProcessing); diff --git a/Framework/LiveData/inc/MantidLiveData/SNSLiveEventDataListener.h b/Framework/LiveData/inc/MantidLiveData/SNSLiveEventDataListener.h index 7ad4712e387..d3dc0d40e43 100644 --- a/Framework/LiveData/inc/MantidLiveData/SNSLiveEventDataListener.h +++ b/Framework/LiveData/inc/MantidLiveData/SNSLiveEventDataListener.h @@ -50,7 +50,7 @@ public: bool connect(const Poco::Net::SocketAddress &address) override; void - start(const Mantid::Types::DateAndTime startTime = Mantid::Types::DateAndTime()) override; + start(const Types::Core::DateAndTime startTime = Types::Core::DateAndTime()) override; boost::shared_ptr<API::Workspace> extractData() override; ILiveListener::RunStatus runStatus() override; @@ -104,7 +104,7 @@ private: return false; if (m_instrumentName.empty()) return false; - if (m_dataStartTime == Mantid::Types::DateAndTime()) + if (m_dataStartTime == Types::Core::DateAndTime()) return false; return haveRequiredLogs(); @@ -114,7 +114,7 @@ private: bool haveRequiredLogs(); void appendEvent(const uint32_t pixelId, const double tof, - const Mantid::Types::DateAndTime pulseTime); + const Mantid::Types::Core::DateAndTime pulseTime); // tof is "Time Of Flight" and is in units of microsecondss relative to the // start of the pulse // (There's some documentation that says nanoseconds, but Russell Taylor @@ -154,14 +154,14 @@ private: bool m_stopThread{false}; // background thread checks this periodically. // If true, the thread exits - Mantid::Types::DateAndTime m_startTime; // The requested start time for the data + Types::Core::DateAndTime m_startTime; // The requested start time for the data // stream (needed by the run() function) // Used to initialize the scan_index property if we haven't received a packet // with the 'real' value by the time we call initWorkspacePart2. (We can't // delay the call to initWorkspacePart2 because we might never receive a // 'real' value for that property. - Mantid::Types::DateAndTime m_dataStartTime; + Types::Core::DateAndTime m_dataStartTime; // These 2 determine whether or not we filter out events that arrive when // the run is paused. diff --git a/Framework/LiveData/inc/MantidLiveData/TOPAZLiveEventDataListener.h b/Framework/LiveData/inc/MantidLiveData/TOPAZLiveEventDataListener.h index 26498f5d490..6ead14320eb 100644 --- a/Framework/LiveData/inc/MantidLiveData/TOPAZLiveEventDataListener.h +++ b/Framework/LiveData/inc/MantidLiveData/TOPAZLiveEventDataListener.h @@ -49,7 +49,7 @@ public: bool buffersEvents() const override { return true; } bool connect(const Poco::Net::SocketAddress &address) override; - void start(Mantid::Types::DateAndTime startTime = Mantid::Types::DateAndTime()) override; + void start(Types::Core::DateAndTime startTime = Types::Core::DateAndTime()) override; boost::shared_ptr<API::Workspace> extractData() override; ILiveListener::RunStatus runStatus() override; @@ -67,7 +67,7 @@ private: void initMonitorWorkspace(); void appendEvent(uint32_t pixelId, double tof, - const Mantid::Types::DateAndTime pulseTime); + const Mantid::Types::Core::DateAndTime pulseTime); // tof is "Time Of Flight" and is in units of microsecondss relative to the // start of the pulse. (There's some documentation that says nanoseconds, // but Russell Taylor assures me it's really in microseconds!) diff --git a/Framework/LiveData/src/FakeEventDataListener.cpp b/Framework/LiveData/src/FakeEventDataListener.cpp index 64e0de03062..fc358890150 100644 --- a/Framework/LiveData/src/FakeEventDataListener.cpp +++ b/Framework/LiveData/src/FakeEventDataListener.cpp @@ -3,15 +3,14 @@ #include "MantidAPI/Run.h" #include "MantidAPI/WorkspaceFactory.h" #include "MantidKernel/ConfigService.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/MersenneTwister.h" #include "MantidKernel/WriteLock.h" #include "MantidLiveData/Exception.h" -#include "MantidTypes/DateAndTime.h" using namespace Mantid::Kernel; using namespace Mantid::API; -using Mantid::Types::DateAndTime; -using Mantid::Types::TofEvent; +using Mantid::Types::Core::DateAndTime; namespace Mantid { namespace LiveData { @@ -63,8 +62,7 @@ ILiveListener::RunStatus FakeEventDataListener::runStatus() { int FakeEventDataListener::runNumber() const { return m_runNumber; } void FakeEventDataListener::start( - Mantid::Types::DateAndTime /*startTime*/) // Ignore the start time for now - // at least + Types::Core::DateAndTime /*startTime*/) // Ignore the start time for now at least { // Set up the workspace buffer (probably won't know its dimensions before this // point) @@ -75,8 +73,7 @@ void FakeEventDataListener::start( WorkspaceFactory::Instance().create("EventWorkspace", 2, 2, 1)); // Set a sample tof range m_rand->setRange(40000, 60000); - m_rand->setSeed( - Mantid::Types::DateAndTime::getCurrentTime().totalNanoseconds()); + m_rand->setSeed(Types::Core::DateAndTime::getCurrentTime().totalNanoseconds()); // If necessary, calculate the number of events we need to generate on each // call of generateEvents @@ -139,8 +136,10 @@ boost::shared_ptr<Workspace> FakeEventDataListener::extractData() { void FakeEventDataListener::generateEvents(Poco::Timer &) { std::lock_guard<std::mutex> _lock(m_mutex); for (long i = 0; i < m_callbackloop; ++i) { - m_buffer->getSpectrum(0).addEventQuickly(TofEvent(m_rand->nextValue())); - m_buffer->getSpectrum(1).addEventQuickly(TofEvent(m_rand->nextValue())); + m_buffer->getSpectrum(0).addEventQuickly( + Types::Event::TofEvent(m_rand->nextValue())); + m_buffer->getSpectrum(1).addEventQuickly( + Types::Event::TofEvent(m_rand->nextValue())); } } } // namespace LiveData diff --git a/Framework/LiveData/src/FileEventDataListener.cpp b/Framework/LiveData/src/FileEventDataListener.cpp index a778024a9f0..72a0c2e60cb 100644 --- a/Framework/LiveData/src/FileEventDataListener.cpp +++ b/Framework/LiveData/src/FileEventDataListener.cpp @@ -113,7 +113,7 @@ ILiveListener::RunStatus FileEventDataListener::runStatus() { int FileEventDataListener::runNumber() const { return m_runNumber; } void FileEventDataListener::start( - Mantid::Types::DateAndTime /*startTime*/) // Ignore the start time + Types::Core::DateAndTime /*startTime*/) // Ignore the start time { // Kick off loading the first chunk (which will include loading the instrument // etc.) diff --git a/Framework/LiveData/src/ISIS/ISISHistoDataListener.cpp b/Framework/LiveData/src/ISIS/ISISHistoDataListener.cpp index 7e8097ef235..198b01fa5a5 100644 --- a/Framework/LiveData/src/ISIS/ISISHistoDataListener.cpp +++ b/Framework/LiveData/src/ISIS/ISISHistoDataListener.cpp @@ -149,7 +149,7 @@ int ISISHistoDataListener::runNumber() const { } void ISISHistoDataListener::start( - Mantid::Types::DateAndTime /*startTime*/) // Ignore the start time + Types::Core::DateAndTime /*startTime*/) // Ignore the start time {} /** diff --git a/Framework/LiveData/src/ISIS/ISISLiveEventDataListener.cpp b/Framework/LiveData/src/ISIS/ISISLiveEventDataListener.cpp index 83f4330e2bc..ef62b701c44 100644 --- a/Framework/LiveData/src/ISIS/ISISLiveEventDataListener.cpp +++ b/Framework/LiveData/src/ISIS/ISISLiveEventDataListener.cpp @@ -10,11 +10,11 @@ #include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceGroup.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/OptionalBool.h" #include "MantidKernel/TimeSeriesProperty.h" #include "MantidKernel/UnitFactory.h" #include "MantidKernel/WarningSuppressions.h" -#include "MantidTypes/DateAndTime.h" #ifdef GCC_VERSION // Avoid compiler warnings on gcc from unused static constants in @@ -25,8 +25,6 @@ GCC_DIAG_OFF(unused-variable) #endif #include "DAE/idc.h" -using Mantid::Types::TofEvent; - const char *PROTON_CHARGE_PROPERTY = "proton_charge"; const char *RUN_NUMBER_PROPERTY = "run_number"; @@ -38,7 +36,7 @@ DECLARE_LISTENER(ISISLiveEventDataListener) namespace { /// static logger Kernel::Logger g_log("ISISLiveEventDataListener"); -} // namespace +} /** * The constructor @@ -152,7 +150,7 @@ bool ISISLiveEventDataListener::connect( } // start event collection -void ISISLiveEventDataListener::start(Mantid::Types::DateAndTime startTime) { +void ISISLiveEventDataListener::start(Types::Core::DateAndTime startTime) { (void)startTime; m_thread.start(*this); } @@ -249,7 +247,7 @@ void ISISLiveEventDataListener::run() { CollectJunk(events.head_n); // absolute pulse (frame) time - Mantid::Types::DateAndTime pulseTime = + Mantid::Types::Core::DateAndTime pulseTime = m_startTime + static_cast<double>(events.head_n.frame_time_zero); // Save the pulse charge in the logs double protons = static_cast<double>(events.head_n.protons); @@ -284,8 +282,8 @@ void ISISLiveEventDataListener::run() { saveEvents(events.data, pulseTime, events.head_n.period); } - } catch (std::runtime_error - &e) { // exception handler for generic runtime exceptions + } catch (std::runtime_error & + e) { // exception handler for generic runtime exceptions g_log.error() << "Caught a runtime exception.\nException message: " << e.what() << '\n'; @@ -293,8 +291,8 @@ void ISISLiveEventDataListener::run() { m_backgroundException = boost::make_shared<std::runtime_error>(e); - } catch (std::invalid_argument - &e) { // TimeSeriesProperty (and possibly some other things) can + } catch (std::invalid_argument & + e) { // TimeSeriesProperty (and possibly some other things) can // can throw these errors g_log.error() << "Caught an invalid argument exception.\nException message: " @@ -377,7 +375,7 @@ void ISISLiveEventDataListener::initEventBuffer( */ void ISISLiveEventDataListener::saveEvents( const std::vector<TCPStreamEventNeutron> &data, - const Mantid::Types::DateAndTime &pulseTime, size_t period) { + const Types::Core::DateAndTime &pulseTime, size_t period) { std::lock_guard<std::mutex> scopedLock(m_mutex); if (period >= static_cast<size_t>(m_numberOfPeriods)) { @@ -390,7 +388,7 @@ void ISISLiveEventDataListener::saveEvents( } for (const auto &streamEvent : data) { - TofEvent event(streamEvent.time_of_flight, pulseTime); + Types::Event::TofEvent event(streamEvent.time_of_flight, pulseTime); m_eventBuffer[period] ->getSpectrum(streamEvent.spectrum) .addEventQuickly(event); @@ -398,8 +396,8 @@ void ISISLiveEventDataListener::saveEvents( } /** - * Set the spectra-detector map to the buffer workspace. - */ + * Set the spectra-detector map to the buffer workspace. + */ void ISISLiveEventDataListener::loadSpectraMap() { // Read in the number of detectors int ndet = getInt("NDET"); @@ -414,9 +412,9 @@ void ISISLiveEventDataListener::loadSpectraMap() { } /** - * Load the instrument - * @param instrName :: Instrument name - */ + * Load the instrument + * @param instrName :: Instrument name + */ void ISISLiveEventDataListener::loadInstrument(const std::string &instrName) { // try to load the instrument. if it doesn't load give a warning and carry on if (instrName.empty()) { @@ -466,16 +464,16 @@ void ISISLiveEventDataListener::getIntArray(const std::string &par, } /** Function called by IDC routines to report an error. Passes the error through - * to the logger - * @param status :: The status code of the error (disregarded) - * @param code :: The error code (disregarded) - * @param message :: The error message - passed to the logger at error level - */ +* to the logger +* @param status :: The status code of the error (disregarded) +* @param code :: The error code (disregarded) +* @param message :: The error message - passed to the logger at error level +*/ void ISISLiveEventDataListener::IDCReporter(int status, int code, const char *message) { (void)status; (void)code; // Avoid compiler warning g_log.error(message); } -} // namespace LiveData -} // namespace Mantid +} +} diff --git a/Framework/LiveData/src/Kafka/KafkaEventListener.cpp b/Framework/LiveData/src/Kafka/KafkaEventListener.cpp index ceafc9d8358..b75c4d33916 100644 --- a/Framework/LiveData/src/Kafka/KafkaEventListener.cpp +++ b/Framework/LiveData/src/Kafka/KafkaEventListener.cpp @@ -38,7 +38,7 @@ bool KafkaEventListener::connect(const Poco::Net::SocketAddress &address) { } /// @copydoc ILiveListener::start -void KafkaEventListener::start(Mantid::Types::DateAndTime startTime) { +void KafkaEventListener::start(Types::Core::DateAndTime startTime) { bool startNow = true; // Workaround for existing LiveListener interface // startTime of 0 means start from now diff --git a/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp b/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp index 4afda639a95..83692309226 100644 --- a/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp +++ b/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp @@ -46,7 +46,7 @@ std::string RUN_START_PROPERTY = "run_start"; */ template <typename T> void appendToLog(Mantid::API::Run &mutableRunInfo, const std::string &name, - const Mantid::Types::DateAndTime &time, T value) { + const Mantid::Types::Core::DateAndTime &time, T value) { if (mutableRunInfo.hasProperty(name)) { auto property = mutableRunInfo.getTimeSeriesProperty<T>(name); property->addValue(time, value); @@ -102,7 +102,8 @@ void addSampleEnvLogs( namespace Mantid { namespace LiveData { - using Mantid::Types::TofEvent; +using Types::Event::TofEvent; +using Types::Core::DateAndTime; // ----------------------------------------------------------------------------- // Public members diff --git a/Framework/LiveData/src/LiveDataAlgorithm.cpp b/Framework/LiveData/src/LiveDataAlgorithm.cpp index 9d0661c813d..15bc2200127 100644 --- a/Framework/LiveData/src/LiveDataAlgorithm.cpp +++ b/Framework/LiveData/src/LiveDataAlgorithm.cpp @@ -4,18 +4,17 @@ #include "MantidAPI/LiveListenerFactory.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/ConfigService.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/FacilityInfo.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/Strings.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include <boost/algorithm/string/trim.hpp> #include <unordered_set> using namespace Mantid::Kernel; using namespace Mantid::API; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; namespace Mantid { namespace LiveData { @@ -259,11 +258,11 @@ void LiveDataAlgorithm::setLiveListener( //---------------------------------------------------------------------------------------------- /** @return the value of the StartTime property */ -Mantid::Types::DateAndTime LiveDataAlgorithm::getStartTime() const { +Mantid::Types::Core::DateAndTime LiveDataAlgorithm::getStartTime() const { std::string date = getPropertyValue("StartTime"); if (date.empty()) return DateAndTime(); - return DateAndTimeHelpers::createFromISO8601(date); + return DateAndTime(date); } //---------------------------------------------------------------------------------------------- diff --git a/Framework/LiveData/src/LoadLiveData.cpp b/Framework/LiveData/src/LoadLiveData.cpp index 75f10b1eaa6..78352537873 100644 --- a/Framework/LiveData/src/LoadLiveData.cpp +++ b/Framework/LiveData/src/LoadLiveData.cpp @@ -16,6 +16,7 @@ using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::DataObjects; +using Mantid::Types::Core::DateAndTime; namespace Mantid { namespace LiveData { @@ -101,8 +102,8 @@ LoadLiveData::runProcessing(Mantid::API::Workspace_sptr inputWS, for (auto prop : proplist) { if ((prop->direction() == 0) && (!inputPropertyWorkspaceFound)) { if (boost::ends_with(prop->type(), "Workspace")) { - g_log.information() - << "Using " << prop->name() << " as the input property.\n"; + g_log.information() << "Using " << prop->name() + << " as the input property.\n"; alg->setPropertyValue(prop->name(), inputName); inputPropertyWorkspaceFound = true; } @@ -399,7 +400,7 @@ void LoadLiveData::exec() { } // TODO: Have the ILiveListener tell me exactly the time stamp - Types::DateAndTime lastTimeStamp = Types::DateAndTime::getCurrentTime(); + DateAndTime lastTimeStamp = DateAndTime::getCurrentTime(); this->setPropertyValue("LastTimeStamp", lastTimeStamp.toISO8601String()); // Now we process the chunk diff --git a/Framework/LiveData/src/MonitorLiveData.cpp b/Framework/LiveData/src/MonitorLiveData.cpp index 10bedc09123..d6defe6b9c4 100644 --- a/Framework/LiveData/src/MonitorLiveData.cpp +++ b/Framework/LiveData/src/MonitorLiveData.cpp @@ -12,7 +12,7 @@ using namespace Mantid::Kernel; using namespace Mantid::API; -using Mantid::Types::DateAndTime; +using Mantid::Types::Core::DateAndTime; namespace Mantid { namespace LiveData { @@ -87,8 +87,8 @@ void MonitorLiveData::doClone(const std::string &originalName, if (newMonitorWS) // If there was a monitor workspace, set it back on // the result { - ads.retrieveWS<MatrixWorkspace>(newName)->setMonitorWorkspace( - newMonitorWS); + ads.retrieveWS<MatrixWorkspace>(newName) + ->setMonitorWorkspace(newMonitorWS); } } else { std::cout << "Not cloning\n"; @@ -227,9 +227,8 @@ void MonitorLiveData::exec() { seconds = DateAndTime::secondsFromDuration(now - lastTime); if (seconds > UpdateEvery) g_log.warning() << "Cannot process live data as quickly as requested: " - "requested every " - << UpdateEvery << " seconds but it takes " << seconds - << " seconds!\n"; + "requested every " << UpdateEvery + << " seconds but it takes " << seconds << " seconds!\n"; } // loop until aborted // Set the outputs (only applicable when RunTransitionBehavior is "Stop") diff --git a/Framework/LiveData/src/SNSLiveEventDataListener.cpp b/Framework/LiveData/src/SNSLiveEventDataListener.cpp index 3e0e7e2e190..a3808f27f29 100644 --- a/Framework/LiveData/src/SNSLiveEventDataListener.cpp +++ b/Framework/LiveData/src/SNSLiveEventDataListener.cpp @@ -11,6 +11,7 @@ #include "MantidDataObjects/Events.h" #include "MantidGeometry/Instrument.h" #include "MantidKernel/ConfigService.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/OptionalBool.h" #include "MantidKernel/Strings.h" #include "MantidKernel/TimeSeriesProperty.h" @@ -18,7 +19,6 @@ #include "MantidKernel/WriteLock.h" #include "MantidLiveData/Exception.h" #include "MantidLiveData/SNSLiveEventDataListener.h" -#include "MantidTypes/DateAndTime.h" // Includes for parsing the XML device descriptions #include <Poco/DOM/AutoPtr.h> @@ -37,8 +37,8 @@ using namespace Mantid::Kernel; using namespace Mantid::API; -using Mantid::Types::DateAndTime; -using Mantid::Types::TofEvent; +using Mantid::Types::Core::DateAndTime; +using Mantid::Types::Event::TofEvent; namespace { // anonymous namespace // Time we'll wait on a receive call (in seconds) @@ -51,7 +51,7 @@ const std::string SCAN_PROPERTY("scan_index"); const std::string PROTON_CHARGE_PROPERTY("proton_charge"); // Helper function to get a DateAndTime value from an ADARA packet header -Mantid::Types::DateAndTime timeFromPacket(const ADARA::PacketHeader &hdr) { +Mantid::Types::Core::DateAndTime timeFromPacket(const ADARA::PacketHeader &hdr) { const uint32_t seconds = static_cast<uint32_t>(hdr.pulseId() >> 32); const uint32_t nanoseconds = hdr.pulseId() & 0xFFFFFFFF; @@ -72,7 +72,7 @@ DECLARE_LISTENER(SNSLiveEventDataListener) namespace { /// static logger Kernel::Logger g_log("SNSLiveEventDataListener"); -} // namespace +} /// Constructor SNSLiveEventDataListener::SNSLiveEventDataListener() @@ -182,8 +182,7 @@ bool SNSLiveEventDataListener::isConnected() { return m_isConnected; } /// @param startTime Specifies how much historical data the SMS should send /// before continuing the current 'live' data. Use 0 to indicate no /// historical data. -void SNSLiveEventDataListener::start( - const Mantid::Types::DateAndTime startTime) { +void SNSLiveEventDataListener::start(const Types::Core::DateAndTime startTime) { // Save the startTime and kick off the background thread // (Can't really do anything else until we send the hello packet and the SMS // sends us @@ -404,7 +403,7 @@ bool SNSLiveEventDataListener::rxPacket(const ADARA::BankedEventPkt &pkt) { std::lock_guard<std::mutex> scopedLock(m_mutex); // Timestamp for the events - Mantid::Types::DateAndTime eventTime = timeFromPacket(pkt); + Mantid::Types::Core::DateAndTime eventTime = timeFromPacket(pkt); // Save the pulse charge in the logs (*10 because we want the units to be // picoCulombs, and ADARA sends them out in units of 10pC) @@ -486,9 +485,8 @@ bool SNSLiveEventDataListener::rxPacket(const ADARA::BeamMonitorPkt &pkt) { // sufficient. g_log.error() << "Mantid cannot handle monitor ID's higher than 5. If " - << monitorID - << " is actually valid, then an appropriate " - "entry must be made to the " + << monitorID << " is actually valid, then an appropriate " + "entry must be made to the " << " ADDABLE list at the top of Framework/API/src/Run.cpp\n"; } else { std::string monName("monitor"); @@ -520,7 +518,7 @@ bool SNSLiveEventDataListener::rxPacket(const ADARA::BeamMonitorPkt &pkt) { // Add the event. Note that they're in units of 100 ns in the packet, // need to change to microseconds. monitorBuffer->getSpectrum(it->second) - .addEventQuickly(TofEvent(tof / 10.0, pktTime)); + .addEventQuickly(Types::Event::TofEvent(tof / 10.0, pktTime)); } } else { g_log.error() << "Event from unknown monitor ID (" << monitorID @@ -1111,9 +1109,9 @@ bool SNSLiveEventDataListener::rxPacket(const ADARA::DeviceDescriptorPkt &pkt) { prop = new TimeSeriesProperty<std::string>(pvName); } else { // invalid type string - g_log.warning() - << "Ignoring process variable " << pvName - << " because it had an unrecognized type (" << pvType << ").\n"; + g_log.warning() << "Ignoring process variable " << pvName + << " because it had an unrecognized type (" + << pvType << ").\n"; } if (prop) { @@ -1341,7 +1339,7 @@ bool SNSLiveEventDataListener::haveRequiredLogs() { /// Adds an event to the workspace void SNSLiveEventDataListener::appendEvent( const uint32_t pixelId, const double tof, - const Mantid::Types::DateAndTime pulseTime) + const Mantid::Types::Core::DateAndTime pulseTime) // NOTE: This function does NOT lock the mutex! Make sure you do that // before calling this function! { @@ -1350,7 +1348,7 @@ void SNSLiveEventDataListener::appendEvent( const auto it = m_indexMap.find(pixelId); if (it != m_indexMap.end()) { const std::size_t workspaceIndex = it->second; - TofEvent event(tof, pulseTime); + Types::Event::TofEvent event(tof, pulseTime); m_eventBuffer->getSpectrum(workspaceIndex).addEventQuickly(event); } else { g_log.warning() << "Invalid pixel ID: " << pixelId << " (TofF: " << tof @@ -1471,7 +1469,7 @@ ILiveListener::RunStatus SNSLiveEventDataListener::runStatus() { // Don't clear this for BeginRun because it was set up in the parser // for the RunStatus packet that signaled the beginning of a new // run and is thus already set to the correct value. - m_dataStartTime = Mantid::Types::DateAndTime(); + m_dataStartTime = Types::Core::DateAndTime(); } // NOTE: It's probably not necessary to clear the instrument name diff --git a/Framework/LiveData/src/StartLiveData.cpp b/Framework/LiveData/src/StartLiveData.cpp index f20b82ebb48..fca48a51870 100644 --- a/Framework/LiveData/src/StartLiveData.cpp +++ b/Framework/LiveData/src/StartLiveData.cpp @@ -6,17 +6,16 @@ #include "MantidAPI/Workspace.h" #include "MantidKernel/ArrayBoundedValidator.h" #include "MantidKernel/ArrayProperty.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/System.h" #include "MantidLiveData/LoadLiveData.h" #include "MantidLiveData/MonitorLiveData.h" +#include "MantidTypes/Core/DateAndTime.h" #include <Poco/ActiveResult.h> using namespace Mantid::Kernel; using namespace Mantid::API; - -using Mantid::Types::DateAndTime; +using Mantid::Types::Core::DateAndTime; namespace Mantid { namespace LiveData { @@ -27,7 +26,7 @@ DECLARE_ALGORITHM(StartLiveData) namespace { /// name for a group of properties that get copied from the listener const char *listenerPropertyGroup = "ListenerProperties"; -} // namespace +} //---------------------------------------------------------------------------------------------- /// Algorithm's name for identification. @see Algorithm::name @@ -167,8 +166,7 @@ void StartLiveData::exec() { this->setPropertyValue("StartTime", "1990-01-01T00:00:01"); else { // Validate the StartTime property. Don't allow times from the future - auto reqStartTime = Mantid::Types::DateAndTimeHelpers::createFromISO8601( - this->getPropertyValue("StartTime")); + DateAndTime reqStartTime(this->getPropertyValue("StartTime")); // DateAndTime will throw an exception if it can't interpret the string, so // we don't need to test for that condition. diff --git a/Framework/LiveData/src/TOPAZLiveEventDataListener.cpp b/Framework/LiveData/src/TOPAZLiveEventDataListener.cpp index 7bbb3d44c20..09e9793276c 100644 --- a/Framework/LiveData/src/TOPAZLiveEventDataListener.cpp +++ b/Framework/LiveData/src/TOPAZLiveEventDataListener.cpp @@ -11,18 +11,18 @@ #include "MantidKernel/UnitFactory.h" #include "MantidLiveData/Exception.h" -#include <Poco/Net/DatagramSocket.h> #include <Poco/Net/NetException.h> -#include <Poco/Net/SocketAddress.h> #include <Poco/Net/StreamSocket.h> +#include <Poco/Net/DatagramSocket.h> +#include <Poco/Net/SocketAddress.h> -#include <exception> -#include <fstream> #include <string> +#include <fstream> +#include <exception> using namespace Mantid::Kernel; using namespace Mantid::API; -using Mantid::Types::TofEvent; +using Mantid::Types::Core::DateAndTime; #if 0 // Port numbers @@ -122,13 +122,13 @@ typedef struct neutron_event_struct NEUTRON_EVENT, *NEUTRON_EVENT_PTR; ****************************************************************************/ // Helper function to get a DateAndTime value from a pulse_id_struct -Mantid::Types::DateAndTime timeFromPulse(const pulse_id_struct *p) { +Mantid::Types::Core::DateAndTime timeFromPulse(const pulse_id_struct *p) { uint32_t seconds = p->pulseIDhigh; uint32_t nanoseconds = p->pulseIDlow; // Make sure we pick the correct constructor (the Mac gets an ambiguous error) - return Mantid::Types::DateAndTime(static_cast<int64_t>(seconds), - static_cast<int64_t>(nanoseconds)); + return DateAndTime(static_cast<int64_t>(seconds), + static_cast<int64_t>(nanoseconds)); } namespace Mantid { @@ -138,7 +138,7 @@ DECLARE_LISTENER(TOPAZLiveEventDataListener) namespace { /// static logger Kernel::Logger g_log("SNSLiveEventDataListener"); -} // namespace +} /// Constructor TOPAZLiveEventDataListener::TOPAZLiveEventDataListener() @@ -265,7 +265,7 @@ bool TOPAZLiveEventDataListener::isConnected() { return m_isConnected; } /// it and stores the resulting events in a temporary workspace. /// @param startTime Ignored. This class doesn't have the capability to /// replay historical data. -void TOPAZLiveEventDataListener::start(Mantid::Types::DateAndTime startTime) { +void TOPAZLiveEventDataListener::start(Types::Core::DateAndTime startTime) { (void)startTime; // Keep the compiler from complaining about unsed variable // Initialize the workspace @@ -373,7 +373,7 @@ void TOPAZLiveEventDataListener::run() { } // Timestamp for the events - Mantid::Types::DateAndTime eventTime = timeFromPulse(&pid[i]); + Mantid::Types::Core::DateAndTime eventTime = timeFromPulse(&pid[i]); std::lock_guard<std::mutex> scopedLock(m_mutex); // Save the pulse charge in the logs @@ -520,7 +520,7 @@ void TOPAZLiveEventDataListener::initMonitorWorkspace() { /// Adds an event to the workspace void TOPAZLiveEventDataListener::appendEvent( - uint32_t pixelId, double tof, const Mantid::Types::DateAndTime pulseTime) + uint32_t pixelId, double tof, const Mantid::Types::Core::DateAndTime pulseTime) // NOTE: This function does NOT lock the mutex! Make sure you do that // before calling this function! { @@ -529,7 +529,7 @@ void TOPAZLiveEventDataListener::appendEvent( auto it = m_indexMap.find(pixelId); if (it != m_indexMap.end()) { std::size_t workspaceIndex = it->second; - TofEvent event(tof, pulseTime); + Mantid::Types::Event::TofEvent event(tof, pulseTime); m_eventBuffer->getSpectrum(workspaceIndex).addEventQuickly(event); } else { // TODO: do we want to disable this warning? Most of the time, we diff --git a/Framework/LiveData/test/KafkaTesting.h b/Framework/LiveData/test/KafkaTesting.h index bbdc057eb22..bcc2ea360d0 100644 --- a/Framework/LiveData/test/KafkaTesting.h +++ b/Framework/LiveData/test/KafkaTesting.h @@ -136,7 +136,7 @@ public: assert(buffer); // Convert date to time_t - auto mantidTime = Mantid::Kernel::DateAndTime(m_startTime); + auto mantidTime = Mantid::Types::Core::DateAndTime(m_startTime); auto tmb = mantidTime.to_tm(); uint64_t startTime = static_cast<uint64_t>(std::mktime(&tmb)); diff --git a/Framework/LiveData/test/TestDataListener.cpp b/Framework/LiveData/test/TestDataListener.cpp index f3066f81a31..c958a5ec239 100644 --- a/Framework/LiveData/test/TestDataListener.cpp +++ b/Framework/LiveData/test/TestDataListener.cpp @@ -12,7 +12,7 @@ using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::Geometry; using Mantid::Kernel::ConfigService; -using Mantid::Types::TofEvent; +using Mantid::Types::Event::TofEvent; namespace Mantid { namespace LiveData { @@ -22,7 +22,7 @@ DECLARE_LISTENER(TestDataListener) TestDataListener::TestDataListener() : LiveListener(), m_buffer(), m_rand(new Kernel::MersenneTwister( - Mantid::Types::DateAndTime::getCurrentTime().totalNanoseconds(), 40000, + Types::Core::DateAndTime::getCurrentTime().totalNanoseconds(), 40000, 60000)), m_changeStatusAfter(0), m_newStatus(ILiveListener::EndRun) { // Set up the first workspace buffer @@ -80,7 +80,7 @@ ILiveListener::RunStatus TestDataListener::runStatus() { int TestDataListener::runNumber() const { return 999; } void TestDataListener::start( - Mantid::Types::DateAndTime /*startTime*/) // Ignore the start time + Types::Core::DateAndTime /*startTime*/) // Ignore the start time {} /** Create the default empty event workspace */ diff --git a/Framework/LiveData/test/TestDataListener.h b/Framework/LiveData/test/TestDataListener.h index 0533ce14bba..aba92b96cd5 100644 --- a/Framework/LiveData/test/TestDataListener.h +++ b/Framework/LiveData/test/TestDataListener.h @@ -22,8 +22,8 @@ public: bool buffersEvents() const override { return true; } bool connect(const Poco::Net::SocketAddress &address) override; - void start(Mantid::Types::DateAndTime startTime = - Mantid::Types::DateAndTime()) override; + void start( + Types::Core::DateAndTime startTime = Types::Core::DateAndTime()) override; boost::shared_ptr<API::Workspace> extractData() override; bool isConnected() override; diff --git a/Framework/LiveData/test/TestGroupDataListener.cpp b/Framework/LiveData/test/TestGroupDataListener.cpp index be8844ccd1d..768a7357119 100644 --- a/Framework/LiveData/test/TestGroupDataListener.cpp +++ b/Framework/LiveData/test/TestGroupDataListener.cpp @@ -40,7 +40,7 @@ int TestGroupDataListener::runNumber() const { return 0; } void TestGroupDataListener::setSpectra(const std::vector<specnum_t> &) {} void TestGroupDataListener::start( - Mantid::Types::DateAndTime /*startTime*/) // Ignore the start time + Types::Core::DateAndTime /*startTime*/) // Ignore the start time {} /** Create the default empty event workspace */ diff --git a/Framework/LiveData/test/TestGroupDataListener.h b/Framework/LiveData/test/TestGroupDataListener.h index da53ff9feee..29907bf2224 100644 --- a/Framework/LiveData/test/TestGroupDataListener.h +++ b/Framework/LiveData/test/TestGroupDataListener.h @@ -22,7 +22,8 @@ public: bool buffersEvents() const override { return true; } bool connect(const Poco::Net::SocketAddress &address) override; - void start(Types::DateAndTime startTime = Types::DateAndTime()) override; + void start( + Types::Core::DateAndTime startTime = Types::Core::DateAndTime()) override; boost::shared_ptr<API::Workspace> extractData() override; bool isConnected() override; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertSpiceDataToRealSpace.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertSpiceDataToRealSpace.h index c77c3e87eb0..6997fa367ee 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertSpiceDataToRealSpace.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertSpiceDataToRealSpace.h @@ -76,9 +76,9 @@ private: /// Parse data table workspace to a vector of matrix workspaces std::vector<API::MatrixWorkspace_sptr> convertToMatrixWorkspace( DataObjects::TableWorkspace_sptr tablews, - API::MatrixWorkspace_const_sptr parentws, Mantid::Types::DateAndTime runstart, + API::MatrixWorkspace_const_sptr parentws, Types::Core::DateAndTime runstart, std::map<std::string, std::vector<double>> &logvecmap, - std::vector<Mantid::Types::DateAndTime> &vectimes); + std::vector<Types::Core::DateAndTime> &vectimes); /// Create an MDEventWorspace by converting vector of matrix workspace data API::IMDEventWorkspace_sptr @@ -103,7 +103,7 @@ private: /// Load one run (one pt.) to a matrix workspace API::MatrixWorkspace_sptr loadRunToMatrixWS( DataObjects::TableWorkspace_sptr tablews, size_t irow, - API::MatrixWorkspace_const_sptr parentws, Mantid::Types::DateAndTime runstart, + API::MatrixWorkspace_const_sptr parentws, Types::Core::DateAndTime runstart, size_t ipt, size_t irotangle, size_t itime, const std::vector<std::pair<size_t, size_t>> anodelist, double &duration); @@ -116,7 +116,7 @@ private: void appendSampleLogs(API::IMDEventWorkspace_sptr mdws, const std::map<std::string, std::vector<double>> &logvecmap, - const std::vector<Mantid::Types::DateAndTime> &vectimes); + const std::vector<Types::Core::DateAndTime> &vectimes); /// Parse detector efficiency table workspace to map std::map<detid_t, double> diff --git a/Framework/MDAlgorithms/src/ConvToMDEventsWS.cpp b/Framework/MDAlgorithms/src/ConvToMDEventsWS.cpp index 4048cc12664..8e6a436d1e4 100644 --- a/Framework/MDAlgorithms/src/ConvToMDEventsWS.cpp +++ b/Framework/MDAlgorithms/src/ConvToMDEventsWS.cpp @@ -2,8 +2,6 @@ #include "MantidMDAlgorithms/UnitsConversionHelper.h" -using Mantid::Types::TofEvent; - namespace Mantid { namespace MDAlgorithms { /**function converts particular list of events of type T into MD workspace and @@ -76,7 +74,7 @@ size_t ConvToMDEventsWS::conversionChunk(size_t workspaceIndex) { switch (m_EventWS->getSpectrum(workspaceIndex).getEventType()) { case Mantid::API::TOF: - return this->convertEventList<TofEvent>( + return this->convertEventList<Mantid::Types::Event::TofEvent>( workspaceIndex); case Mantid::API::WEIGHTED: return this->convertEventList<Mantid::DataObjects::WeightedEvent>( diff --git a/Framework/MDAlgorithms/src/ConvertSpiceDataToRealSpace.cpp b/Framework/MDAlgorithms/src/ConvertSpiceDataToRealSpace.cpp index ae5978d74a9..d9dca7da8bd 100644 --- a/Framework/MDAlgorithms/src/ConvertSpiceDataToRealSpace.cpp +++ b/Framework/MDAlgorithms/src/ConvertSpiceDataToRealSpace.cpp @@ -13,7 +13,6 @@ #include "MantidGeometry/IComponent.h" #include "MantidGeometry/IDetector.h" #include "MantidGeometry/MDGeometry/GeneralFrame.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/OptionalBool.h" #include "MantidKernel/TimeSeriesProperty.h" @@ -28,7 +27,7 @@ using namespace Mantid::Kernel; using namespace Mantid::DataObjects; using namespace Mantid::Geometry; using namespace Mantid::DataObjects; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; DECLARE_ALGORITHM(ConvertSpiceDataToRealSpace) @@ -111,7 +110,7 @@ void ConvertSpiceDataToRealSpace::exec() { // Use parent workspace's first std::string runstartstr = parentWS->run().getProperty("run_start")->value(); try { - auto temprunstart = DateAndTimeHelpers::createFromISO8601(runstartstr); + DateAndTime temprunstart(runstartstr); runstart = temprunstart; hasrunstartset = true; } catch (...) { @@ -126,7 +125,7 @@ void ConvertSpiceDataToRealSpace::exec() { // Use user given std::string runstartstr = getProperty("RunStart"); try { - auto temprunstart = DateAndTimeHelpers::createFromISO8601(runstartstr); + DateAndTime temprunstart(runstartstr); runstart = temprunstart; hasrunstartset = true; } catch (...) { @@ -143,7 +142,7 @@ void ConvertSpiceDataToRealSpace::exec() { // Convert table workspace to a list of 2D workspaces std::map<std::string, std::vector<double>> logvecmap; - std::vector<Mantid::Types::DateAndTime> vectimes; + std::vector<Types::Core::DateAndTime> vectimes; // Set up range for x/y/z m_extentMins.resize(3); @@ -205,10 +204,9 @@ void ConvertSpiceDataToRealSpace::exec() { std::vector<MatrixWorkspace_sptr> ConvertSpiceDataToRealSpace::convertToMatrixWorkspace( DataObjects::TableWorkspace_sptr tablews, - API::MatrixWorkspace_const_sptr parentws, - Mantid::Types::DateAndTime runstart, + API::MatrixWorkspace_const_sptr parentws, Types::Core::DateAndTime runstart, std::map<std::string, std::vector<double>> &logvecmap, - std::vector<Mantid::Types::DateAndTime> &vectimes) { + std::vector<Types::Core::DateAndTime> &vectimes) { // Get table workspace's column information size_t ipt, irotangle, itime; std::vector<std::pair<size_t, size_t>> anodelist; @@ -284,7 +282,7 @@ void ConvertSpiceDataToRealSpace::parseSampleLogs( */ MatrixWorkspace_sptr ConvertSpiceDataToRealSpace::loadRunToMatrixWS( DataObjects::TableWorkspace_sptr tablews, size_t irow, - MatrixWorkspace_const_sptr parentws, Mantid::Types::DateAndTime runstart, + MatrixWorkspace_const_sptr parentws, Types::Core::DateAndTime runstart, size_t ipt, size_t irotangle, size_t itime, const std::vector<std::pair<size_t, size_t>> anodelist, double &duration) { // New workspace from parent workspace @@ -437,7 +435,7 @@ void ConvertSpiceDataToRealSpace::readTableInfo( void ConvertSpiceDataToRealSpace::appendSampleLogs( IMDEventWorkspace_sptr mdws, const std::map<std::string, std::vector<double>> &logvecmap, - const std::vector<Mantid::Types::DateAndTime> &vectimes) { + const std::vector<Types::Core::DateAndTime> &vectimes) { // Check! size_t numexpinfo = mdws->getNumExperimentInfo(); if (numexpinfo == 0) @@ -460,7 +458,7 @@ void ConvertSpiceDataToRealSpace::appendSampleLogs( // Add run_start and start_time to each ExperimentInfo for (size_t i = 0; i < vectimes.size(); ++i) { - Mantid::Types::DateAndTime runstart = vectimes[i]; + Types::Core::DateAndTime runstart = vectimes[i]; mdws->getExperimentInfo(static_cast<uint16_t>(i)) ->mutableRun() .addLogData(new PropertyWithValue<std::string>( @@ -750,5 +748,5 @@ void ConvertSpiceDataToRealSpace::correctByDetectorEfficiency( } } -} // namespace MDAlgorithms +} // namespace DataHandling } // namespace Mantid diff --git a/Framework/MDAlgorithms/src/ConvertToDetectorFaceMD.cpp b/Framework/MDAlgorithms/src/ConvertToDetectorFaceMD.cpp index 4625070e79a..372df92cc8a 100644 --- a/Framework/MDAlgorithms/src/ConvertToDetectorFaceMD.cpp +++ b/Framework/MDAlgorithms/src/ConvertToDetectorFaceMD.cpp @@ -16,7 +16,7 @@ using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::DataObjects; using namespace Mantid::Geometry; -using Mantid::Types::TofEvent; +using Mantid::Types::Event::TofEvent; namespace Mantid { namespace MDAlgorithms { diff --git a/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace.cpp b/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace.cpp index ff2743dc277..db50f17dd78 100644 --- a/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace.cpp +++ b/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace.cpp @@ -31,7 +31,7 @@ using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::Geometry; -using Mantid::Types::TofEvent; +using Mantid::Types::Event::TofEvent; namespace Mantid { namespace MDAlgorithms { diff --git a/Framework/MDAlgorithms/src/IntegrateFlux.cpp b/Framework/MDAlgorithms/src/IntegrateFlux.cpp index 6c0355a8e16..502f8647153 100644 --- a/Framework/MDAlgorithms/src/IntegrateFlux.cpp +++ b/Framework/MDAlgorithms/src/IntegrateFlux.cpp @@ -14,6 +14,7 @@ namespace MDAlgorithms { using Mantid::Kernel::Direction; using Mantid::API::WorkspaceProperty; using namespace Mantid::HistogramData; +using Mantid::Types::Event::TofEvent; // Register the algorithm into the AlgorithmFactory DECLARE_ALGORITHM(IntegrateFlux) @@ -146,7 +147,7 @@ void IntegrateFlux::integrateSpectra(const API::MatrixWorkspace &inputWS, integrateSpectraEvents<DataObjects::WeightedEvent>(*eventWS, integrWS); return; case (API::TOF): - integrateSpectraEvents<Types::TofEvent>(*eventWS, integrWS); + integrateSpectraEvents<TofEvent>(*eventWS, integrWS); return; } } else { diff --git a/Framework/MDAlgorithms/src/SaveIsawQvector.cpp b/Framework/MDAlgorithms/src/SaveIsawQvector.cpp index f1598e6b99b..68e28c9d702 100644 --- a/Framework/MDAlgorithms/src/SaveIsawQvector.cpp +++ b/Framework/MDAlgorithms/src/SaveIsawQvector.cpp @@ -13,7 +13,7 @@ using namespace Mantid::API; using namespace Mantid::Kernel; using namespace Mantid::DataObjects; -using Mantid::Types::TofEvent; +using Mantid::Types::Event::TofEvent; namespace Mantid { namespace MDAlgorithms { diff --git a/Framework/MDAlgorithms/test/ConvertCWPDMDToSpectraTest.h b/Framework/MDAlgorithms/test/ConvertCWPDMDToSpectraTest.h index 0aac0398ee9..455b961ef20 100644 --- a/Framework/MDAlgorithms/test/ConvertCWPDMDToSpectraTest.h +++ b/Framework/MDAlgorithms/test/ConvertCWPDMDToSpectraTest.h @@ -9,19 +9,18 @@ #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/Run.h" #include "MantidDataHandling/LoadSpiceAscii.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/Exception.h" #include "MantidKernel/TimeSeriesProperty.h" #include "MantidKernel/Unit.h" #include "MantidMDAlgorithms/ConvertCWPDMDToSpectra.h" #include "MantidMDAlgorithms/ConvertSpiceDataToRealSpace.h" -using Mantid::DataHandling::LoadSpiceAscii; using Mantid::MDAlgorithms::ConvertCWPDMDToSpectra; +using Mantid::DataHandling::LoadSpiceAscii; using Mantid::MDAlgorithms::ConvertSpiceDataToRealSpace; using namespace Mantid::API; using namespace Mantid::Kernel; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; class ConvertCWPDMDToSpectraTest : public CxxTest::TestSuite { public: diff --git a/Framework/MDAlgorithms/test/ConvertSpiceDataToRealSpaceTest.h b/Framework/MDAlgorithms/test/ConvertSpiceDataToRealSpaceTest.h index b9d5f64939e..d01934b1b6b 100644 --- a/Framework/MDAlgorithms/test/ConvertSpiceDataToRealSpaceTest.h +++ b/Framework/MDAlgorithms/test/ConvertSpiceDataToRealSpaceTest.h @@ -20,7 +20,6 @@ #include "MantidKernel/Property.h" #include "MantidKernel/TimeSeriesProperty.h" #include "MantidMDAlgorithms/ConvertSpiceDataToRealSpace.h" -#include "MantidKernel/DateAndTimeHelpers.h" using Mantid::MDAlgorithms::ConvertSpiceDataToRealSpace; using Mantid::DataHandling::LoadInstrument; @@ -29,7 +28,7 @@ using Mantid::DataHandling::LoadSpiceAscii; using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::Kernel; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; class ConvertSpiceDataToRealSpaceTest : public CxxTest::TestSuite { public: diff --git a/Framework/MDAlgorithms/test/IntegrateEllipsoidsTest.h b/Framework/MDAlgorithms/test/IntegrateEllipsoidsTest.h index fed327a934f..3d0659f6fab 100644 --- a/Framework/MDAlgorithms/test/IntegrateEllipsoidsTest.h +++ b/Framework/MDAlgorithms/test/IntegrateEllipsoidsTest.h @@ -18,7 +18,7 @@ using namespace Mantid::MDAlgorithms; using namespace Mantid::Kernel; using namespace Mantid::Geometry; using namespace Mantid::DataObjects; -using Mantid::Types::TofEvent; +using Mantid::Types::Event::TofEvent; namespace { // Add A Fake 'Peak' to both the event data and to the peaks workspace diff --git a/Framework/Nexus/inc/MantidNexus/NexusClasses.h b/Framework/Nexus/inc/MantidNexus/NexusClasses.h index 380ba0ffcd1..3196318ba2a 100644 --- a/Framework/Nexus/inc/MantidNexus/NexusClasses.h +++ b/Framework/Nexus/inc/MantidNexus/NexusClasses.h @@ -739,7 +739,7 @@ private: ///@returns a property pointer template <class NX_TYPE, class TIME_TYPE> Kernel::Property *loadValues(const std::string &logName, NX_TYPE &value, - Mantid::Types::DateAndTime start_t, + Types::Core::DateAndTime start_t, const TIME_TYPE ×) { value.openLocal(); auto logv = new Kernel::TimeSeriesProperty<double>(logName); diff --git a/Framework/Nexus/inc/MantidNexus/NexusFileIO.h b/Framework/Nexus/inc/MantidNexus/NexusFileIO.h index 1ebb0140580..3995cb08d88 100644 --- a/Framework/Nexus/inc/MantidNexus/NexusFileIO.h +++ b/Framework/Nexus/inc/MantidNexus/NexusFileIO.h @@ -387,22 +387,22 @@ void NexusFileIO::writeNumericTimeLog( if (ipos != std::string::npos) logName = logName.substr(ipos + 1); // extract values from timeseries - std::map<Mantid::Types::DateAndTime, T> dV = timeSeries->valueAsMap(); + std::map<Types::Core::DateAndTime, T> dV = timeSeries->valueAsMap(); std::vector<double> values; std::vector<double> times; - Mantid::Types::DateAndTime t0; + Types::Core::DateAndTime t0; bool first = true; - for (typename std::map<Mantid::Types::DateAndTime, T>::const_iterator dv = + for (typename std::map<Types::Core::DateAndTime, T>::const_iterator dv = dV.begin(); dv != dV.end(); dv++) { T val = dv->second; - Mantid::Types::DateAndTime time = dv->first; + Types::Core::DateAndTime time = dv->first; values.push_back(val); if (first) { t0 = time; // start time of log first = false; } - times.push_back(Mantid::Types::DateAndTime::secondsFromDuration(time - t0)); + times.push_back(Types::Core::DateAndTime::secondsFromDuration(time - t0)); } // create log status = NXmakegroup(fileID, logName.c_str(), "NXlog"); diff --git a/Framework/PythonInterface/mantid/api/CMakeLists.txt b/Framework/PythonInterface/mantid/api/CMakeLists.txt index 4b074d1dc9a..1ae62d7b981 100644 --- a/Framework/PythonInterface/mantid/api/CMakeLists.txt +++ b/Framework/PythonInterface/mantid/api/CMakeLists.txt @@ -144,7 +144,7 @@ target_link_libraries ( PythonAPIModule LINK_PRIVATE ${TCMALLOC_LIBRARIES_LINKTI PythonGeometryModule PythonKernelModule API - Types + Types Kernel HistogramData Geometry diff --git a/Framework/PythonInterface/mantid/dataobjects/CMakeLists.txt b/Framework/PythonInterface/mantid/dataobjects/CMakeLists.txt index 0f444730bc5..f263dfed5a7 100644 --- a/Framework/PythonInterface/mantid/dataobjects/CMakeLists.txt +++ b/Framework/PythonInterface/mantid/dataobjects/CMakeLists.txt @@ -71,7 +71,7 @@ target_link_libraries ( PythonDataObjectsModule LINK_PRIVATE ${TCMALLOC_LIBRARIE PythonKernelModule API DataObjects - Types + Types Kernel HistogramData Geometry diff --git a/Framework/PythonInterface/mantid/dataobjects/src/Exports/EventList.cpp b/Framework/PythonInterface/mantid/dataobjects/src/Exports/EventList.cpp index 3f8c1c4be2a..a684a2e1a58 100644 --- a/Framework/PythonInterface/mantid/dataobjects/src/Exports/EventList.cpp +++ b/Framework/PythonInterface/mantid/dataobjects/src/Exports/EventList.cpp @@ -10,8 +10,8 @@ GET_POINTER_SPECIALIZATION(EventList) namespace { void addEventToEventList(EventList &self, double tof, - Mantid::Types::DateAndTime pulsetime) { - self.addEventQuickly(Mantid::Types::TofEvent(tof, pulsetime)); + Mantid::Types::Core::DateAndTime pulsetime) { + self.addEventQuickly(Mantid::Types::Event::TofEvent(tof, pulsetime)); } } diff --git a/Framework/PythonInterface/mantid/kernel/src/Exports/DateAndTime.cpp b/Framework/PythonInterface/mantid/kernel/src/Exports/DateAndTime.cpp index b909575bcb8..3054cb50966 100644 --- a/Framework/PythonInterface/mantid/kernel/src/Exports/DateAndTime.cpp +++ b/Framework/PythonInterface/mantid/kernel/src/Exports/DateAndTime.cpp @@ -1,11 +1,8 @@ -#include "MantidTypes/DateAndTime.h" -#include <MantidKernel/DateAndTimeHelpers.h> +#include "MantidKernel/DateAndTime.h" #include <boost/python/class.hpp> -#include <boost/python/make_constructor.hpp> #include <boost/python/operators.hpp> // Also provides self -using Mantid::Types::DateAndTime; -using Mantid::Types::time_duration; +using namespace Mantid::Types::Core; using namespace boost::python; using boost::python::arg; @@ -19,14 +16,11 @@ std::string ISO8601StringPlusSpace(DateAndTime &self) { return self.toISO8601String() + " "; } -void createFromISO8601(DateAndTime &self, const std::string &date) { - self = Mantid::Types::DateAndTimeHelpers::createFromISO8601(date); -} - void export_DateAndTime() { class_<DateAndTime>("DateAndTime", no_init) // Constructors - .def("__init__", make_constructor(&createFromISO8601)) + .def(init<const std::string>((arg("self"), arg("ISO8601 string")), + "Construct from an ISO8601 string")) .def(init<double, double>( (arg("self"), arg("seconds"), arg("nanoseconds")), "Construct using a number of seconds and nanoseconds (floats)")) diff --git a/Framework/PythonInterface/mantid/kernel/src/Exports/StlContainers.cpp b/Framework/PythonInterface/mantid/kernel/src/Exports/StlContainers.cpp index 7d9fe1af17c..b30e117f306 100644 --- a/Framework/PythonInterface/mantid/kernel/src/Exports/StlContainers.cpp +++ b/Framework/PythonInterface/mantid/kernel/src/Exports/StlContainers.cpp @@ -1,6 +1,6 @@ #include "MantidPythonInterface/kernel/StlExportDefinitions.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/Quat.h" #include "MantidKernel/V3D.h" @@ -16,7 +16,7 @@ void exportStlContainers() { std_vector_exporter<double>::wrap("std_vector_dbl"); std_vector_exporter<bool>::wrap("std_vector_bool"); std_vector_exporter<std::string>::wrap("std_vector_str"); - std_vector_exporter<Mantid::Types::DateAndTime>::wrap( + std_vector_exporter<Mantid::Types::Core::DateAndTime>::wrap( "std_vector_dateandtime"); std_vector_exporter<Mantid::Kernel::Quat>::wrap("std_vector_quat"); std_vector_exporter<Mantid::Kernel::V3D>::wrap("std_vector_v3d"); diff --git a/Framework/PythonInterface/mantid/kernel/src/Exports/TimeSeriesProperty.cpp b/Framework/PythonInterface/mantid/kernel/src/Exports/TimeSeriesProperty.cpp index 1bf09100f64..7736d4c86c7 100644 --- a/Framework/PythonInterface/mantid/kernel/src/Exports/TimeSeriesProperty.cpp +++ b/Framework/PythonInterface/mantid/kernel/src/Exports/TimeSeriesProperty.cpp @@ -9,7 +9,7 @@ #include <boost/python/return_value_policy.hpp> #include <boost/python/register_ptr_to_python.hpp> -using Mantid::Types::DateAndTime; +using Mantid::Types::Core::DateAndTime; using Mantid::Kernel::TimeSeriesProperty; using Mantid::Kernel::Property; using namespace boost::python; diff --git a/Framework/PythonInterface/test/cpp/CMakeLists.txt b/Framework/PythonInterface/test/cpp/CMakeLists.txt index 43f0992caf1..ac77fec315c 100644 --- a/Framework/PythonInterface/test/cpp/CMakeLists.txt +++ b/Framework/PythonInterface/test/cpp/CMakeLists.txt @@ -18,7 +18,6 @@ if ( CXXTEST_FOUND ) target_link_libraries( PythonInterfaceCppTest LINK_PRIVATE ${TCMALLOC_LIBRARIES_LINKTIME} API Geometry - Types Kernel PythonKernelModule PythonAPIModule diff --git a/Framework/PythonInterface/test/testhelpers/CMakeLists.txt b/Framework/PythonInterface/test/testhelpers/CMakeLists.txt index 0a918e2189e..ba9c7e44a57 100644 --- a/Framework/PythonInterface/test/testhelpers/CMakeLists.txt +++ b/Framework/PythonInterface/test/testhelpers/CMakeLists.txt @@ -42,7 +42,7 @@ target_link_libraries ( PythonWorkspaceCreationHelper LINK_PRIVATE ${TCMALLOC_LI DataHandling API HistogramData - Types + Types Kernel Geometry ${PYTHON_LIBRARIES} diff --git a/Framework/RemoteJobManagers/src/MantidWebServiceAPIJobManager.cpp b/Framework/RemoteJobManagers/src/MantidWebServiceAPIJobManager.cpp index 3d00162e922..a73f0e7b772 100644 --- a/Framework/RemoteJobManagers/src/MantidWebServiceAPIJobManager.cpp +++ b/Framework/RemoteJobManagers/src/MantidWebServiceAPIJobManager.cpp @@ -1,8 +1,7 @@ -#include "MantidRemoteJobManagers/MantidWebServiceAPIJobManager.h" #include "MantidAPI/RemoteJobManagerFactory.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/Logger.h" #include "MantidRemoteJobManagers/MantidWebServiceAPIHelper.h" +#include "MantidRemoteJobManagers/MantidWebServiceAPIJobManager.h" #include "MantidRemoteJobManagers/SimpleJSON.h" #include <fstream> @@ -16,9 +15,10 @@ DECLARE_REMOTEJOBMANAGER(MantidWebServiceAPIJobManager) namespace { // static logger object Mantid::Kernel::Logger g_log("MantidWebServiceAPIJobManager"); -} // namespace +} using namespace Mantid::Kernel; +using Mantid::Types::Core::DateAndTime; /** * Abort a previously submitted job @@ -101,8 +101,8 @@ void MantidWebServiceAPIJobManager::downloadRemoteFile( const std::string &localFileName) { std::istream &respStream = - httpGet("/download", std::string("TransID=") + transactionID + - "&File=" + remoteFileName); + httpGet("/download", std::string("TransID=") + transactionID + "&File=" + + remoteFileName); if (lastStatus() == Poco::Net::HTTPResponse::HTTP_OK) { @@ -222,12 +222,9 @@ MantidWebServiceAPIJobManager::queryAllRemoteJobs() const { info.name = jobNames[i]; info.runnableName = scriptNames[i]; info.transactionID = transIds[i]; - info.submitDate = - Mantid::Types::DateAndTimeHelpers::createFromISO8601(submitDates[i]); - info.startDate = - Mantid::Types::DateAndTimeHelpers::createFromISO8601(startDates[i]); - info.completionTime = Mantid::Types::DateAndTimeHelpers::createFromISO8601( - completionDates[i]); + info.submitDate = DateAndTime(submitDates[i]); + info.startDate = DateAndTime(startDates[i]); + info.completionTime = DateAndTime(completionDates[i]); info.cmdLine = cmdLines[i]; result.push_back(info); } @@ -322,16 +319,13 @@ MantidWebServiceAPIJobManager::queryRemoteJob(const std::string &jobID) const { // in the output and see if the values are there... if (status.find("SubmitDate") != status.end()) { status["SubmitDate"].getValue(value); - info.submitDate = - Mantid::Types::DateAndTimeHelpers::createFromISO8601(value); + info.submitDate = DateAndTime(value); status["StartDate"].getValue(value); - info.startDate = - Mantid::Types::DateAndTimeHelpers::createFromISO8601(value); + info.startDate = DateAndTime(value); status["CompletionDate"].getValue(value); - info.completionTime = - Mantid::Types::DateAndTimeHelpers::createFromISO8601(value); + info.completionTime = DateAndTime(value); } // in principle not required for/provided by the Mantid remote job submission diff --git a/Framework/RemoteJobManagers/test/CMakeLists.txt b/Framework/RemoteJobManagers/test/CMakeLists.txt index 8265c269351..e189795e99a 100644 --- a/Framework/RemoteJobManagers/test/CMakeLists.txt +++ b/Framework/RemoteJobManagers/test/CMakeLists.txt @@ -4,7 +4,7 @@ if ( CXXTEST_FOUND ) cxxtest_add_test ( RemoteJobManagersTest ${TEST_FILES} ) target_link_libraries ( RemoteJobManagersTest LINK_PRIVATE ${TCMALLOC_LIBRARIES_LINKTIME} API - Types + Types Kernel RemoteJobManagers ${Boost_LIBRARIES} diff --git a/Framework/SINQ/inc/MantidSINQ/SINQHMListener.h b/Framework/SINQ/inc/MantidSINQ/SINQHMListener.h index 2abbd55cec7..8c170057cb9 100644 --- a/Framework/SINQ/inc/MantidSINQ/SINQHMListener.h +++ b/Framework/SINQ/inc/MantidSINQ/SINQHMListener.h @@ -48,8 +48,8 @@ public: bool buffersEvents() const override { return false; } bool connect(const Poco::Net::SocketAddress &address) override; - void start(Mantid::Types::DateAndTime startTime = - Mantid::Types::DateAndTime()) override; + void start(Mantid::Types::Core::DateAndTime startTime = + Mantid::Types::Core::DateAndTime()) override; boost::shared_ptr<Mantid::API::Workspace> extractData() override; bool isConnected() override; ILiveListener::RunStatus runStatus() override; diff --git a/Framework/SINQ/src/SINQHMListener.cpp b/Framework/SINQ/src/SINQHMListener.cpp index 741e8b892e4..fd1ebf197de 100644 --- a/Framework/SINQ/src/SINQHMListener.cpp +++ b/Framework/SINQ/src/SINQHMListener.cpp @@ -123,7 +123,7 @@ void SINQHMListener::setSpectra( */ } -void SINQHMListener::start(Mantid::Types::DateAndTime /*startTime */) { +void SINQHMListener::start(Mantid::Types::Core::DateAndTime /*startTime */) { // Nothing to do here } diff --git a/Framework/ScriptRepository/inc/MantidScriptRepository/ScriptRepositoryImpl.h b/Framework/ScriptRepository/inc/MantidScriptRepository/ScriptRepositoryImpl.h index e5bb325432a..4b81bee8347 100644 --- a/Framework/ScriptRepository/inc/MantidScriptRepository/ScriptRepositoryImpl.h +++ b/Framework/ScriptRepository/inc/MantidScriptRepository/ScriptRepositoryImpl.h @@ -2,11 +2,10 @@ #define _MANTIDSCRIPTREPOSITORY_SCRIPTREPOSITORYIMPL_H_ #include "MantidAPI/ScriptRepository.h" -#include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidKernel/DateAndTime.h" #include "MantidScriptRepository/DllConfig.h" -#include "MantidTypes/DateAndTime.h" -#include <json/value.h> #include <map> +#include <json/value.h> namespace Mantid { namespace API { @@ -45,17 +44,17 @@ class SCRIPT_DLL_EXPORT ScriptRepositoryImpl : public ScriptRepository { /// For the local files, get the DateAndTime reported by the operative /// system /// or defaultTime if not available. - Mantid::Types::DateAndTime current_date; + Types::Core::DateAndTime current_date; /// For the files that were downloaded, get the DateAndTime reported when /// they /// were created. - Mantid::Types::DateAndTime downloaded_date; + Types::Core::DateAndTime downloaded_date; /// For the remote files, get the DateAndTime of the last revision. - Mantid::Types::DateAndTime pub_date; + Types::Core::DateAndTime pub_date; /// Description of the files. std::string description; /// The version downloaded of this file - Mantid::Types::DateAndTime downloaded_pubdate; + Types::Core::DateAndTime downloaded_pubdate; /// Indicate if this file should be updated automatically. bool auto_update; /// Identify the author of this file. @@ -65,11 +64,10 @@ class SCRIPT_DLL_EXPORT ScriptRepositoryImpl : public ScriptRepository { /// provide a constructor, to set the default values. RepositoryEntry() : remote(false), local(false), directory(false), - current_date(Mantid::Types::DateAndTimeHelpers::defaultTime()), - downloaded_date(Mantid::Types::DateAndTimeHelpers::defaultTime()), - pub_date(Mantid::Types::DateAndTimeHelpers::defaultTime()), - description(""), - downloaded_pubdate(Mantid::Types::DateAndTimeHelpers::defaultTime()), + current_date(Types::Core::DateAndTime::defaultTime()), + downloaded_date(Types::Core::DateAndTime::defaultTime()), + pub_date(Types::Core::DateAndTime::defaultTime()), description(""), + downloaded_pubdate(Types::Core::DateAndTime::defaultTime()), auto_update(false), author(""), status(BOTH_UNCHANGED){}; }; diff --git a/Framework/ScriptRepository/src/ScriptRepositoryImpl.cpp b/Framework/ScriptRepository/src/ScriptRepositoryImpl.cpp index b2d847a63e6..667418dfea1 100644 --- a/Framework/ScriptRepository/src/ScriptRepositoryImpl.cpp +++ b/Framework/ScriptRepository/src/ScriptRepositoryImpl.cpp @@ -2,35 +2,34 @@ #include "MantidScriptRepository/ScriptRepositoryImpl.h" #include "MantidAPI/ScriptRepositoryFactory.h" #include "MantidKernel/ConfigService.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/Exception.h" #include "MantidKernel/InternetHelper.h" #include "MantidKernel/Logger.h" #include "MantidKernel/NetworkProxy.h" #include "MantidKernel/ProxyInfo.h" -#include <unordered_set> #include <utility> +#include <unordered_set> -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; +using Mantid::Kernel::Logger; using Mantid::Kernel::ConfigService; using Mantid::Kernel::ConfigServiceImpl; -using Mantid::Kernel::Logger; -using Mantid::Kernel::NetworkProxy; using Mantid::Kernel::ProxyInfo; +using Mantid::Kernel::NetworkProxy; // from poco -#include <Poco/Exception.h> -#include <Poco/File.h> -#include <Poco/Net/NetException.h> #include <Poco/Path.h> +#include <Poco/File.h> #include <Poco/TemporaryFile.h> #include <Poco/URI.h> +#include <Poco/Exception.h> +#include <Poco/Net/NetException.h> /*#include <Poco/Net/HTTPClientSession.h> #include <Poco/Net/HTTPRequest.h> #include <Poco/Net/HTTPResponse.h> */ -#include "Poco/Net/FilePartSource.h" #include <Poco/Net/HTMLForm.h> +#include "Poco/Net/FilePartSource.h" // Visual Studio complains with the inclusion of Poco/FileStream // disabling this warning. @@ -46,14 +45,14 @@ using Mantid::Kernel::ProxyInfo; #include <Poco/NullStream.h> #include <cstdlib> #endif -#include <Poco/DateTimeFormatter.h> -#include <Poco/DateTimeParser.h> -#include <Poco/DirectoryIterator.h> #include <Poco/StreamCopier.h> +#include <Poco/DirectoryIterator.h> +#include <Poco/DateTimeParser.h> +#include <Poco/DateTimeFormatter.h> // from boost -#include <boost/algorithm/string.hpp> #include <boost/foreach.hpp> +#include <boost/algorithm/string.hpp> #include <boost/regex.hpp> #include <json/json.h> @@ -63,7 +62,7 @@ namespace API { namespace { /// static logger Kernel::Logger g_log("ScriptRepositoryImpl"); -} // namespace +} /// Default timeout int DEFAULT_TIMEOUT_SEC = 30; @@ -363,8 +362,7 @@ void ScriptRepositoryImpl::ensureValidRepository() { if (!isValid()) { std::stringstream ss; ss << "ScriptRepository is not installed correctly. The current path for " - "ScriptRepository is " - << local_repository + "ScriptRepository is " << local_repository << " but some important files that are required are corrupted or not " "present." << "\nPlease, re-install the ScriptRepository!\n" @@ -466,12 +464,11 @@ std::vector<std::string> ScriptRepositoryImpl::listFiles() { // it will proceed in this situation. } catch (Poco::Exception &ex) { g_log.error() << "ScriptRepository failed to list all entries inside the " - "repository. Details: " - << ex.className() << ":> " << ex.displayText() << '\n'; + "repository. Details: " << ex.className() << ":> " + << ex.displayText() << '\n'; } catch (std::exception &ex) { g_log.error() << "ScriptRepository failed to list all entries inside the " - "repository. Details: " - << ex.what() << '\n'; + "repository. Details: " << ex.what() << '\n'; } std::vector<std::string> out(repo.size()); size_t i = repo.size(); @@ -658,7 +655,7 @@ void ScriptRepositoryImpl::download_directory( dir.createDirectories(); entry.second.status = BOTH_UNCHANGED; - entry.second.downloaded_date = DateAndTimeHelpers::createFromISO8601( + entry.second.downloaded_date = DateAndTime( Poco::DateTimeFormatter::format(dir.getLastModified(), timeformat)); entry.second.downloaded_pubdate = entry.second.pub_date; updateLocalJson(entry.first, entry.second); @@ -742,7 +739,7 @@ void ScriptRepositoryImpl::download_file(const std::string &file_path, { Poco::File local(local_path); - entry.downloaded_date = DateAndTimeHelpers::createFromISO8601( + entry.downloaded_date = DateAndTime( Poco::DateTimeFormatter::format(local.getLastModified(), timeformat)); entry.downloaded_pubdate = entry.pub_date; entry.status = BOTH_UNCHANGED; @@ -893,15 +890,13 @@ void ScriptRepositoryImpl::upload(const std::string &file_path, RepositoryEntry &entry = repo.at(file_path); { Poco::File local(absolute_path); - entry.downloaded_date = DateAndTimeHelpers::createFromISO8601( - Poco::DateTimeFormatter::format(local.getLastModified(), - timeformat)); + entry.downloaded_date = DateAndTime(Poco::DateTimeFormatter::format( + local.getLastModified(), timeformat)); // update the pub_date and downloaded_pubdate with the pub_date given by // the upload. // this ensures that the status will be correctly defined. if (!published_date.empty()) - entry.pub_date = - DateAndTimeHelpers::createFromISO8601(published_date); + entry.pub_date = DateAndTime(published_date); entry.downloaded_pubdate = entry.pub_date; entry.status = BOTH_UNCHANGED; } @@ -915,8 +910,7 @@ void ScriptRepositoryImpl::upload(const std::string &file_path, // So add to the file locally to avoid race condition. RepositoryEntry &remote_entry = repo.at(file_path); if (!published_date.empty()) - remote_entry.pub_date = - DateAndTimeHelpers::createFromISO8601(published_date); + remote_entry.pub_date = DateAndTime(published_date); remote_entry.status = BOTH_UNCHANGED; g_log.debug() << "ScriptRepository updating repository json \n"; updateRepositoryJson(file_path, remote_entry); @@ -930,14 +924,14 @@ void ScriptRepositoryImpl::upload(const std::string &file_path, } /* - * Adds an entry to .repository.json - * This is necessary when uploading a file to keep .repository.json and - * .local.json in sync, and thus display correct file status in the GUI. - * Requesting an updated .repository.json from the server is not viable - * at such a time as it would create a race condition. - * @param path: relative path of uploaded file - * @param entry: the entry to add to the json file - */ +* Adds an entry to .repository.json +* This is necessary when uploading a file to keep .repository.json and +* .local.json in sync, and thus display correct file status in the GUI. +* Requesting an updated .repository.json from the server is not viable +* at such a time as it would create a race condition. +* @param path: relative path of uploaded file +* @param entry: the entry to add to the json file +*/ void ScriptRepositoryImpl::updateRepositoryJson(const std::string &path, const RepositoryEntry &entry) { @@ -1439,8 +1433,7 @@ void ScriptRepositoryImpl::parseCentralRepository(Repository &repo) { RepositoryEntry &entry = repo[filepath]; entry.remote = true; entry.directory = entry_json.get("directory", false).asBool(); - entry.pub_date = DateAndTimeHelpers::createFromISO8601( - entry_json.get("pub_date", "").asString()); + entry.pub_date = DateAndTime(entry_json.get("pub_date", "").asString()); entry.description = entry_json.get("description", "").asString(); entry.author = entry_json.get("author", "").asString(); entry.status = BOTH_UNCHANGED; @@ -1509,11 +1502,9 @@ void ScriptRepositoryImpl::parseDownloadedEntries(Repository &repo) { // was found at the local file system and at the remote repository entry_it->second.downloaded_pubdate = - DateAndTimeHelpers::createFromISO8601( - entry_json.get("downloaded_pubdate", "").asString()); + DateAndTime(entry_json.get("downloaded_pubdate", "").asString()); entry_it->second.downloaded_date = - DateAndTimeHelpers::createFromISO8601( - entry_json.get("downloaded_date", "").asString()); + DateAndTime(entry_json.get("downloaded_date", "").asString()); std::string auto_update = entry_json.get("auto_update", "false").asString(); entry_it->second.auto_update = @@ -1659,7 +1650,7 @@ void ScriptRepositoryImpl::recursiveParsingDirectories(const std::string &path, // '\n'; RepositoryEntry &entry = repo[entry_path]; entry.local = true; - entry.current_date = DateAndTimeHelpers::createFromISO8601( + entry.current_date = DateAndTime( Poco::DateTimeFormatter::format(it->getLastModified(), timeformat)); entry.directory = it->isDirectory(); if (it->isDirectory()) @@ -1774,6 +1765,6 @@ std::string ScriptRepositoryImpl::convertPath(const std::string &path) { return path; } -} // namespace API +} // END API -} // namespace Mantid +} // END MANTID diff --git a/Framework/ScriptRepository/test/CMakeLists.txt b/Framework/ScriptRepository/test/CMakeLists.txt index b9e32da9cf5..26f42cadb8b 100644 --- a/Framework/ScriptRepository/test/CMakeLists.txt +++ b/Framework/ScriptRepository/test/CMakeLists.txt @@ -7,7 +7,7 @@ if ( CXXTEST_FOUND ) cxxtest_add_test ( ScriptRepositoryTest ${TEST_FILES} ${GMOCK_TEST_FILES}) target_link_libraries( ScriptRepositoryTest LINK_PRIVATE ${TCMALLOC_LIBRARIES_LINKTIME} API - Types + Types Kernel ScriptRepository ${Boost_LIBRARIES} diff --git a/Framework/ScriptRepository/test/ScriptRepositoryTestImpl.h b/Framework/ScriptRepository/test/ScriptRepositoryTestImpl.h index 87bfde69557..48098cfef3b 100644 --- a/Framework/ScriptRepository/test/ScriptRepositoryTestImpl.h +++ b/Framework/ScriptRepository/test/ScriptRepositoryTestImpl.h @@ -1,10 +1,10 @@ #ifndef SCRIPTREPOSITORYIMPLTEST_H_ #define SCRIPTREPOSITORYIMPLTEST_H_ +#include <cxxtest/TestSuite.h> #include "MantidScriptRepository/ScriptRepositoryImpl.h" #include <Poco/File.h> #include <Poco/Path.h> -#include <cxxtest/TestSuite.h> // Visual Studion compains with the inclusion of Poco/FileStream // disabling this warning. #if defined(_WIN32) || defined(_WIN64) @@ -15,19 +15,17 @@ #else #include <Poco/FileStream.h> #endif -#include "MantidKernel/ConfigService.h" -#include "MantidKernel/DateAndTimeHelpers.h" -#include <Poco/DateTimeFormatter.h> #include <Poco/TemporaryFile.h> #include <algorithm> +#include <Poco/DateTimeFormatter.h> #include <boost/algorithm/string.hpp> - +#include "MantidKernel/ConfigService.h" using Mantid::Kernel::ConfigService; using Mantid::Kernel::ConfigServiceImpl; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; using namespace std; -using Mantid::API::ScriptRepoException; using Mantid::API::ScriptRepositoryImpl; +using Mantid::API::ScriptRepoException; const bool TEST_MANUALLY = false; @@ -393,8 +391,8 @@ public: } /************************************* - * File Info - *************************************/ + * File Info + *************************************/ void test_info_correctly_parses_the_repository_json() { using Mantid::API::ScriptInfo; TS_ASSERT_THROWS_NOTHING(repo->install(local_rep)); @@ -404,14 +402,13 @@ public: "tofconverter description"); TS_ASSERT(information.author.empty()); TSM_ASSERT("check time", - information.pub_date == DateAndTimeHelpers::createFromISO8601( - "2012-02-10 10:00:50")); + information.pub_date == DateAndTime("2012-02-10 10:00:50")); TS_ASSERT(!information.auto_update); } /************************************* - * Download - *************************************/ + * Download + *************************************/ /** Test that we are able to download files from the remote repository */ @@ -456,8 +453,8 @@ public: } /************************************* - * UPDATE - *************************************/ + * UPDATE + *************************************/ void test_update() { TS_ASSERT_THROWS_NOTHING(repo->install(local_rep)); std::vector<string> list_of_files; @@ -625,8 +622,8 @@ public: } /************************************* - * FILE STATUS - *************************************/ + * FILE STATUS + *************************************/ void test_info_of_one_file() { std::string file_name = "TofConv/README.txt"; std::string dir_name = "TofConv"; @@ -733,8 +730,8 @@ public: } /************************************* - * FILE STATUS - *************************************/ + * FILE STATUS + *************************************/ void test_info_of_downloaded_folder() { std::string file_name = "TofConv/TofConverter.py"; std::string folder_name = "TofConv"; @@ -900,8 +897,8 @@ public: } /************************************* - * SET IGNORE FILES - *************************************/ + * SET IGNORE FILES + *************************************/ void test_ignore_files() { TS_ASSERT_THROWS_NOTHING(repo->install(local_rep)); diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h b/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h index 74442ea9763..93b7fab66f1 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h @@ -15,7 +15,7 @@ #include "MantidDataObjects/MDEventFactory.h" #include "MantidDataObjects/MDEventWorkspace.h" #include "MantidDataObjects/MDLeanEvent.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/Utils.h" #include "MantidKernel/make_unique.h" diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h b/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h index 0e163cffeb5..905cdbd28d3 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h @@ -14,24 +14,28 @@ #include "MantidAPI/Algorithm.h" #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/ITableWorkspace_fwd.h" +#include "MantidAPI/Run.h" #include "MantidAPI/MatrixWorkspace_fwd.h" #include "MantidAPI/Run.h" #include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceGroup_fwd.h" #include "MantidDataObjects/EventWorkspace.h" #include "MantidDataObjects/RebinnedOutput.h" +#include "MantidDataObjects/Workspace2D.h" +#include "MantidDataObjects/WorkspaceSingleValue.h" +#include "MantidDataObjects/EventWorkspace.h" +#include "MantidDataObjects/RebinnedOutput.h" #include "MantidDataObjects/TableWorkspace.h" #include "MantidDataObjects/Workspace2D.h" #include "MantidDataObjects/WorkspaceSingleValue.h" #include "MantidGeometry/Instrument/Detector.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/make_unique.h" namespace Mantid { namespace DataObjects { class PeaksWorkspace; } -} // namespace Mantid +} namespace WorkspaceCreationHelper { /// Create a Fibonacci series @@ -302,8 +306,8 @@ createEventWorkspace(int numPixels, int numBins, int numEvents = 100, Mantid::DataObjects::EventWorkspace_sptr createEventWorkspaceWithStartTime( int numPixels, int numBins, int numEvents = 100, double x0 = 0.0, double binDelta = 1.0, int eventPattern = 1, int start_at_pixelID = 0, - Mantid::Types::DateAndTime run_start = - Mantid::Types::DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00")); + Mantid::Types::Core::DateAndTime run_start = + Mantid::Types::Core::DateAndTime("2010-01-01T00:00:00")); Mantid::DataObjects::EventWorkspace_sptr createGroupedEventWorkspace(std::vector<std::vector<int>> groups, int numBins, diff --git a/Framework/TestHelpers/src/ComponentCreationHelper.cpp b/Framework/TestHelpers/src/ComponentCreationHelper.cpp index 57872098445..85e290caf03 100644 --- a/Framework/TestHelpers/src/ComponentCreationHelper.cpp +++ b/Framework/TestHelpers/src/ComponentCreationHelper.cpp @@ -13,7 +13,7 @@ #include "MantidTestHelpers/ComponentCreationHelper.h" #include "MantidKernel/UnitFactory.h" #include "MantidKernel/ConfigService.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/make_unique.h" #include "MantidKernel/Quat.h" #include "MantidGeometry/Objects/ShapeFactory.h" diff --git a/Framework/TestHelpers/src/MDEventsTestHelper.cpp b/Framework/TestHelpers/src/MDEventsTestHelper.cpp index e6a8c270ad8..4a8ca104102 100644 --- a/Framework/TestHelpers/src/MDEventsTestHelper.cpp +++ b/Framework/TestHelpers/src/MDEventsTestHelper.cpp @@ -12,20 +12,20 @@ #include "MantidAPI/FrameworkManager.h" #include "MantidAPI/MatrixWorkspace.h" -#include "MantidDataObjects/EventWorkspace.h" #include "MantidDataObjects/FakeMD.h" +#include "MantidDataObjects/EventWorkspace.h" #include "MantidDataObjects/MDEventWorkspace.h" #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/InstrumentDefinitionParser.h" -#include "MantidGeometry/MDGeometry/GeneralFrame.h" #include "MantidGeometry/MDGeometry/MDHistoDimension.h" #include "MantidGeometry/MDGeometry/MDTypes.h" +#include "MantidGeometry/MDGeometry/GeneralFrame.h" -#include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidKernel/cow_ptr.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/Strings.h" #include "MantidKernel/Utils.h" -#include "MantidKernel/cow_ptr.h" #include "MantidTestHelpers/FacilityHelper.h" #include "MantidTestHelpers/MDEventsTestHelper.h" @@ -39,12 +39,12 @@ namespace Mantid { namespace DataObjects { using namespace Mantid::API; -using Mantid::DataObjects::EventWorkspace; using Mantid::DataObjects::EventWorkspace_sptr; +using Mantid::DataObjects::EventWorkspace; using Mantid::Geometry::InstrumentDefinitionParser; -using Mantid::Geometry::MDHistoDimension; using Mantid::Geometry::MDHistoDimension_sptr; -using namespace Mantid::Types; +using Mantid::Geometry::MDHistoDimension; +using Mantid::Types::Core::DateAndTime; namespace Strings = Mantid::Kernel::Strings; /** Set of helper methods for testing MDEventWorkspace things @@ -77,13 +77,12 @@ createDiffractionEventWorkspace(int numEvents, int numPixels, int numBins) { retVal->populateInstrumentParameters(); retVal->setInstrument(instrument); - DateAndTime run_start = - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00"); + DateAndTime run_start("2010-01-01T00:00:00"); for (int pix = 0; pix < numPixels; pix++) { for (int i = 0; i < numEvents; i++) { - retVal->getSpectrum(pix) += Mantid::DataObjects::TofEvent( - (i + 0.5) * binDelta, run_start + double(i)); + retVal->getSpectrum(pix) += + Types::Event::TofEvent((i + 0.5) * binDelta, run_start + double(i)); } retVal->getSpectrum(pix).addDetectorID(pix); } @@ -368,6 +367,6 @@ void checkAndDeleteFile(std::string filename) { } } -} // namespace MDEventsTestHelper -} // namespace DataObjects -} // namespace Mantid +} // namespace +} +} diff --git a/Framework/TestHelpers/src/SingleCrystalDiffractionTestHelper.cpp b/Framework/TestHelpers/src/SingleCrystalDiffractionTestHelper.cpp index 618c1bc8d44..5737b6bc4b5 100644 --- a/Framework/TestHelpers/src/SingleCrystalDiffractionTestHelper.cpp +++ b/Framework/TestHelpers/src/SingleCrystalDiffractionTestHelper.cpp @@ -21,7 +21,7 @@ using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::Geometry; using namespace Mantid::Kernel; -using Mantid::Types::TofEvent; +using Mantid::Types::Event::TofEvent; namespace Mantid { namespace SingleCrystalDiffractionTestHelper { diff --git a/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp b/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp index ec2b00f5a1d..79660994195 100644 --- a/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp +++ b/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp @@ -13,6 +13,7 @@ #include "MantidTestHelpers/InstrumentCreationHelper.h" #include "MantidAPI/Algorithm.h" +#include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidAPI/IAlgorithm.h" #include "MantidAPI/NumericAxis.h" #include "MantidAPI/Run.h" @@ -26,13 +27,11 @@ #include "MantidGeometry/Crystal/OrientedLattice.h" #include "MantidGeometry/Instrument/Component.h" #include "MantidGeometry/Instrument/Detector.h" -#include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidGeometry/Instrument/Goniometer.h" #include "MantidGeometry/Instrument/ParameterMap.h" #include "MantidGeometry/Instrument/ReferenceFrame.h" #include "MantidGeometry/Objects/ShapeFactory.h" #include "MantidHistogramData/LinearGenerator.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/MersenneTwister.h" #include "MantidKernel/OptionalBool.h" #include "MantidKernel/TimeSeriesProperty.h" @@ -52,7 +51,8 @@ using namespace Mantid::Geometry; using namespace Mantid::HistogramData; using Mantid::MantidVec; using Mantid::MantidVecPtr; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; +using Mantid::Types::Event::TofEvent; MockAlgorithm::MockAlgorithm(size_t nSteps) : m_Progress( @@ -86,17 +86,17 @@ void removeWS(const std::string &name) { } /** - * Creates bin or point based histograms based on the data passed - * in for Y and E values and the bool specified. - * - * @param isHistogram :: Specifies whether the returned histogram - * should use points or bin edges for the x axis. True gives bin edges. - * @param yAxis :: Takes an rvalue (move) of the y axis for the new histogram - * @param eAxis :: Takes an rvalue (move) of the e axis for the new histogram - * - * @return :: Returns a histogram with the user specified X axis type - * and the data the user passed in. - */ + * Creates bin or point based histograms based on the data passed + * in for Y and E values and the bool specified. + * + * @param isHistogram :: Specifies whether the returned histogram + * should use points or bin edges for the x axis. True gives bin edges. + * @param yAxis :: Takes an rvalue (move) of the y axis for the new histogram + * @param eAxis :: Takes an rvalue (move) of the e axis for the new histogram + * + * @return :: Returns a histogram with the user specified X axis type + * and the data the user passed in. + */ template <typename YType, typename EType> Histogram createHisto(bool isHistogram, YType &&yAxis, EType &&eAxis) { // We don't need to check if y.size() == e.size() as the histogram @@ -559,13 +559,13 @@ create2DWorkspaceWithReflectometryInstrument(double startX) { } /** - * Create a very small 2D workspace for a virtual reflectometry instrument with - * multiple detectors - * @return workspace with instrument attached. - * @param startX : X Tof start value for the workspace. - * @param detSize : optional detector height (default is 0 which puts all - * detectors at the same position) - */ +* Create a very small 2D workspace for a virtual reflectometry instrument with +* multiple detectors +* @return workspace with instrument attached. +* @param startX : X Tof start value for the workspace. +* @param detSize : optional detector height (default is 0 which puts all +* detectors at the same position) +*/ MatrixWorkspace_sptr create2DWorkspaceWithReflectometryInstrumentMultiDetector( double startX, const double detSize) { Instrument_sptr instrument = boost::make_shared<Instrument>(); @@ -704,8 +704,7 @@ EventWorkspace_sptr createEventWorkspace(int numPixels, int numBins, int start_at_pixelID) { return createEventWorkspaceWithStartTime( numPixels, numBins, numEvents, x0, binDelta, eventPattern, - start_at_pixelID, - DateAndTimeHelpers::createFromISO8601("2010-01-01T00:00:00")); + start_at_pixelID, DateAndTime("2010-01-01T00:00:00")); } /** @@ -1237,17 +1236,17 @@ RebinnedOutput_sptr createRebinnedOutputWorkspace() { } /** - * Populates the destination array (usually a mutable histogram) - * starting at the index specified with the doubles provided in an - * initializer list. Note the caller is responsible for ensuring - * the destination has capacity for startingIndex + size(initializer list) - * number of values - * - * @param destination :: The array to populate with data - * @param startingIndex :: The index to start populating data at - * @param values :: The initializer list to populate the array with - * starting at the index specified - */ + * Populates the destination array (usually a mutable histogram) + * starting at the index specified with the doubles provided in an + * initializer list. Note the caller is responsible for ensuring + * the destination has capacity for startingIndex + size(initializer list) + * number of values + * + * @param destination :: The array to populate with data + * @param startingIndex :: The index to start populating data at + * @param values :: The initializer list to populate the array with + * starting at the index specified + */ template <typename T> void populateWsWithInitList(T &destination, size_t startingIndex, const std::initializer_list<double> &values) { diff --git a/Framework/Types/CMakeLists.txt b/Framework/Types/CMakeLists.txt index 186e5973f40..bcdf464a7d9 100644 --- a/Framework/Types/CMakeLists.txt +++ b/Framework/Types/CMakeLists.txt @@ -1,18 +1,20 @@ # This is not a module, there are no source files. Types in this folder must be header-only! -set ( SRC_FILES - src/DateAndTime.cpp - src/TofEvent.cpp + +set ( SRC_FILES + src/Core/DateAndTime.cpp + src/Event/TofEvent.cpp ) + set ( INC_FILES - inc/MantidTypes/DateAndTime.h + inc/MantidTypes/Core/DateAndTime.h inc/MantidTypes/DllConfig.h inc/MantidTypes/SpectrumDefinition.h - inc/MantidTypes/TofEvent.h + inc/MantidTypes/Event/TofEvent.h ) set ( TEST_FILES - DateAndTimeTest.h SpectrumDefinitionTest.h + DateAndTimeTest.h TofEventTest.h ) @@ -24,14 +26,12 @@ endif() add_library ( Types ${SRC_FILES} ${INC_FILES} ) -# Set the name of the generated library set_target_properties ( Types PROPERTIES OUTPUT_NAME MantidTypes - COMPILE_DEFINITIONS "IN_MANTID_TYPES" ) + COMPILE_DEFINITIONS "IN_MANTID_TYPES;PSAPI_VERSION=1" ) -# Add to the 'Framework' group in VS set_property ( TARGET Types PROPERTY FOLDER "MantidFramework" ) - -target_link_libraries ( Types LINK_PUBLIC ${Boost_LIBRARIES} ) + +target_link_libraries(Types LINK_PUBLIC ${Boost_LIBRARIES}) # Add the unit tests directory add_subdirectory ( test ) diff --git a/Framework/Types/inc/MantidTypes/DateAndTime.h b/Framework/Types/inc/MantidTypes/Core/DateAndTime.h similarity index 79% rename from Framework/Types/inc/MantidTypes/DateAndTime.h rename to Framework/Types/inc/MantidTypes/Core/DateAndTime.h index 057d904f62d..c57446ca1d3 100644 --- a/Framework/Types/inc/MantidTypes/DateAndTime.h +++ b/Framework/Types/inc/MantidTypes/Core/DateAndTime.h @@ -13,9 +13,9 @@ namespace Mantid { namespace Types { - +namespace Core { /// Durations and time intervals -typedef boost::posix_time::time_duration time_duration; +using time_duration = boost::posix_time::time_duration; //============================================================================================= /** Class for holding the date and time in Mantid. @@ -27,9 +27,27 @@ typedef boost::posix_time::time_duration time_duration; * * @author Janik Zikovsky, SNS * @date November 12, 2010 - * - * - * */ + Copyright © 2017-18 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge + National Laboratory & European Spallation Source + + This file is part of Mantid. + + Mantid is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + Mantid is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + File change history is stored at: <https://github.com/mantidproject/mantid>. + Code Documentation is available at: <http://doxygen.mantidproject.org> +*/ // Make the compiler pack the data size aligned to 1-byte, to use as little // space as possible @@ -110,6 +128,7 @@ public: static int64_t nanosecondsFromDuration(const time_duration &td); static int64_t nanosecondsFromSeconds(double sec); static time_duration durationFromNanoseconds(int64_t dur); + static const DateAndTime &defaultTime(); static void createVector(const DateAndTime start, const std::vector<double> &seconds, std::vector<DateAndTime> &out); @@ -130,8 +149,8 @@ private: int64_t _nanoseconds; }; #pragma pack(pop) - +} // namespace Core } // namespace Types } // namespace Mantid -#endif // MANTID_TYPES_DATE_AND_TIME_H +#endif //MANTID_TYPES_DATE_AND_TIME_H \ No newline at end of file diff --git a/Framework/Types/inc/MantidTypes/DllConfig.h b/Framework/Types/inc/MantidTypes/DllConfig.h index 0eeeb53d64c..7487e09362e 100644 --- a/Framework/Types/inc/MantidTypes/DllConfig.h +++ b/Framework/Types/inc/MantidTypes/DllConfig.h @@ -2,6 +2,9 @@ #define MANTID_TYPES_DLLCONFIG_H_ /* +This file contains the DLLExport/DLLImport linkage configuration for the +Types library + @author Lamar Moore, STFC Copyright © 2017 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge @@ -34,4 +37,4 @@ Code Documentation is available at: <http://doxygen.mantidproject.org> #define EXTERN_MANTID_TYPES extern #endif /* IN_MANTID_KERNEL*/ -#endif // MANTID_TYPES_DLLCONFIG_H_ +#endif // MANTID_KERNEL_DLLCONFIG_H_ diff --git a/Framework/Types/inc/MantidTypes/TofEvent.h b/Framework/Types/inc/MantidTypes/Event/TofEvent.h similarity index 67% rename from Framework/Types/inc/MantidTypes/TofEvent.h rename to Framework/Types/inc/MantidTypes/Event/TofEvent.h index fc23fcafbd9..fc4bbe4da6b 100644 --- a/Framework/Types/inc/MantidTypes/TofEvent.h +++ b/Framework/Types/inc/MantidTypes/Event/TofEvent.h @@ -1,39 +1,36 @@ #ifndef MANTID_TYPES_TOFEVENT_H #define MANTID_TYPES_TOFEVENT_H -#include "MantidTypes/DateAndTime.h" +#include "MantidTypes/Core/DateAndTime.h" +#include "MantidTypes/DllConfig.h" namespace Mantid { namespace DataObjects { class EventList; class WeightedEvent; class WeightedEventNoTime; -class tofGreaterOrEqual; -class tofGreater; } // namespace DataObjects - namespace DataHandling { class LoadEventNexus; } namespace Types { -//========================================================================================== -/** Info about a single neutron detection event: - * - * - the time of flight of the neutron (can be converted to other units) - * - the absolute time of the pulse at which it was produced - */ +namespace Event { + //========================================================================================== + /** Info about a single neutron detection event: + * + * - the time of flight of the neutron (can be converted to other units) + * - the absolute time of the pulse at which it was produced + */ #pragma pack(push, 4) // Ensure the structure is no larger than it needs to -class _declspec(dllexport) TofEvent { +class MANTID_TYPES_DLL TofEvent { /// EventList has the right to mess with TofEvent. - friend class Mantid::DataObjects::EventList; - friend class Mantid::DataObjects::WeightedEvent; - friend class Mantid::DataObjects::WeightedEventNoTime; - friend class Mantid::DataObjects::tofGreaterOrEqual; - friend class Mantid::DataObjects::tofGreater; - friend class Mantid::DataHandling::LoadEventNexus; // Needed while the ISIS - // hack of spreading events - // out in a bin remains + friend class DataObjects::EventList; + friend class DataObjects::WeightedEvent; + friend class DataObjects::WeightedEventNoTime; + friend class DataHandling::LoadEventNexus; // Needed while the ISIS hack of + // spreading events out in a bin + // remains protected: /** The 'x value' of the event. This will be in a unit available from the @@ -53,7 +50,7 @@ protected: * 64 bits gives 1 ns resolution up to +- 292 years around 1990. Should be *enough. */ - DateAndTime m_pulsetime; + Core::DateAndTime m_pulsetime; public: /// Constructor, specifying only the time of flight in microseconds @@ -61,7 +58,7 @@ public: /// Constructor, specifying the time of flight in microseconds and the frame /// id - TofEvent(double tof, const Mantid::Types::DateAndTime pulsetime); + TofEvent(double tof, const Core::DateAndTime pulsetime); /// Empty constructor TofEvent(); @@ -75,7 +72,7 @@ public: double operator()() const; double tof() const; - Mantid::Types::DateAndTime pulseTime() const; + Mantid::Types::Core::DateAndTime pulseTime() const; double weight() const; double error() const; double errorSquared() const; @@ -90,19 +87,19 @@ public: //========================================================================================== /** () operator: return the tof (X value) of the event. - * This is useful for std operations like comparisons and std::lower_bound - * @return :: double, the tof (X value) of the event. - */ +* This is useful for std operations like comparisons and std::lower_bound +* @return :: double, the tof (X value) of the event. +*/ inline double TofEvent::operator()() const { return m_tof; } /** @return The 'x value'. Despite the name, this can be in any unit in the - * UnitFactory. - * If it is time-of-flight, it will be in microseconds. - */ +* UnitFactory. +* If it is time-of-flight, it will be in microseconds. +*/ inline double TofEvent::tof() const { return m_tof; } /// Return the pulse time -inline Mantid::Types::DateAndTime TofEvent::pulseTime() const { +inline Core::DateAndTime TofEvent::pulseTime() const { return m_pulsetime; } @@ -114,6 +111,7 @@ inline double TofEvent::error() const { return 1.0; } /// Return the errorSquared of the event - exactly 1.0 always inline double TofEvent::errorSquared() const { return 1.0; } +} // namespace Event } // namespace Types } // namespace Mantid -#endif // MANTIS_TYPES_TOFEVENT_H +#endif // MANTID_TYPES_TOFEVENT_H \ No newline at end of file diff --git a/Framework/Types/src/DateAndTime.cpp b/Framework/Types/src/Core/DateAndTime.cpp similarity index 97% rename from Framework/Types/src/DateAndTime.cpp rename to Framework/Types/src/Core/DateAndTime.cpp index bb8f30d6de2..b21d27988eb 100644 --- a/Framework/Types/src/DateAndTime.cpp +++ b/Framework/Types/src/Core/DateAndTime.cpp @@ -1,27 +1,8 @@ -#include "MantidTypes/DateAndTime.h" - -#include <boost/date_time/date.hpp> -#include <boost/date_time/time.hpp> -#include <boost/lexical_cast.hpp> - -#include <cmath> -#include <exception> -#include <limits> -#include <memory> -#include <ostream> -#include <stdexcept> +#include "MantidTypes/Core/DateAndTime.h" namespace Mantid { namespace Types { - -const uint32_t DateAndTime::EPOCH_DIFF = 631152000; -/// The epoch for GPS times. -const boost::posix_time::ptime - DateAndTime::GPS_EPOCH(boost::gregorian::date(1990, 1, 1)); - -/// Const of one second time duration -const time_duration DateAndTime::ONE_SECOND = - boost::posix_time::time_duration(0, 0, 1, 0); +namespace Core { namespace { /// Max allowed nanoseconds in the time; 2^62-1 @@ -131,6 +112,16 @@ time_t DateAndTime::utc_mktime(struct tm *utctime) { return result; } +/// The epoch for GPS times. +boost::posix_time::ptime DateAndTime::GPS_EPOCH() { + return boost::posix_time::ptime(boost::gregorian::date(1990, 1, 1)); +} + +/// Const of one second time duration +time_duration DateAndTime::ONE_SECOND() { + return boost::posix_time::time_duration(0, 0, 1, 0); +} + //------------------------------------------------------------------------------------------------ /** Default, empty constructor */ DateAndTime::DateAndTime() : _nanoseconds(0) {} @@ -231,7 +222,7 @@ DateAndTime::DateAndTime(const int32_t seconds, const int32_t nanoseconds) { * @return a boost::posix_time::ptime. */ boost::posix_time::ptime DateAndTime::to_ptime() const { - return GPS_EPOCH + durationFromNanoseconds(_nanoseconds); + return GPS_EPOCH() + durationFromNanoseconds(_nanoseconds); } //------------------------------------------------------------------------------------------------ @@ -249,7 +240,7 @@ void DateAndTime::set_from_ptime(boost::posix_time::ptime _ptime) { if (_ptime.is_not_a_date_time()) _nanoseconds = MIN_NANOSECONDS; } else { - _nanoseconds = nanosecondsFromDuration(_ptime - GPS_EPOCH); + _nanoseconds = nanosecondsFromDuration(_ptime - GPS_EPOCH()); // Check for overflow if (_nanoseconds < 0) { @@ -362,6 +353,12 @@ DateAndTime DateAndTime::maximum() { return DateAndTime(MAX_NANOSECONDS); } /** Return the minimum time possible */ DateAndTime DateAndTime::minimum() { return DateAndTime(MIN_NANOSECONDS); } +/// A default date and time to use when time is not specified +const DateAndTime &DateAndTime::defaultTime() { + static DateAndTime time("1970-01-01T00:00:00"); + return time; +} + //------------------------------------------------------------------------------------------------ /** Sets the date and time using an ISO8601-formatted string * @@ -860,7 +857,6 @@ std::ostream &operator<<(std::ostream &stream, const DateAndTime &t) { stream << t.toSimpleString(); return stream; } - +} // namespace Core } // namespace Types - -} // namespace Mantid +} // namespace Mantid \ No newline at end of file diff --git a/Framework/Types/src/TofEvent.cpp b/Framework/Types/src/Event/TofEvent.cpp similarity index 96% rename from Framework/Types/src/TofEvent.cpp rename to Framework/Types/src/Event/TofEvent.cpp index 7e264e0636e..723b7d67d41 100644 --- a/Framework/Types/src/TofEvent.cpp +++ b/Framework/Types/src/Event/TofEvent.cpp @@ -1,9 +1,11 @@ -#include "MantidTypes/TofEvent.h" +#include "MantidTypes/Event/TofEvent.h" using std::ostream; namespace Mantid { namespace Types { +using Core::DateAndTime; +namespace Event { //========================================================================== /// --------------------- TofEvent stuff ---------------------------------- //========================================================================== @@ -77,6 +79,6 @@ ostream &operator<<(ostream &os, const TofEvent &event) { os << event.m_tof << "," << event.m_pulsetime.toSimpleString(); return os; } - +} // namespace Event } // namespace Types } // namespace Mantid \ No newline at end of file diff --git a/Framework/Types/test/CMakeLists.txt b/Framework/Types/test/CMakeLists.txt index 94dae528e4d..e89ea580b77 100644 --- a/Framework/Types/test/CMakeLists.txt +++ b/Framework/Types/test/CMakeLists.txt @@ -6,8 +6,7 @@ if ( CXXTEST_FOUND ) Types ${Boost_LIBRARIES} ${GMOCK_LIBRARIES} - ${GTEST_LIBRARIES} - ) + ${GTEST_LIBRARIES} ) add_dependencies ( FrameworkTests TypesTest ) # Add to the 'FrameworkTests' group in VS diff --git a/Framework/Types/test/DateAndTimeTest.h b/Framework/Types/test/DateAndTimeTest.h index 0b1fb452d1f..79cadc8061e 100644 --- a/Framework/Types/test/DateAndTimeTest.h +++ b/Framework/Types/test/DateAndTimeTest.h @@ -8,16 +8,14 @@ #ifndef DATEANDTIMETEST_H_ #define DATEANDTIMETEST_H_ -#include "MantidTypes/DateAndTime.h" +#include "MantidTypes/Core/DateAndTime.h" #include <cxxtest/TestSuite.h> #include <sstream> -#include <sys/stat.h> #include <time.h> using namespace Mantid; -using namespace Mantid::Types; +using namespace Types::Core; -using std::cout; using std::runtime_error; using std::size_t; using std::vector; @@ -25,7 +23,7 @@ using std::vector; //========================================================================================== class DateAndTimeTest : public CxxTest::TestSuite { public: - void test_constructors() { + void test_constructors_and_set() { // Expected will be Jan 2, 1990, at 00:01:02 boost::posix_time::ptime expected = boost::posix_time::from_iso_string(std::string("19900102T000102.345")); @@ -43,6 +41,22 @@ public: // ptime d = DateAndTime(expected); TS_ASSERT_EQUALS(d, expected); + + // string + d = DateAndTime("1990-01-02T00:01:02.345"); + TS_ASSERT_EQUALS(d, expected); + d.setFromISO8601("1990-01-02T00:01:02.345"); + TS_ASSERT_EQUALS(d, expected); + + // string with a space + d = DateAndTime("1990-01-02 00:01:02.345"); + TS_ASSERT_EQUALS(d, expected); + d.setFromISO8601("1990-01-02 00:01:02.345"); + TS_ASSERT_EQUALS(d, expected); + } + + void test_constructor_fails_invalid_string() { + TS_ASSERT_THROWS(DateAndTime("invalid time string"), std::invalid_argument); } void test_limits_on_construction() { @@ -67,6 +81,12 @@ public: a = DateAndTime(-li, li2); TS_ASSERT_EQUALS(a, DateAndTime::minimum()); + // String constructors + a = DateAndTime("2490-01-02 00:01:02.345"); + TS_ASSERT_EQUALS(a, DateAndTime::maximum()); + a = DateAndTime("1600-01-02 00:01:02.345"); + TS_ASSERT_EQUALS(a, DateAndTime::minimum()); + // ptime constructor boost::posix_time::ptime p; p = boost::posix_time::from_iso_string("24000102T000102"); @@ -79,6 +99,174 @@ public: // time_t and int constructors can't overflow on 32-bits at least } + void test_year_month_etc() { + DateAndTime a; + a = DateAndTime("1990-01-02 03:04:05.678"); + TS_ASSERT_EQUALS(a.year(), 1990); + TS_ASSERT_EQUALS(a.month(), 1); + TS_ASSERT_EQUALS(a.day(), 2); + TS_ASSERT_EQUALS(a.hour(), 3); + TS_ASSERT_EQUALS(a.minute(), 4); + TS_ASSERT_EQUALS(a.second(), 5); + TS_ASSERT_EQUALS(a.nanoseconds(), 678000000); + } + + void test_comparison_operators() { + DateAndTime a, b, c, d; + a = DateAndTime("1990-01-02 00:00:02.000"); + b = DateAndTime("1990-01-02 00:01:02.345"); + c = DateAndTime("1990-01-02 00:01:02.345"); + d = DateAndTime("1990-01-02 00:00:02.000000001"); + + TS_ASSERT(a < b); + TS_ASSERT(b > a); + TS_ASSERT(a <= b); + TS_ASSERT(b >= a); + TS_ASSERT(a == a); + TS_ASSERT(b == b); + TS_ASSERT(b == c); + TS_ASSERT(a != b); + // intentionally different to confirm the tolerance check works + TS_ASSERT(a != d); + TS_ASSERT(a.equals(d)); + + boost::posix_time::ptime p; + p = boost::posix_time::from_iso_string("19900102T000002.000"); + TS_ASSERT(a == p); + TS_ASSERT(b != p); + } + + void test_toFormattedString() { + DateAndTime a; + a = DateAndTime("1990-01-02 03:04:05.678"); + std::string s = a.toSimpleString(); + TS_ASSERT_EQUALS(s.substr(0, 20), "1990-Jan-02 03:04:05"); + TS_ASSERT_EQUALS(a.toFormattedString(), "1990-Jan-02 03:04:05"); + TS_ASSERT_EQUALS(a.toFormattedString("%Y-%m-%d"), "1990-01-02"); + TS_ASSERT_EQUALS(a.toISO8601String(), "1990-01-02T03:04:05.678000000"); + } + + void test_to_int64() { + DateAndTime a; + a = DateAndTime("1990-01-02 00:01:02.345"); + int64_t nanosec = a.totalNanoseconds(); + // 1day, 1 minute, 2 seconds, 0.345 seconds = 86462345000000 nanosec + TS_ASSERT_EQUALS(nanosec, int64_t(86462345000000LL)); + } + + void test_stream_operator() { + DateAndTime a; + std::ostringstream message; + a = DateAndTime("1990-01-02 03:04:05.678"); + message << a; + TS_ASSERT_EQUALS(message.str(), a.toSimpleString()); + std::ostringstream message2; + message2 << a << "\n"; + TS_ASSERT_EQUALS(message2.str(), a.toSimpleString() + "\n"); + } + + void test_subtraction_of_times() { + DateAndTime a, b, c; + boost::posix_time::ptime p; + time_duration td; + + a = DateAndTime("1990-01-02 00:01:02.345"); + b = DateAndTime("1990-01-02 00:00:02.000"); + td = a - b; + TS_ASSERT_EQUALS( + td, DateAndTime::durationFromNanoseconds(int64_t(60345000000LL))); + + a = DateAndTime("1990-01-02 00:01:02.345"); + p = boost::posix_time::from_iso_string("19900102T000002.000"); + // boost ptime gets converted to ptime implicitely + td = a - p; + TS_ASSERT_EQUALS( + td, DateAndTime::durationFromNanoseconds(int64_t(60345000000LL))); + } + + void test_subtraction_of_times_limits() { + DateAndTime a, b, c; + boost::posix_time::ptime p; + time_duration td; + + a = DateAndTime("2200-01-02 00:01:02.345"); + b = DateAndTime("1800-01-02 00:01:02.345"); + td = a - b; + // The difference won't be correct, but it is positive and ~2**62 + // nanoseconds + TS_ASSERT_LESS_THAN(4.6e9, DateAndTime::secondsFromDuration(td)); + + td = b - a; + // The difference won't be correct, but it is negative + TS_ASSERT_LESS_THAN(DateAndTime::secondsFromDuration(td), -4.6e9); + } + + void test_addition_and_subtraction_operators_nanoseconds_as_int() { + DateAndTime a, b, c; + a = DateAndTime("1990-01-02 00:00:02.000"); + b = DateAndTime("1990-01-02 00:01:02.345"); + c = a + int64_t(60345000000LL); + TS_ASSERT_EQUALS(c, b); + a += int64_t(60345000000LL); + TS_ASSERT_EQUALS(a, b); + + a = DateAndTime("1990-01-02 00:00:02.000"); + b = DateAndTime("1990-01-02 00:01:02.345"); + c = b - int64_t(60345000000LL); + TS_ASSERT_EQUALS(c, a); + b -= int64_t(60345000000LL); + TS_ASSERT_EQUALS(b, a); + } + + void test_addition_and_subtraction_operators_time_duration() { + DateAndTime a, b, c; + a = DateAndTime("1990-01-02 00:00:02.000"); + b = DateAndTime("1990-01-02 00:01:02.345"); + c = a + DateAndTime::durationFromNanoseconds(int64_t(60345000000LL)); + TS_ASSERT_EQUALS(c, b); + a += DateAndTime::durationFromNanoseconds(int64_t(60345000000LL)); + TS_ASSERT_EQUALS(a, b); + + a = DateAndTime("1990-01-02 00:00:02.000"); + b = DateAndTime("1990-01-02 00:01:02.345"); + c = b - DateAndTime::durationFromNanoseconds(int64_t(60345000000LL)); + TS_ASSERT_EQUALS(c, a); + b -= DateAndTime::durationFromNanoseconds(int64_t(60345000000LL)); + TS_ASSERT_EQUALS(b, a); + } + + void test_addition_and_subtraction_operators_double() { + DateAndTime a, b, c; + a = DateAndTime("1990-01-02 00:00:02.000"); + b = DateAndTime("1990-01-02 00:01:02.345"); + c = a + 60.345; + TS_ASSERT_EQUALS(c, b); + a += 60.345; + TS_ASSERT_EQUALS(a, b); + + a = DateAndTime("1990-01-02 00:00:02.000"); + b = DateAndTime("1990-01-02 00:01:02.345"); + c = b - 60.345; + TS_ASSERT_EQUALS(c, a); + b -= 60.345; + TS_ASSERT_EQUALS(b, a); + } + + void test_limits_on_addition_and_subtraction() { + DateAndTime a, b, c; + a = DateAndTime("1990-01-02 00:00:02.000"); + b = a + 1e20; + TS_ASSERT_EQUALS(b, DateAndTime::maximum()); + b = a - 1e20; + TS_ASSERT_LESS_THAN(b.year(), 1900); + + a = DateAndTime("1989-01-02 00:00:02.000"); + b = a - 1e20; + TS_ASSERT_EQUALS(b, DateAndTime::minimum()); + b = a + 1e20; + TS_ASSERT_LESS_THAN(2000, b.year()); + } + void test_dataSizes() { // Must occupy 8 bytes! TS_ASSERT_EQUALS(sizeof(DateAndTime), 8); @@ -118,8 +306,7 @@ public: timeinfo->tm_min = 0; timeinfo->tm_sec = 0; // Convert to time_t but assuming the tm is specified in UTC time. - std::time_t utc_time_t = - Mantid::Types::DateAndTimeHelpers::utc_mktime(timeinfo); + std::time_t utc_time_t = DateAndTime::utc_mktime(timeinfo); // This will be the local time std::time_t local_time_t = std::mktime(timeinfo); @@ -151,6 +338,43 @@ public: delete timeinfo; } + void test_ISO8601_string_with_timezones() { + // Time without timezone : UTC assumed + DateAndTime time_no_tz = DateAndTime("2010-03-24T14:12:51.562"); + DateAndTime time_no_fraction = DateAndTime("2010-03-24T14:12:51"); + + // The conversion should handle the fraction + TS_ASSERT_DELTA( + DateAndTime::secondsFromDuration(time_no_tz - time_no_fraction), 0.562, + 0.0005); + + // ZULU specified + DateAndTime time_z = DateAndTime("2010-03-24T14:12:51.562Z"); + // Positive time offset (also a fraction like Newfoundland (crazy newfies ;) + // ) + DateAndTime time_positive_tz = DateAndTime("2010-03-24T19:42:51.562+05:30"); + DateAndTime time_positive_tz2 = DateAndTime("2010-03-24T16:12:51.562+02"); + // Negative time offset + DateAndTime time_negative_tz = DateAndTime("2010-03-24T10:12:51.562-04:00"); + DateAndTime time_negative_tz2 = DateAndTime("2010-03-24T06:12:51.562-08"); + + // Now check the time zone difference + TS_ASSERT_DELTA(DateAndTime::secondsFromDuration(time_no_tz - time_z), 0.0, + 1e-4); + TS_ASSERT_DELTA( + DateAndTime::secondsFromDuration(time_no_tz - time_positive_tz), 0.0, + 1e-4); + TS_ASSERT_DELTA( + DateAndTime::secondsFromDuration(time_no_tz - time_negative_tz), 0.0, + 1e-4); + TS_ASSERT_DELTA( + DateAndTime::secondsFromDuration(time_no_tz - time_positive_tz2), 0.0, + 1e-4); + TS_ASSERT_DELTA( + DateAndTime::secondsFromDuration(time_no_tz - time_negative_tz2), 0.0, + 1e-4); + } + void testDurations() { time_duration onesec = time_duration(0, 0, 1, 0); TS_ASSERT_EQUALS(DateAndTime::secondsFromDuration(onesec), 1.0); @@ -180,8 +404,8 @@ public: } /* Ensure that exceptions thrown by boost date_time conversions are caught - where they - may cause problems. */ + where they + may cause problems. */ void testNotADateTime() { boost::posix_time::ptime time(boost::posix_time::not_a_date_time); DateAndTime dt(time); @@ -189,6 +413,17 @@ public: TS_ASSERT_THROWS_NOTHING(dt.to_tm()); } + void test_duration_limits() { + DateAndTime a, b, c, d; + time_duration td; + a = DateAndTime("2010-03-24T14:12:51.562"); + // Only about 290 years time difference are supported (2^63 nanoseconds)! + b = DateAndTime("2300-03-24T14:12:51.562"); + td = b - a; + c = a + td; + TS_ASSERT_EQUALS(c, b); + } + void test_duration_from_seconds_Extremes() { time_duration onesec = time_duration(0, 0, 1, 0); time_duration extreme; @@ -200,6 +435,19 @@ public: // Output value is negative TS_ASSERT_LESS_THAN(extreme, onesec); } + + void test_Vector() { + DateAndTime a = DateAndTime("1990-01-02 03:04:05.000"); + std::vector<double> secs{1.0, 2.0, 0.5, -3.0}; + + std::vector<DateAndTime> times; + DateAndTime::createVector(a, secs, times); + TS_ASSERT_EQUALS(times.size(), secs.size()); + TS_ASSERT_EQUALS(times[0], DateAndTime("1990-01-02 03:04:06.000")); + TS_ASSERT_EQUALS(times[1], DateAndTime("1990-01-02 03:04:07.000")); + TS_ASSERT_EQUALS(times[2], DateAndTime("1990-01-02 03:04:05.500")); + TS_ASSERT_EQUALS(times[3], DateAndTime("1990-01-02 03:04:02.000")); + } }; #endif /* DATEANDTIMETEST_H_ */ diff --git a/Framework/Types/test/TofEventTest.h b/Framework/Types/test/TofEventTest.h index 58f2529b470..13aa11ab6b3 100644 --- a/Framework/Types/test/TofEventTest.h +++ b/Framework/Types/test/TofEventTest.h @@ -1,11 +1,14 @@ #ifndef TOFEVENTTEST_H_ #define TOFEVENTTEST_H_ 1 +#include "MantidTypes/Event/TofEvent.h" +#include <cmath> #include <cxxtest/TestSuite.h> -#include "MantidTypes/TofEvent.h" -using namespace Mantid; -using namespace Mantid::Types; +using Mantid::Types::Event::TofEvent; + +using std::size_t; +using std::vector; //========================================================================================== class TofEventTest : public CxxTest::TestSuite { diff --git a/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp b/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp index 798c0bfd87e..17f13622d52 100644 --- a/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp +++ b/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp @@ -346,7 +346,7 @@ void AlignAndFocusPowder::exec() { if (tolerance > 0.) { g_log.information() << "running CompressEvents(Tolerance=" << tolerance << ") started at " - << Mantid::Types::DateAndTime::getCurrentTime() << "\n"; + << Types::Core::DateAndTime::getCurrentTime() << "\n"; API::IAlgorithm_sptr compressAlg = createChildAlgorithm("CompressEvents"); compressAlg->setProperty("InputWorkspace", m_outputEW); compressAlg->setProperty("OutputWorkspace", m_outputEW); @@ -369,7 +369,7 @@ void AlignAndFocusPowder::exec() { g_log.information() << "running CropWorkspace(TOFmin=" << xmin << ", TOFmax=" << xmax << ") started at " - << Mantid::Types::DateAndTime::getCurrentTime() << "\n"; + << Types::Core::DateAndTime::getCurrentTime() << "\n"; API::IAlgorithm_sptr cropAlg = createChildAlgorithm("CropWorkspace"); cropAlg->setProperty("InputWorkspace", m_outputW); cropAlg->setProperty("OutputWorkspace", m_outputW); @@ -390,7 +390,7 @@ void AlignAndFocusPowder::exec() { if (m_outputEW->getNumberEvents() > 0) { g_log.information() << "running RemovePromptPulse(Width=" << removePromptPulseWidth << ") started at " - << Mantid::Types::DateAndTime::getCurrentTime() << "\n"; + << Types::Core::DateAndTime::getCurrentTime() << "\n"; API::IAlgorithm_sptr filterPAlg = createChildAlgorithm("RemovePromptPulse"); filterPAlg->setProperty("InputWorkspace", m_outputW); @@ -407,7 +407,7 @@ void AlignAndFocusPowder::exec() { if (maskBinTableWS) { g_log.information() << "running MaskBinsFromTable started at " - << Mantid::Types::DateAndTime::getCurrentTime() << "\n"; + << Types::Core::DateAndTime::getCurrentTime() << "\n"; API::IAlgorithm_sptr alg = createChildAlgorithm("MaskBinsFromTable"); alg->setProperty("InputWorkspace", m_outputW); alg->setProperty("OutputWorkspace", m_outputW); @@ -420,7 +420,7 @@ void AlignAndFocusPowder::exec() { if (m_maskWS) { g_log.information() << "running MaskDetectors started at " - << Mantid::Types::DateAndTime::getCurrentTime() << "\n"; + << Types::Core::DateAndTime::getCurrentTime() << "\n"; API::IAlgorithm_sptr maskAlg = createChildAlgorithm("MaskDetectors"); maskAlg->setProperty("Workspace", m_outputW); maskAlg->setProperty("MaskedWorkspace", m_maskWS); @@ -437,7 +437,7 @@ void AlignAndFocusPowder::exec() { if (m_calibrationWS) { g_log.information() << "running AlignDetectors started at " - << Mantid::Types::DateAndTime::getCurrentTime() << "\n"; + << Types::Core::DateAndTime::getCurrentTime() << "\n"; API::IAlgorithm_sptr alignAlg = createChildAlgorithm("AlignDetectors"); alignAlg->setProperty("InputWorkspace", m_outputW); alignAlg->setProperty("OutputWorkspace", m_outputW); @@ -458,7 +458,7 @@ void AlignAndFocusPowder::exec() { if (LRef > 0.) { g_log.information() << "running UnwrapSNS(LRef=" << LRef << ",Tmin=" << tmin << ",Tmax=" << tmax << ") started at " - << Mantid::Types::DateAndTime::getCurrentTime() << "\n"; + << Types::Core::DateAndTime::getCurrentTime() << "\n"; API::IAlgorithm_sptr removeAlg = createChildAlgorithm("UnwrapSNS"); removeAlg->setProperty("InputWorkspace", m_outputW); removeAlg->setProperty("OutputWorkspace", m_outputW); @@ -489,7 +489,7 @@ void AlignAndFocusPowder::exec() { if (!isEmpty(maxwl)) g_log.information() << ", WavelengthMax=" << maxwl; g_log.information() << ") started at " - << Mantid::Types::DateAndTime::getCurrentTime() << "\n"; + << Types::Core::DateAndTime::getCurrentTime() << "\n"; API::IAlgorithm_sptr removeAlg = createChildAlgorithm("CropWorkspace"); removeAlg->setProperty("InputWorkspace", m_outputW); @@ -504,7 +504,7 @@ void AlignAndFocusPowder::exec() { } else if (DIFCref > 0.) { g_log.information() << "running RemoveLowResTof(RefDIFC=" << DIFCref << ",K=3.22) started at " - << Mantid::Types::DateAndTime::getCurrentTime() << "\n"; + << Types::Core::DateAndTime::getCurrentTime() << "\n"; EventWorkspace_sptr ews = boost::dynamic_pointer_cast<EventWorkspace>(m_outputW); if (ews) @@ -628,7 +628,7 @@ void AlignAndFocusPowder::exec() { if ((m_outputEW) && (tolerance > 0.)) { g_log.information() << "running CompressEvents(Tolerance=" << tolerance << ") started at " - << Mantid::Types::DateAndTime::getCurrentTime() << "\n"; + << Types::Core::DateAndTime::getCurrentTime() << "\n"; API::IAlgorithm_sptr compressAlg = createChildAlgorithm("CompressEvents"); compressAlg->setProperty("InputWorkspace", m_outputEW); compressAlg->setProperty("OutputWorkspace", m_outputEW); @@ -664,7 +664,7 @@ API::MatrixWorkspace_sptr AlignAndFocusPowder::editInstrument( std::vector<specnum_t> specids, std::vector<double> l2s, std::vector<double> phis) { g_log.information() << "running EditInstrumentGeometry started at " - << Mantid::Types::DateAndTime::getCurrentTime() << "\n"; + << Types::Core::DateAndTime::getCurrentTime() << "\n"; API::IAlgorithm_sptr editAlg = createChildAlgorithm("EditInstrumentGeometry"); editAlg->setProperty("Workspace", ws); @@ -696,7 +696,7 @@ AlignAndFocusPowder::diffractionFocus(API::MatrixWorkspace_sptr ws) { } g_log.information() << "running DiffractionFocussing started at " - << Mantid::Types::DateAndTime::getCurrentTime() << "\n"; + << Types::Core::DateAndTime::getCurrentTime() << "\n"; API::IAlgorithm_sptr focusAlg = createChildAlgorithm("DiffractionFocussing"); focusAlg->setProperty("InputWorkspace", ws); @@ -717,7 +717,7 @@ AlignAndFocusPowder::convertUnits(API::MatrixWorkspace_sptr matrixws, std::string target) { g_log.information() << "running ConvertUnits(Target=" << target << ") started at " - << Mantid::Types::DateAndTime::getCurrentTime() << "\n"; + << Types::Core::DateAndTime::getCurrentTime() << "\n"; API::IAlgorithm_sptr convert2Alg = createChildAlgorithm("ConvertUnits"); convert2Alg->setProperty("InputWorkspace", matrixws); @@ -741,7 +741,7 @@ AlignAndFocusPowder::rebin(API::MatrixWorkspace_sptr matrixws) { << ", LogBinning=" << (m_resampleX < 0) << ", dMin(" << m_dmins.size() << "), dmax(" << m_dmaxs.size() << ")) started at " - << Mantid::Types::DateAndTime::getCurrentTime() << "\n"; + << Types::Core::DateAndTime::getCurrentTime() << "\n"; API::IAlgorithm_sptr alg = createChildAlgorithm("ResampleX"); alg->setProperty("InputWorkspace", matrixws); alg->setProperty("OutputWorkspace", matrixws); @@ -766,7 +766,7 @@ AlignAndFocusPowder::rebin(API::MatrixWorkspace_sptr matrixws) { for (double param : m_params) g_log.information() << param << " "; g_log.information() << ") started at " - << Mantid::Types::DateAndTime::getCurrentTime() << "\n"; + << Types::Core::DateAndTime::getCurrentTime() << "\n"; API::IAlgorithm_sptr rebin3Alg = createChildAlgorithm("Rebin"); rebin3Alg->setProperty("InputWorkspace", matrixws); rebin3Alg->setProperty("OutputWorkspace", matrixws); diff --git a/MantidPlot/src/Mantid/AlgorithmHistoryWindow.cpp b/MantidPlot/src/Mantid/AlgorithmHistoryWindow.cpp index cb7000941a9..8f61f11ab68 100644 --- a/MantidPlot/src/Mantid/AlgorithmHistoryWindow.cpp +++ b/MantidPlot/src/Mantid/AlgorithmHistoryWindow.cpp @@ -88,7 +88,7 @@ AlgExecSummaryGrpBox::~AlgExecSummaryGrpBox() { } } void AlgExecSummaryGrpBox::setData(const double execDuration, - const Mantid::Types::DateAndTime execDate) { + const Mantid::Types::Core::DateAndTime execDate) { QString dur(""); dur.setNum(execDuration, 'g', 6); dur += " seconds"; @@ -319,7 +319,7 @@ AlgExecSummaryGrpBox *AlgorithmHistoryWindow::createExecSummaryGrpBox() { const auto entry = m_algHist.getAlgorithmHistory(i); double duration = 0; duration = entry->executionDuration(); - Mantid::Types::DateAndTime date = entry->executionDate(); + Mantid::Types::Core::DateAndTime date = entry->executionDate(); pgrpBox->setData(duration, date); } return pgrpBox; @@ -448,7 +448,7 @@ void AlgorithmHistoryWindow::updateExecSummaryGrpBox( AlgorithmHistory_const_sptr algHistory) { // getting the selcted algorithm at pos from History vector double duration = algHistory->executionDuration(); - Mantid::Types::DateAndTime date = algHistory->executionDate(); + Mantid::Types::Core::DateAndTime date = algHistory->executionDate(); if (m_execSumGrpBox) m_execSumGrpBox->setData(duration, date); } diff --git a/MantidPlot/src/Mantid/AlgorithmHistoryWindow.h b/MantidPlot/src/Mantid/AlgorithmHistoryWindow.h index ae19b720499..c928ce89d5c 100644 --- a/MantidPlot/src/Mantid/AlgorithmHistoryWindow.h +++ b/MantidPlot/src/Mantid/AlgorithmHistoryWindow.h @@ -5,7 +5,7 @@ #include "MantidAPI/HistoryView.h" #include "MantidAPI/ScriptBuilder.h" #include "MantidAPI/WorkspaceHistory.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/EnvironmentHistory.h" #include "MantidQtWidgets/Common/MantidDialog.h" @@ -91,7 +91,7 @@ public: AlgExecSummaryGrpBox(QString, QWidget *w); ~AlgExecSummaryGrpBox() override; void setData(const double execDuration, - const Mantid::Types::DateAndTime execDate); + const Mantid::Types::Core::DateAndTime execDate); private: QLineEdit *getAlgExecDurationCtrl() const { return m_execDurationEdit; } diff --git a/MantidPlot/src/Mantid/MantidUI.cpp b/MantidPlot/src/Mantid/MantidUI.cpp index c74cb6c6db7..bbdff7e0639 100644 --- a/MantidPlot/src/Mantid/MantidUI.cpp +++ b/MantidPlot/src/Mantid/MantidUI.cpp @@ -5,6 +5,7 @@ #include "AlgorithmHistoryWindow.h" #include "AlgorithmMonitor.h" #include "ImportWorkspaceDlg.h" +#include "MantidSurfaceContourPlotGenerator.h" #include "MantidMDCurve.h" #include "MantidMDCurveDialog.h" #include "MantidMatrix.h" @@ -13,30 +14,29 @@ #include "MantidQtWidgets/Common/MantidWSIndexDialog.h" #include "MantidSampleLogDialog.h" #include "MantidSampleMaterialDialog.h" -#include "MantidSurfaceContourPlotGenerator.h" #include "MantidTable.h" #include "MantidUI.h" #include "ProjectSerialiser.h" +#include "ui_SequentialFitDialog.h" #include "../Folder.h" #include "../ScriptingWindow.h" #include "../Spectrogram.h" #include "../TiledWindow.h" #include "MantidQtWidgets/Common/pixmaps.h" -#include "ui_SequentialFitDialog.h" T #include "Mantid/InstrumentWidget/InstrumentWindow.h" #include "MantidAPI/Axis.h" #include "MantidAPI/TextAxis.h" #include "MantidKernel/ConfigService.h" +#include "MantidKernel/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/EnvironmentHistory.h" #include "MantidKernel/FacilityInfo.h" #include "MantidKernel/LogFilter.h" #include "MantidKernel/Property.h" -#include "MantidKernel/TimeInterval.h" #include "MantidKernel/TimeSeriesProperty.h" #include "MantidKernel/UnitConversion.h" -#include "MantidTypes/DateAndTime.h" #include "InstrumentWidget/InstrumentWindow.h" @@ -66,6 +66,8 @@ #include <QMenu> #include <QMenuBar> #include <QMessageBox> +#include <QMessageBox> +#include <QTextEdit> #include <QTextEdit> #include <QToolBar> @@ -100,9 +102,10 @@ using namespace std; using namespace Mantid::API; using namespace MantidQt::API; using namespace MantidQt::MantidWidgets; -using Mantid::Types::DateAndTime; -using MantidQt::MantidWidgets::MantidTreeWidget; using MantidQt::MantidWidgets::MantidWSIndexDialog; +using MantidQt::MantidWidgets::MantidTreeWidget; +using Mantid::Types::Core::DateAndTime; +using Mantid::Types::Core::time_duration; using MantidQt::SliceViewer::SliceViewerWindow; namespace MantidException = Mantid::Kernel::Exception; @@ -204,7 +207,7 @@ getWorkspacesFromAds(const QList<QString> &workspaceNames) { } return workspaces; } -} // namespace +} MantidUI::MantidUI(ApplicationWindow *aw) : m_finishedLoadDAEObserver(*this, @@ -288,12 +291,11 @@ MantidUI::MantidUI(ApplicationWindow *aw) SLOT(algorithmStarted(void *)), Qt::QueuedConnection); connect(m_algMonitor, SIGNAL(algorithmFinished(void *)), m_exploreAlgorithms, SLOT(algorithmFinished(void *)), Qt::QueuedConnection); - connect( - m_algMonitor, - SIGNAL(needUpdateProgress(void *, double, const QString &, double, int)), - m_exploreAlgorithms, - SLOT(updateProgress(void *, double, const QString &, double, int)), - Qt::QueuedConnection); + connect(m_algMonitor, SIGNAL(needUpdateProgress( + void *, double, const QString &, double, int)), + m_exploreAlgorithms, + SLOT(updateProgress(void *, double, const QString &, double, int)), + Qt::QueuedConnection); m_algMonitor->start(); @@ -326,9 +328,8 @@ void MantidUI::init() { connect(m_defaultFitFunction, SIGNAL(executeFit(QString, QHash<QString, QString>, Mantid::API::AlgorithmObserver *)), - this, - SLOT(showAlgorithmDialog(QString, QHash<QString, QString>, - Mantid::API::AlgorithmObserver *))); + this, SLOT(showAlgorithmDialog(QString, QHash<QString, QString>, + Mantid::API::AlgorithmObserver *))); m_defaultFitFunction->hide(); m_appWindow->addDockWidget(Qt::LeftDockWidgetArea, m_defaultFitFunction); @@ -380,9 +381,10 @@ void MantidUI::showFitPropertyBrowser(bool on) { } /** - * Be careful where this is called, if it is a called too late in the Qt - * shutdown the application crashes - */ +* Be careful where this is called, if it is a called too late in the Qt shutdown +* the application +* crashes +*/ void MantidUI::shutdown() { g_log.notice("MantidPlot is shutting down..."); @@ -457,17 +459,17 @@ QStringList MantidUI::getAlgorithmNames() { } /** - * Returns the number of algorithms currently executing - */ +* Returns the number of algorithms currently executing +*/ int MantidUI::runningAlgCount() const { return m_algMonitor->count(); } /** - * Alerts applicationWindow that the ADS has been modified. - */ +* Alerts applicationWindow that the ADS has been modified. +*/ void MantidUI::updateProject() { m_appWindow->modifiedProject(); } /** - * Ticket #678 - */ +* Ticket #678 +*/ void MantidUI::saveNexusWorkspace() { executeSaveNexus(); } /** @@ -544,7 +546,7 @@ MantidUI::getWorkspace(const QString &workspaceName) { } /** Extension to ApplicationWindow::menuAboutToShow() to deal with Mantid. - */ +*/ bool MantidUI::menuAboutToShow(MdiSubWindow *w) { if (w && isOfType(w, "MantidMatrix")) { @@ -653,14 +655,14 @@ void MantidUI::importWorkspace(const QString &wsName, bool showDlg, } /** Import the selected workspace, if any. Displays the import dialog. - */ +*/ void MantidUI::importWorkspace() { QString wsName = getSelectedWorkspaceName(); importWorkspace(wsName, true, true); } /** Import the selected table workspace transposed. - */ +*/ void MantidUI::importTransposed() { ScopedOverrideCursor waitCursor; QString wsName = getSelectedWorkspaceName(); @@ -673,7 +675,7 @@ void MantidUI::importTransposed() { } /** Create a TableWorkspace of box data from the MDEventWorkspace - */ +*/ void MantidUI::importBoxDataTable() { std::cout << "MantidUI::importBoxDataTable()\n"; QString wsName = getSelectedWorkspaceName(); @@ -695,9 +697,9 @@ void MantidUI::importBoxDataTable() { } /** Plots a Curve showing intensities for a MDWorkspace. - * But only if the workspace meets certain criteria, such as - * having only one non-integrated dimension. Should exit gracefully otherwise. - */ +* But only if the workspace meets certain criteria, such as +* having only one non-integrated dimension. Should exit gracefully otherwise. +*/ void MantidUI::showMDPlot() { QString wsName = getSelectedWorkspaceName(); @@ -956,8 +958,8 @@ void MantidUI::showSpectrumViewer() { } /** Create a window with a SliceViewer widget to show - * the selected workspace - */ +* the selected workspace +*/ void MantidUI::showSliceViewer() { // Retrieve the MDWorkspace QString wsName = getSelectedWorkspaceName(); @@ -1212,8 +1214,8 @@ Table *MantidUI::createTableDetectors(MantidMatrix *m) { } /** - * Show the detector table - this method is here for the Python interface - */ +* Show the detector table - this method is here for the Python interface +*/ Table *MantidUI::createDetectorTable(const QString &wsName) { std::vector<int> indices; Table *t = createDetectorTable(wsName, indices); @@ -1221,14 +1223,14 @@ Table *MantidUI::createDetectorTable(const QString &wsName) { } /** - * Create the relevant detector table for the given workspace - * @param wsName :: The name of the workspace - * @param indices :: Limit the table to these workspace indices (MatrixWorkspace - * only). If the vector is empty, - * all the indices are used. - * @param include_data :: If true then first value from the each spectrum is - * displayed (MatrixWorkspace only) - */ +* Create the relevant detector table for the given workspace +* @param wsName :: The name of the workspace +* @param indices :: Limit the table to these workspace indices (MatrixWorkspace +* only). If the vector is empty, +* all the indices are used. +* @param include_data :: If true then first value from the each spectrum is +* displayed (MatrixWorkspace only) +*/ Table *MantidUI::createDetectorTable(const QString &wsName, const std::vector<int> &indices, bool include_data) { @@ -1248,13 +1250,13 @@ Table *MantidUI::createDetectorTable(const QString &wsName, } /** - * Create the instrument detector table from a MatrixWorkspace - * @param wsName :: The name of the workspace - * @param ws :: A pointer to a MatrixWorkspace - * @param indices :: Limit the table to these workspace indices - * @param include_data :: If true then first value from the each spectrum is - * displayed - */ +* Create the instrument detector table from a MatrixWorkspace +* @param wsName :: The name of the workspace +* @param ws :: A pointer to a MatrixWorkspace +* @param indices :: Limit the table to these workspace indices +* @param include_data :: If true then first value from the each spectrum is +* displayed +*/ Table *MantidUI::createDetectorTable( const QString &wsName, const Mantid::API::MatrixWorkspace_sptr &ws, const std::vector<int> &indices, bool include_data) { @@ -1354,11 +1356,11 @@ Table *MantidUI::createDetectorTable( throw std::runtime_error("No detectors found."); if (!signedThetaParamRetrieved) { const std::vector<std::string> ¶meters = - spectrumInfo.detector(wsIndex).getStringParameter( - "show-signed-theta", true); // recursive - showSignedTwoTheta = - (!parameters.empty() && find(parameters.begin(), parameters.end(), - "Always") != parameters.end()); + spectrumInfo.detector(wsIndex) + .getStringParameter("show-signed-theta", true); // recursive + showSignedTwoTheta = (!parameters.empty() && + find(parameters.begin(), parameters.end(), + "Always") != parameters.end()); signedThetaParamRetrieved = true; } @@ -1473,11 +1475,11 @@ Table *MantidUI::createDetectorTable( } /** - * Creates a table showing the detectors contributing to the peaks within a - * PeaksWorkspace - * @param wsName :: The name of the workspace - * @param ws :: A pointer to an IPeaksWorkspace object - */ +* Creates a table showing the detectors contributing to the peaks within a +* PeaksWorkspace +* @param wsName :: The name of the workspace +* @param ws :: A pointer to an IPeaksWorkspace object +*/ Table * MantidUI::createDetectorTable(const QString &wsName, const Mantid::API::IPeaksWorkspace_sptr &ws) { @@ -1633,11 +1635,11 @@ void MantidUI::executeSaveNexus() { //----------------------------------------------------------------------------- /** Open an algorithm dialog to execute the named algorithm. - * - * @param algName :: name of the algorithm - * @param version :: version number, -1 for latest - * @return true if sucessful. - */ +* +* @param algName :: name of the algorithm +* @param version :: version number, -1 for latest +* @return true if sucessful. +*/ void MantidUI::showAlgorithmDialog(const QString &algName, int version) { Mantid::API::IAlgorithm_sptr alg = this->createAlgorithm(algName, version); if (!alg) @@ -1657,15 +1659,16 @@ void MantidUI::showAlgorithmDialog(const QString &algName, int version) { } /** - * Execute an algorithm. Show the algorithm dialog before executing. The - * property widgets will be preset with values in paramList. - * @param algName :: The algorithm name - * @param paramList :: A list of algorithm properties to be passed to - * Algorithm::setProperties - * @param obs :: A pointer to an instance of AlgorithmObserver which will be - * attached to the finish notification - * @param version :: version number, -1 for latest - */ +* Execute an algorithm. Show the algorithm dialog before executing. The property +* widgets will be preset +* with values in paramList. +* @param algName :: The algorithm name +* @param paramList :: A list of algorithm properties to be passed to +* Algorithm::setProperties +* @param obs :: A pointer to an instance of AlgorithmObserver which will be +* attached to the finish notification +* @param version :: version number, -1 for latest +*/ void MantidUI::showAlgorithmDialog(const QString &algName, QHash<QString, QString> paramList, Mantid::API::AlgorithmObserver *obs, @@ -1698,17 +1701,17 @@ void MantidUI::showAlgorithmDialog(const QString &algName, } /** - * Slot for executing an algorithm. - * @param alg :: Shared pointer to an algorithm to execute with all properties - * already set. - */ +* Slot for executing an algorithm. +* @param alg :: Shared pointer to an algorithm to execute with all properties +* already set. +*/ void MantidUI::executeAlgorithm(Mantid::API::IAlgorithm_sptr alg) { executeAlgorithmAsync(alg); } /** - * This creates an algorithm dialog (the default property entry thingie). - */ +* This creates an algorithm dialog (the default property entry thingie). +*/ MantidQt::API::AlgorithmDialog * MantidUI::createAlgorithmDialog(Mantid::API::IAlgorithm_sptr alg) { QHash<QString, QString> presets; @@ -1749,9 +1752,9 @@ MantidUI::createAlgorithmDialog(Mantid::API::IAlgorithm_sptr alg) { } /** - * Find the first input workspace for an algorithm - * @param algorithm :: A pointer to the algorithm instance - */ +* Find the first input workspace for an algorithm +* @param algorithm :: A pointer to the algorithm instance +*/ QString MantidUI::findInputWorkspaceProperty( Mantid::API::IAlgorithm_sptr algorithm) const { // Iterate through the properties and find the first input one @@ -1786,11 +1789,10 @@ void MantidUI::copyWorkspacestoVector( } /** - * Determine if the workspace has one or more UB matrixes on one of it's - * samples. - * @param wsName - * @return True if present - */ +* Determine if the workspace has one or more UB matrixes on one of it's samples. +* @param wsName +* @return True if present +*/ bool MantidUI::hasUB(const QString &wsName) { const std::string algName("HasUB"); Mantid::API::IAlgorithm_sptr alg; @@ -1816,9 +1818,9 @@ bool MantidUI::hasUB(const QString &wsName) { } /** - * Clears the UB from the selected workspace - * @param wsName :: selected workspace name - */ +* Clears the UB from the selected workspace +* @param wsName :: selected workspace name +*/ void MantidUI::clearUB(const QStringList &wsName) { const std::string algName("ClearUB"); const int version = -1; @@ -1843,9 +1845,9 @@ void MantidUI::clearUB(const QStringList &wsName) { } /** - * Renames selected workspace - * @param wsName :: selected workspace name - */ +* Renames selected workspace +* @param wsName :: selected workspace name +*/ void MantidUI::renameWorkspace(QStringList wsName) { // If the wsname is blank look for an active window and assume this workspace // is @@ -2010,9 +2012,9 @@ bool MantidUI::executeAlgorithmAsync(Mantid::API::IAlgorithm_sptr alg, } /** - * Slot to update the recent files list (from main appWindow) when accepting - * LoadDialog dialogs - */ +* Slot to update the recent files list (from main appWindow) when accepting +* LoadDialog dialogs +*/ void MantidUI::loadFileDialogAccept() { QObject *sender = QObject::sender(); MantidQt::API::AlgorithmDialog *dlg = @@ -2098,14 +2100,13 @@ void MantidUI::manageMantidWorkspaces() { } /** Create an instrument window from a named workspace. - * The window will be returned hidden. - * @param wsName The name of the workspace for which to generate the instrument - * view. - * @param tab The index of the tab (starting from 0) to initially display - * (default: 0) - * @return A pointer to the instrument window widget if created. NULL - * otherwise. - */ +* The window will be returned hidden. +* @param wsName The name of the workspace for which to generate the instrument +* view. +* @param tab The index of the tab (starting from 0) to initially display +* (default: 0) +* @return A pointer to the instrument window widget if created. NULL otherwise. +*/ InstrumentWindow *MantidUI::getInstrumentView(const QString &wsName, int tab) { if (!Mantid::API::AnalysisDataService::Instance().doesExist( wsName.toStdString())) @@ -2247,8 +2248,8 @@ void MantidUI::enableSaveNexus(const QString &wsName) { void MantidUI::disableSaveNexus() { appWindow()->disableSaveNexus(); } /** - * Prepares the Mantid Menu depending on the state of the active MantidMatrix. - */ +* Prepares the Mantid Menu depending on the state of the active MantidMatrix. +*/ void MantidUI::menuMantidMatrixAboutToShow() { menuMantidMatrix->clear(); MantidMatrix *w = dynamic_cast<MantidMatrix *>(appWindow()->activeWindow()); @@ -2317,16 +2318,16 @@ MultiLayer *MantidUI::plotInstrumentSpectrumList(const QString &wsName, } /** - * Sets the flag that tells the scripting environment that - * a script is currently running - */ +* Sets the flag that tells the scripting environment that +* a script is currently running +*/ void MantidUI::setIsRunning(bool) { // deprecated } /** - * Merge the curves from the two given MultiLayer objects - */ +* Merge the curves from the two given MultiLayer objects +*/ MultiLayer *MantidUI::mergePlots(MultiLayer *mlayer_1, MultiLayer *mlayer_2) { if (!mlayer_1) return NULL; @@ -2391,20 +2392,20 @@ bool MantidUI::createScriptInputDialog(const QString &alg_name, } /** Displays a string in a Qtiplot table - * @param logName :: the title of the table is based on this - * @param data :: the string to display - */ +* @param logName :: the title of the table is based on this +* @param data :: the string to display +*/ void MantidUI::importString(const QString &logName, const QString &data) { importString(logName, data, QString("")); } /** Displays a string in a Qtiplot table - * @param logName :: the title of the table is based on this - * @param data :: the string to display - * @param sep :: the seperator character - * @param wsName :: add workspace name to the table window title bar, defaults - * to logname if left blank - */ +* @param logName :: the title of the table is based on this +* @param data :: the string to display +* @param sep :: the seperator character +* @param wsName :: add workspace name to the table window title bar, defaults +* to logname if left blank +*/ void MantidUI::importString(const QString &logName, const QString &data, const QString &sep, const QString &wsName) { QStringList loglines = QStringList(data); @@ -2439,11 +2440,11 @@ void MantidUI::importString(const QString &logName, const QString &data, t->showNormal(); } /** Displays a string in a Qtiplot table - * @param logName :: the title of the table is based on this - * @param data :: a formatted string with the time series data to display - * @param wsName :: add workspace name to the table window title bar, defaults - * to logname if left blank - */ +* @param logName :: the title of the table is based on this +* @param data :: a formatted string with the time series data to display +* @param wsName :: add workspace name to the table window title bar, defaults +* to logname if left blank +*/ void MantidUI::importStrSeriesLog(const QString &logName, const QString &data, const QString &wsName) { QStringList loglines = data.split("\n", QString::SkipEmptyParts); @@ -2493,22 +2494,22 @@ void MantidUI::importStrSeriesLog(const QString &logName, const QString &data, //------------------------------------------------------------------------------------------------ /** Import a numeric log data. It will be shown in a graph and copied into a - * table - * @param wsName :: The workspace name which log data will be imported - * @param logName :: The name of the log property to import - * @param filter :: Filter flag telling how to filter the log data. - * - 0 means no filtering - * - 1 filter by running status - * - 2 filter by period - * - 3 filter by status & period - */ +* table +* @param wsName :: The workspace name which log data will be imported +* @param logName :: The name of the log property to import +* @param filter :: Filter flag telling how to filter the log data. +* - 0 means no filtering +* - 1 filter by running status +* - 2 filter by period +* - 3 filter by status & period +*/ void MantidUI::importNumSeriesLog(const QString &wsName, const QString &logName, int filter) { // if you need to add a final filter value to the end of the filter to match // the extent of the data, then set this to the index of the row to add the // value int addFinalFilterValueIndex = 0; - DateAndTime lastFilterTime; + Mantid::Types::Core::DateAndTime lastFilterTime; // Convert input int into enum value const Mantid::API::LogFilterGenerator::FilterType filterType = [&filter]() { @@ -2558,7 +2559,7 @@ void MantidUI::importNumSeriesLog(const QString &wsName, const QString &logName, formatLogName(label, wsName); // Get the starting time of the log. - DateAndTime startTime; + Mantid::Types::Core::DateAndTime startTime; // Toggle to switch between using the real date or the change in seconds. bool useAbsoluteDate = false; @@ -2652,7 +2653,7 @@ void MantidUI::importNumSeriesLog(const QString &wsName, const QString &logName, } // end (valid filter exists) } - Mantid::Types::DateAndTime lastTime; + Mantid::Types::Core::DateAndTime lastTime; double lastValue = 0; // Iterate through the time-value map. @@ -2726,7 +2727,7 @@ void MantidUI::importNumSeriesLog(const QString &wsName, const QString &logName, // Set x-axis label format if (useAbsoluteDate) { - Mantid::Types::DateAndTime label_as_ptime = + Mantid::Types::Core::DateAndTime label_as_ptime = flt->data()->nthInterval(0).begin(); QDateTime dt = QDateTime::fromTime_t(uint(label_as_ptime.to_localtime_t())); QString format = dt.toString(Qt::ISODate) + ";HH:mm:ss"; @@ -2781,17 +2782,16 @@ void MantidUI::configModified() { appWindow()->isDeleteWorkspacePromptEnabled()); } -std::string MantidUI::extractLogTime(Mantid::Types::DateAndTime value, - bool useAbsoluteDate, - Mantid::Types::DateAndTime start) { +std::string MantidUI::extractLogTime(DateAndTime value, bool useAbsoluteDate, + DateAndTime start) { std::string time_string; if (useAbsoluteDate) { // Convert time into string time_string = value.toSimpleString(); } else { // How many seconds elapsed? - Mantid::Types::time_duration elapsed = value - start; - double seconds = Mantid::Types::DateAndTime::secondsFromDuration(elapsed); + time_duration elapsed = value - start; + double seconds = DateAndTime::secondsFromDuration(elapsed); // Output with 6 decimal points std::ostringstream oss; @@ -3221,12 +3221,12 @@ MultiLayer *MantidUI::plot1D(const QMultiMap<QString, int> &toPlot, } /* Get the log values and put into a curve spec list in preparation of - * the creation of the curves - * @param curveSpecList :: list of curve specs to recieve the logs - * @param toPlot :: workspaces to plot - * @param log :: log value - * @param customLogValues :: custom log values - */ +* the creation of the curves +* @param curveSpecList :: list of curve specs to recieve the logs +* @param toPlot :: workspaces to plot +* @param log :: log value +* @param customLogValues :: custom log values +*/ void MantidUI::putLogsIntoCurveSpecs(std::vector<CurveSpec> &curveSpecList, const QMultiMap<QString, int> &toPlot, const QString &log, @@ -3269,13 +3269,13 @@ void MantidUI::putLogsIntoCurveSpecs(std::vector<CurveSpec> &curveSpecList, } /** - * Draw a color fill plot for each of the listed workspaces. Unfortunately the - * plotting is - * initimately linked to MantidMatrix so that one of these needs to be created - * first - * @param ui :: the sequential fitting UI form - * @param fitbrowser :: pointer to the fit property browser - */ +* Draw a color fill plot for each of the listed workspaces. Unfortunately the +* plotting is +* initimately linked to MantidMatrix so that one of these needs to be created +* first +* @param ui :: the sequential fitting UI form +* @param fitbrowser :: pointer to the fit property browser +*/ void MantidUI::showSequentialPlot( Ui::SequentialFitDialog *ui, MantidQt::MantidWidgets::FitPropertyBrowser *fitbrowser) { @@ -3318,13 +3318,13 @@ void MantidUI::showSequentialPlot( } /** - * Draw a color fill plot for each of the listed workspaces. Unfortunately the - * plotting is - * initimately linked to MantidMatrix so that one of these needs to be created - * first - * @param wsNames :: For each workspace listed create a 2D colorfill plot - * @param curveType :: The curve type for each of the plots - */ +* Draw a color fill plot for each of the listed workspaces. Unfortunately the +* plotting is +* initimately linked to MantidMatrix so that one of these needs to be created +* first +* @param wsNames :: For each workspace listed create a 2D colorfill plot +* @param curveType :: The curve type for each of the plots +*/ void MantidUI::drawColorFillPlots(const QStringList &wsNames, GraphOptions::CurveType curveType) { int nPlots = wsNames.size(); @@ -3379,15 +3379,15 @@ void MantidUI::drawColorFillPlots(const QStringList &wsNames, } /** - * Draw a single ColorFill plot for the named workspace - * @param wsName :: The name of the workspace which provides data for the plot - * @param curveType :: The type of curve - * @param window :: An optional pointer to a plot window. If not NULL the window - * is cleared - * and reused - * @param hidden - * @returns A pointer to the created plot - */ +* Draw a single ColorFill plot for the named workspace +* @param wsName :: The name of the workspace which provides data for the plot +* @param curveType :: The type of curve +* @param window :: An optional pointer to a plot window. If not NULL the window +* is cleared +* and reused +* @param hidden +* @returns A pointer to the created plot +*/ MultiLayer *MantidUI::drawSingleColorFillPlot(const QString &wsName, GraphOptions::CurveType curveType, MultiLayer *window, bool hidden) { @@ -3459,9 +3459,9 @@ MultiLayer *MantidUI::plotSpectraRange(const QString &wsName, int i0, int i1, if (i0 < 0 || i1 < 0) return 0; /** For instrument with one to many spectra-detector mapping, - * different pixels with correspond to the same specta so - * we need to remove doublons in this case. - */ + * different pixels with correspond to the same specta so + * we need to remove doublons in this case. + */ std::set<int> indexList; for (int i = i0; i <= i1; i++) indexList.insert(i); @@ -3636,16 +3636,16 @@ void MantidUI::plotLayerOfMultilayer(MultiLayer *multi, const bool plotErrors, }; // Lambda to set axis label hiding - const auto formatAxes = [&nRows, &nCols, &nPlots](Graph *layer, const int row, - const int col) { - const bool drawYAxisLabel = col == 0; - if (!drawXAxisLabel(row, col, nRows, nCols, nPlots)) { - layer->setXAxisTitle(QString::null); - } - if (!drawYAxisLabel) { - layer->setYAxisTitle(QString::null); - } - }; + const auto formatAxes = + [&nRows, &nCols, &nPlots](Graph *layer, const int row, const int col) { + const bool drawYAxisLabel = col == 0; + if (!drawXAxisLabel(row, col, nRows, nCols, nPlots)) { + layer->setXAxisTitle(QString::null); + } + if (!drawYAxisLabel) { + layer->setYAxisTitle(QString::null); + } + }; const bool isFitResult = workspaceIsFitResult(wsName); @@ -3788,9 +3788,9 @@ Table *MantidUI::createTableFromSelectedColumns(MantidMatrix *m, bool errs) { } /** Saves data to nexus file - * @param wsName :: Name of the workspace to be saved - * @param fileName :: name of the nexus file to created - */ +* @param wsName :: Name of the workspace to be saved +* @param fileName :: name of the nexus file to created +*/ void MantidUI::savedatainNexusFormat(const std::string &fileName, const std::string &wsName) { auto inputWorkspace = @@ -3813,9 +3813,9 @@ void MantidUI::savedatainNexusFormat(const std::string &fileName, } } /** Loads data from nexus file - * @param wsName :: Name of the workspace to be created - * @param fileName :: name of the nexus file - */ +* @param wsName :: Name of the workspace to be created +* @param fileName :: name of the nexus file +*/ void MantidUI::loadWSFromFile(const std::string &wsName, const std::string &fileName) { if (fileName.empty()) @@ -3830,8 +3830,9 @@ void MantidUI::loadWSFromFile(const std::string &wsName, } bool MantidUI::workspacesDockPlot1To1() { - return "On" == Mantid::Kernel::ConfigService::Instance().getString( - "MantidOptions.ReusePlotInstances"); + return "On" == + Mantid::Kernel::ConfigService::Instance().getString( + "MantidOptions.ReusePlotInstances"); } /** diff --git a/MantidPlot/src/Mantid/MantidUI.h b/MantidPlot/src/Mantid/MantidUI.h index 5f825facc40..b0d5965bb9e 100644 --- a/MantidPlot/src/Mantid/MantidUI.h +++ b/MantidPlot/src/Mantid/MantidUI.h @@ -616,9 +616,9 @@ private: /// This method accepts user inputs and executes loadraw/load nexus /// algorithm - std::string extractLogTime(Mantid::Types::DateAndTime value, + std::string extractLogTime(Mantid::Types::Core::DateAndTime value, bool useAbsoluteDate, - Mantid::Types::DateAndTime start); + Mantid::Types::Core::DateAndTime start); /// extracts the files from a mimedata object that have a .py extension QStringList extractPyFiles(const QList<QUrl> &urlList) const; diff --git a/qt/scientific_interfaces/Indirect/IndirectDataReductionTab.cpp b/qt/scientific_interfaces/Indirect/IndirectDataReductionTab.cpp index a4e7c8dbd93..08fa4a17aa6 100644 --- a/qt/scientific_interfaces/Indirect/IndirectDataReductionTab.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectDataReductionTab.cpp @@ -10,7 +10,7 @@ using namespace Mantid::API; using namespace Mantid::Geometry; using namespace Mantid::Kernel; -using Mantid::Types::DateAndTime; +using Mantid::Types::Core::DateAndTime; namespace { Mantid::Kernel::Logger g_log("IndirectDataReductionTab"); diff --git a/qt/scientific_interfaces/Indirect/IndirectTab.cpp b/qt/scientific_interfaces/Indirect/IndirectTab.cpp index 217ae39a3ea..7ee8bd2f767 100644 --- a/qt/scientific_interfaces/Indirect/IndirectTab.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectTab.cpp @@ -17,7 +17,7 @@ using namespace Mantid::API; using namespace Mantid::Geometry; using namespace Mantid::Kernel; using namespace MantidQt::MantidWidgets; -using Mantid::Types::DateAndTime; +using Mantid::Types::Core::DateAndTime; namespace { Mantid::Kernel::Logger g_log("IndirectTab"); diff --git a/qt/scientific_interfaces/Indirect/IndirectTab.h b/qt/scientific_interfaces/Indirect/IndirectTab.h index 5fb7f6f7ceb..d9777b86749 100644 --- a/qt/scientific_interfaces/Indirect/IndirectTab.h +++ b/qt/scientific_interfaces/Indirect/IndirectTab.h @@ -3,7 +3,7 @@ #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/AnalysisDataService.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/System.h" #include "MantidQtWidgets/Common/AlgorithmRunner.h" #include "MantidQtWidgets/Common/BatchAlgorithmRunner.h" @@ -211,8 +211,8 @@ protected: /// Overidden by child class. virtual bool validate() = 0; - Mantid::Types::DateAndTime m_tabStartTime; - Mantid::Types::DateAndTime m_tabEndTime; + Mantid::Types::Core::DateAndTime m_tabStartTime; + Mantid::Types::Core::DateAndTime m_tabEndTime; std::string m_pythonExportWsName; }; } // namespace CustomInterfaces diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisHelper.cpp b/qt/scientific_interfaces/Muon/MuonAnalysisHelper.cpp index 03840031dc5..e5db428d431 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisHelper.cpp +++ b/qt/scientific_interfaces/Muon/MuonAnalysisHelper.cpp @@ -8,7 +8,6 @@ #include "MantidAPI/TableRow.h" #include "MantidAPI/WorkspaceGroup.h" #include "MantidGeometry/Instrument.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/EmptyValues.h" #include "MantidKernel/InstrumentInfo.h" #include "MantidKernel/StringTokenizer.h" @@ -57,16 +56,15 @@ getKeysFromTable(const Mantid::API::ITableWorkspace_sptr &tab) { } return keys; } -} // namespace +} namespace MantidQt { namespace CustomInterfaces { namespace MuonAnalysisHelper { using namespace Mantid::Kernel; -using namespace Mantid::Types; using namespace Mantid::API; -using Mantid::Types::DateAndTime; +using Mantid::Types::Core::DateAndTime; /** * Sets double validator for specified field. @@ -138,21 +136,19 @@ void printRunInfo(MatrixWorkspace_sptr runWs, std::ostringstream &out) { const Run &run = runWs->run(); - Mantid::Types::DateAndTime start, end; + Mantid::Types::Core::DateAndTime start, end; // Add the start time for the run out << "\nStart: "; if (run.hasProperty("run_start")) { - start = DateAndTimeHelpers::createFromISO8601( - run.getProperty("run_start")->value()); + start = run.getProperty("run_start")->value(); out << start.toSimpleString(); } // Add the end time for the run out << "\nEnd: "; if (run.hasProperty("run_end")) { - end = Mantid::Types::DateAndTimeHelpers::createFromISO8601( - run.getProperty("run_end")->value()); + end = run.getProperty("run_end")->value(); out << end.toSimpleString(); } @@ -496,20 +492,19 @@ Workspace_sptr sumWorkspaces(const std::vector<Workspace_sptr> &workspaces) { // Comparison function for dates auto dateCompare = [](const std::string &first, const std::string &second) { - return DateAndTimeHelpers::createFromISO8601(first) < - DateAndTimeHelpers::createFromISO8601(second); + return DateAndTime(first) < DateAndTime(second); }; // Comparison function for doubles - auto numericalCompare = [](const std::string &first, - const std::string &second) { - try { - return boost::lexical_cast<double>(first) < - boost::lexical_cast<double>(second); - } catch (boost::bad_lexical_cast & /*e*/) { - return false; - } - }; + auto numericalCompare = + [](const std::string &first, const std::string &second) { + try { + return boost::lexical_cast<double>(first) < + boost::lexical_cast<double>(second); + } catch (boost::bad_lexical_cast & /*e*/) { + return false; + } + }; // Range of log values auto runNumRange = findLogRange(workspaces, "run_number", numericalCompare); @@ -1149,4 +1144,4 @@ getWorkspaceColors(const std::vector<Workspace_sptr> &workspaces) { } } // namespace MuonAnalysisHelper } // namespace CustomInterfaces -} // namespace MantidQt +} // namespace Mantid diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisHelper.h b/qt/scientific_interfaces/Muon/MuonAnalysisHelper.h index 436b726ddba..862581f5a7f 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisHelper.h +++ b/qt/scientific_interfaces/Muon/MuonAnalysisHelper.h @@ -7,7 +7,7 @@ #include "MantidAPI/MatrixWorkspace_fwd.h" #include "MantidAPI/ITableWorkspace_fwd.h" #include "MantidKernel/Logger.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include <QSettings> #include <QVector> diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.cpp b/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.cpp index e579b1f8682..8f326023d12 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.cpp +++ b/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.cpp @@ -3,26 +3,25 @@ #include "MantidAPI/ITableWorkspace.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/Run.h" -#include "MantidAPI/TableRow.h" #include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceGroup.h" +#include "MantidAPI/TableRow.h" #include "MantidKernel/ConfigService.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/TimeSeriesProperty.h" -#include "MantidQtWidgets/Common/HelpWindow.h" #include "MantidQtWidgets/Common/MuonFitPropertyBrowser.h" +#include "MantidQtWidgets/Common/HelpWindow.h" #include "MantidQtWidgets/Common/UserSubWindow.h" #include "MuonAnalysisHelper.h" #include "MuonAnalysisResultTableCreator.h" #include "MuonSequentialFitDialog.h" -#include <boost/algorithm/string/predicate.hpp> #include <boost/shared_ptr.hpp> +#include <boost/algorithm/string/predicate.hpp> #include <QFileInfo> -#include <QHash> #include <QLineEdit> +#include <QHash> #include <QMessageBox> #include <algorithm> @@ -39,7 +38,7 @@ using namespace Mantid::API; using namespace MantidQt::API; using namespace MantidQt::MantidWidgets; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; const std::string MuonAnalysisResultTableTab::WORKSPACE_POSTFIX("_Workspace"); const std::string MuonAnalysisResultTableTab::PARAMS_POSTFIX("_Parameters"); @@ -47,17 +46,12 @@ const QString MuonAnalysisResultTableTab::RUN_NUMBER_LOG("run_number"); const QString MuonAnalysisResultTableTab::RUN_START_LOG("run_start"); const QString MuonAnalysisResultTableTab::RUN_END_LOG("run_end"); const QStringList MuonAnalysisResultTableTab::NON_TIMESERIES_LOGS{ - MuonAnalysisResultTableTab::RUN_NUMBER_LOG, - "group", - "period", - RUN_START_LOG, - RUN_END_LOG, - "sample_temp", - "sample_magn_field"}; + MuonAnalysisResultTableTab::RUN_NUMBER_LOG, "group", "period", + RUN_START_LOG, RUN_END_LOG, "sample_temp", "sample_magn_field"}; /** - * Constructor - */ +* Constructor +*/ MuonAnalysisResultTableTab::MuonAnalysisResultTableTab(Ui::MuonAnalysis &uiForm) : m_uiForm(uiForm), m_savedLogsState(), m_unselectedFittings() { // Connect the help button to the wiki page. @@ -93,16 +87,16 @@ MuonAnalysisResultTableTab::MuonAnalysisResultTableTab(Ui::MuonAnalysis &uiForm) } /** - * Muon Analysis Results Table Help (slot) - */ +* Muon Analysis Results Table Help (slot) +*/ void MuonAnalysisResultTableTab::helpResultsClicked() { MantidQt::API::HelpWindow::showCustomInterface( nullptr, QString("Muon_Analysis"), QString("results-table")); } /** - * Select/Deselect all log values to be included in the table - */ +* Select/Deselect all log values to be included in the table +*/ void MuonAnalysisResultTableTab::selectAllLogs(bool state) { if (state) { for (int i = 0; i < m_uiForm.valueTable->rowCount(); i++) { @@ -125,8 +119,8 @@ void MuonAnalysisResultTableTab::selectAllLogs(bool state) { } /** - * Select/Deselect all fitting results to be included in the table - */ +* Select/Deselect all fitting results to be included in the table +*/ void MuonAnalysisResultTableTab::selectAllFittings(bool state) { if (state) { for (int i = 0; i < m_uiForm.fittingResultsTable->rowCount(); i++) { @@ -491,12 +485,12 @@ void MuonAnalysisResultTableTab::populateTables() { } /** - * Populates the items (log values) into their table. - * - * @param fittedWsList :: a workspace list containing ONLY the workspaces that - * have parameter - * tables associated with it. - */ +* Populates the items (log values) into their table. +* +* @param fittedWsList :: a workspace list containing ONLY the workspaces that +* have parameter +* tables associated with it. +*/ void MuonAnalysisResultTableTab::populateLogsAndValues( const QStringList &fittedWsList) { // A set of all the logs we've met in the workspaces @@ -549,11 +543,9 @@ void MuonAnalysisResultTableTab::populateLogsAndValues( } else if (logName == RUN_START_LOG || logName == RUN_END_LOG) { wsLogValues[logName + " (text)"] = QString::fromStdString(prop->value()); - const auto seconds = - static_cast<double>( - DateAndTimeHelpers::createFromISO8601(prop->value()) - .totalNanoseconds()) * - 1.e-9; + const auto seconds = static_cast<double>(DateAndTime(prop->value()) + .totalNanoseconds()) * + 1.e-9; wsLogValues[logName + " (s)"] = seconds; } else if (auto stringProp = dynamic_cast<PropertyWithValue<std::string> *>(prop)) { @@ -719,10 +711,10 @@ void MuonAnalysisResultTableTab::onCreateTableClicked() { } /** - * Creates the table using the information selected by the user in the tables - * @param multipleFits :: [input] Whether table is for multiple fits or one - * single fit - */ +* Creates the table using the information selected by the user in the tables +* @param multipleFits :: [input] Whether table is for multiple fits or one +* single fit +*/ void MuonAnalysisResultTableTab::createTable(bool multipleFits) { if (m_logValues.size() == 0) { QMessageBox::information(this, "Mantid - Muon Analysis", @@ -777,11 +769,11 @@ QStringList MuonAnalysisResultTableTab::getSelectedItemsToFit() { } /** - * Get the user selected log file - * - * @return logsSelected :: A vector of QString's containing the logs that are - * selected. - */ +* Get the user selected log file +* +* @return logsSelected :: A vector of QString's containing the logs that are +* selected. +*/ QStringList MuonAnalysisResultTableTab::getSelectedLogs() { QStringList logsSelected; for (int i = 0; i < m_uiForm.valueTable->rowCount(); i++) { @@ -797,12 +789,12 @@ QStringList MuonAnalysisResultTableTab::getSelectedLogs() { } /** - * Checks that the file name isn't been used, displays the appropriate message - * and - * then returns the name in which to save. - * - * @return name :: The name the results table should be created with. - */ +* Checks that the file name isn't been used, displays the appropriate message +* and +* then returns the name in which to save. +* +* @return name :: The name the results table should be created with. +*/ std::string MuonAnalysisResultTableTab::getFileName() { std::string fileName(m_uiForm.tableName->text().toStdString()); @@ -825,6 +817,6 @@ std::string MuonAnalysisResultTableTab::getFileName() { } return fileName; } -} // namespace Muon -} // namespace CustomInterfaces -} // namespace MantidQt +} +} +} diff --git a/qt/scientific_interfaces/test/ALCLatestFileFinderTest.h b/qt/scientific_interfaces/test/ALCLatestFileFinderTest.h index a7e52ab512a..3c84d138905 100644 --- a/qt/scientific_interfaces/test/ALCLatestFileFinderTest.h +++ b/qt/scientific_interfaces/test/ALCLatestFileFinderTest.h @@ -3,17 +3,17 @@ #include <cxxtest/TestSuite.h> -#include "../Muon/ALCLatestFileFinder.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/make_unique.h" +#include "MantidKernel/DateAndTime.h" +#include "../Muon/ALCLatestFileFinder.h" #include "MantidTestHelpers/ScopedFileHelper.h" -#include <Poco/DateTime.h> #include <Poco/File.h> +#include <Poco/DateTime.h> using MantidQt::CustomInterfaces::ALCLatestFileFinder; using ScopedFileHelper::ScopedFile; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; /** * Temporary directory that is deleted when it goes out of scope @@ -62,14 +62,14 @@ public: private: /** - * Generate a filename from supplied instrument, run number - * @param directory :: [input] Name of directory to create files in (must - * already exist) - * @param instrument [input] :: instrument name - * @param run [input] :: run number - * @param extension [input] :: extension - * @returns :: filename - */ + * Generate a filename from supplied instrument, run number + * @param directory :: [input] Name of directory to create files in (must + * already exist) + * @param instrument [input] :: instrument name + * @param run [input] :: run number + * @param extension [input] :: extension + * @returns :: filename + */ std::string createFileName(const std::string &directory, const std::string &instrument, const std::string &run, @@ -87,10 +87,10 @@ private: return stream.str(); } /** - * Set file's last modified time (resolution: nearest second) - * @param path :: [input] Path to file - * @param time :: [input] ISO8601 formatted time string - */ + * Set file's last modified time (resolution: nearest second) + * @param path :: [input] Path to file + * @param time :: [input] ISO8601 formatted time string + */ void adjustFileTime(const std::string &path, const std::string &modifiedTime) { // Make sure the file exists @@ -99,7 +99,7 @@ private: // Parse the time string and convert to Poco's format // Ignore sub-second intervals - DateAndTime time = DateAndTimeHelpers::createFromISO8601(modifiedTime); + DateAndTime time(modifiedTime); Poco::DateTime pocoTime(time.year(), time.month(), time.day(), time.hour(), time.minute(), time.second()); diff --git a/qt/scientific_interfaces/test/MDFLogValueFinderTest.h b/qt/scientific_interfaces/test/MDFLogValueFinderTest.h index e1249d84ae0..d7bab9a3127 100644 --- a/qt/scientific_interfaces/test/MDFLogValueFinderTest.h +++ b/qt/scientific_interfaces/test/MDFLogValueFinderTest.h @@ -1,22 +1,21 @@ #ifndef MANTIDQT_CUSTOMINTERFACES_MDFLOGVALUEFINDERTEST_H_ #define MANTIDQT_CUSTOMINTERFACES_MDFLOGVALUEFINDERTEST_H_ -#include "../MultiDatasetFit/MDFLogValueFinder.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/Run.h" #include "MantidAPI/ScopedWorkspace.h" #include "MantidAPI/WorkspaceFactory.h" -#include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/TimeSeriesProperty.h" +#include "../MultiDatasetFit/MDFLogValueFinder.h" -#include <QStringList> #include <cxxtest/TestSuite.h> - -using namespace Mantid::Types; +#include <QStringList> using Mantid::API::MatrixWorkspace_sptr; using Mantid::API::ScopedWorkspace; using Mantid::API::WorkspaceFactory; +using Mantid::Types::Core::DateAndTime; using Mantid::Kernel::Math::StatisticType; using Mantid::Kernel::TimeSeriesProperty; using MantidQt::CustomInterfaces::MDFLogValueFinder; @@ -154,7 +153,7 @@ private: for (size_t i = 0; i < 10; ++i) { DateAndTime t; const std::string &time = "2016-08-24T14:26:0" + std::to_string(i); - DateAndTimeHelpers::setFromISO8601(t, time); + t.setFromISO8601(time); times.push_back(t); values.push_back(static_cast<double>(i + logValue)); } diff --git a/qt/scientific_interfaces/test/MuonAnalysisHelperTest.h b/qt/scientific_interfaces/test/MuonAnalysisHelperTest.h index e17a90dd13c..827781b78f9 100644 --- a/qt/scientific_interfaces/test/MuonAnalysisHelperTest.h +++ b/qt/scientific_interfaces/test/MuonAnalysisHelperTest.h @@ -3,7 +3,6 @@ #include <cxxtest/TestSuite.h> -#include "../Muon/MuonAnalysisHelper.h" #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/FrameworkManager.h" @@ -13,8 +12,8 @@ #include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceGroup.h" #include "MantidGeometry/Instrument.h" -#include "MantidKernel/DateAndTimeHelpers.h" #include "MantidKernel/TimeSeriesProperty.h" +#include "../Muon/MuonAnalysisHelper.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" using namespace MantidQt::CustomInterfaces::MuonAnalysisHelper; @@ -22,7 +21,7 @@ using namespace MantidQt::CustomInterfaces::MuonAnalysisHelper; using namespace Mantid; using namespace Mantid::Kernel; using namespace Mantid::API; -using namespace Mantid::Types; +using Mantid::Types::Core::DateAndTime; /// This is a wrapper for the ADS that automatically clears itself on /// destruction @@ -132,8 +131,8 @@ public: WorkspaceCreationHelper::create2DWorkspace123(1, 3); MatrixWorkspace_sptr ws3 = WorkspaceCreationHelper::create2DWorkspace123(1, 3); - auto start = DateAndTimeHelpers::createFromISO8601("2015-12-23T15:32:40Z"); - auto end = DateAndTimeHelpers::createFromISO8601("2015-12-24T09:00:00Z"); + DateAndTime start{"2015-12-23T15:32:40Z"}; + DateAndTime end{"2015-12-24T09:00:00Z"}; addLog(ws1, "run_start", start.toSimpleString()); addLog(ws1, "run_end", end.toSimpleString()); addLog(ws1, "run_number", "15189"); @@ -184,8 +183,8 @@ public: void test_replaceLogValue() { ScopedWorkspace ws(createWs("MUSR", 15189)); - auto start1 = DateAndTimeHelpers::createFromISO8601("2015-12-23T15:32:40Z"); - auto start2 = DateAndTimeHelpers::createFromISO8601("2014-12-23T15:32:40Z"); + DateAndTime start1{"2015-12-23T15:32:40Z"}; + DateAndTime start2{"2014-12-23T15:32:40Z"}; addLog(ws.retrieve(), "run_start", start1.toSimpleString()); replaceLogValue(ws.name(), "run_start", start2.toSimpleString()); auto times = findLogValues(ws.retrieve(), "run_start"); @@ -196,8 +195,8 @@ public: void test_findLogValues() { Workspace_sptr ws1 = createWs("MUSR", 15189); Workspace_sptr ws2 = createWs("MUSR", 15190); - auto start1 = DateAndTimeHelpers::createFromISO8601("2015-12-23T15:32:40Z"); - auto start2 = DateAndTimeHelpers::createFromISO8601("2014-12-23T15:32:40Z"); + DateAndTime start1{"2015-12-23T15:32:40Z"}; + DateAndTime start2{"2014-12-23T15:32:40Z"}; addLog(ws1, "run_start", start1.toSimpleString()); addLog(ws2, "run_start", start2.toSimpleString()); auto groupWS = groupWorkspaces({ws1, ws2}); @@ -205,23 +204,21 @@ public: auto badLogs = findLogValues(groupWS, "not_present"); auto singleStart = findLogValues(ws1, "run_start"); TS_ASSERT_EQUALS(2, starts.size()); - TS_ASSERT_EQUALS(start1.toSimpleString(), starts[0]); - TS_ASSERT_EQUALS(start2.toSimpleString(), starts[1]); + TS_ASSERT_EQUALS(start1, starts[0]); + TS_ASSERT_EQUALS(start2, starts[1]); TS_ASSERT_EQUALS(0, badLogs.size()); TS_ASSERT_EQUALS(1, singleStart.size()); - TS_ASSERT_EQUALS(start1.toSimpleString(), singleStart[0]); + TS_ASSERT_EQUALS(start1, singleStart[0]); } void test_findLogRange_singleWS() { Workspace_sptr ws = createWs("MUSR", 15189); - auto start = DateAndTimeHelpers::createFromISO8601("2015-12-23T15:32:40Z"); + DateAndTime start{"2015-12-23T15:32:40Z"}; addLog(ws, "run_start", start.toSimpleString()); - auto range = - findLogRange(ws, "run_start", - [](const std::string &first, const std::string &second) { - return DateAndTimeHelpers::createFromISO8601(first) < - DateAndTimeHelpers::createFromISO8601(second); - }); + auto range = findLogRange(ws, "run_start", [](const std::string &first, + const std::string &second) { + return DateAndTime(first) < DateAndTime(second); + }); TS_ASSERT_EQUALS(range.first, start.toSimpleString()); TS_ASSERT_EQUALS(range.second, start.toSimpleString()); } @@ -229,16 +226,15 @@ public: void test_findLogRange_groupWS() { Workspace_sptr ws1 = createWs("MUSR", 15189); Workspace_sptr ws2 = createWs("MUSR", 15190); - auto start1 = DateAndTimeHelpers::createFromISO8601("2015-12-23T15:32:40Z"); - auto start2 = DateAndTimeHelpers::createFromISO8601("2014-12-23T15:32:40Z"); + DateAndTime start1{"2015-12-23T15:32:40Z"}; + DateAndTime start2{"2014-12-23T15:32:40Z"}; addLog(ws1, "run_start", start1.toSimpleString()); addLog(ws2, "run_start", start2.toSimpleString()); auto groupWS = groupWorkspaces({ws1, ws2}); auto range = findLogRange(groupWS, "run_start", [](const std::string &first, const std::string &second) { - return DateAndTimeHelpers::createFromISO8601(first) < - DateAndTimeHelpers::createFromISO8601(second); + return DateAndTime(first) < DateAndTime(second); }); TS_ASSERT_EQUALS(range.first, start2.toSimpleString()); TS_ASSERT_EQUALS(range.second, start1.toSimpleString()); @@ -247,16 +243,15 @@ public: void test_findLogRange_vectorOfWorkspaces() { Workspace_sptr ws1 = createWs("MUSR", 15189); Workspace_sptr ws2 = createWs("MUSR", 15190); - auto start1 = DateAndTimeHelpers::createFromISO8601("2015-12-23T15:32:40Z"); - auto start2 = DateAndTimeHelpers::createFromISO8601("2014-12-23T15:32:40Z"); + DateAndTime start1{"2015-12-23T15:32:40Z"}; + DateAndTime start2{"2014-12-23T15:32:40Z"}; addLog(ws1, "run_start", start1.toSimpleString()); addLog(ws2, "run_start", start2.toSimpleString()); std::vector<Workspace_sptr> workspaces = {ws1, ws2}; auto range = findLogRange(workspaces, "run_start", [](const std::string &first, const std::string &second) { - return DateAndTimeHelpers::createFromISO8601(first) < - DateAndTimeHelpers::createFromISO8601(second); + return DateAndTime(first) < DateAndTime(second); }); TS_ASSERT_EQUALS(range.first, start2.toSimpleString()); TS_ASSERT_EQUALS(range.second, start1.toSimpleString()); @@ -268,8 +263,7 @@ public: auto timeRange = findLogRange(ws, "run_start", [](const std::string &first, const std::string &second) { - return DateAndTimeHelpers::createFromISO8601(first) < - DateAndTimeHelpers::createFromISO8601(second); + return DateAndTime(first) < DateAndTime(second); }); TS_ASSERT_EQUALS(timeRange.first, ""); TS_ASSERT_EQUALS(timeRange.second, ""); @@ -303,13 +297,10 @@ public: void test_appendTimeSeriesLogs() { Workspace_sptr ws1 = createWs("MUSR", 15189); Workspace_sptr ws2 = createWs("MUSR", 15190); - const DateAndTime - time1 = DateAndTimeHelpers::createFromISO8601("2015-12-23T15:32:40Z"), - time2 = DateAndTimeHelpers::createFromISO8601("2015-12-23T15:32:41Z"), - time3 = DateAndTimeHelpers::createFromISO8601("2015-12-23T15:32:42Z"), - time4 = DateAndTimeHelpers::createFromISO8601("2015-12-23T15:32:43Z"), - time5 = DateAndTimeHelpers::createFromISO8601("2015-12-23T15:32:44Z"), - time6 = DateAndTimeHelpers::createFromISO8601("2015-12-23T15:32:45Z"); + const DateAndTime time1{"2015-12-23T15:32:40Z"}, + time2{"2015-12-23T15:32:41Z"}, time3{"2015-12-23T15:32:42Z"}, + time4{"2015-12-23T15:32:43Z"}, time5{"2015-12-23T15:32:44Z"}, + time6{"2015-12-23T15:32:45Z"}; const double value1(1), value2(2), value3(3), value4(4), value5(5), value6(6); const std::string logName = "TSLog"; @@ -742,7 +733,7 @@ private: // Adds a time series log to the workspace void addTimeSeriesLog(const Workspace_sptr &ws, const std::string &logName, - const std::vector<Mantid::Types::DateAndTime> ×, + const std::vector<Mantid::Types::Core::DateAndTime> ×, const std::vector<double> &values) { TS_ASSERT_EQUALS(times.size(), values.size()); auto matrixWS = boost::dynamic_pointer_cast<MatrixWorkspace>(ws); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeWidgetItem.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeWidgetItem.h index 9b605b40d19..79501358152 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeWidgetItem.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeWidgetItem.h @@ -2,7 +2,7 @@ #define MANTIDTREEWIDGETITEM_H #include "MantidQtWidgets/Common/DllOption.h" -#include <MantidTypes/DateAndTime.h> +#include <MantidKernel/DateAndTime.h> #include <MantidQtWidgets/Common/WorkspaceObserver.h> #include <QTreeWidgetItem> @@ -24,7 +24,7 @@ public: private: bool operator<(const QTreeWidgetItem &other) const override; MantidTreeWidget *m_parent; - static Mantid::Types::DateAndTime getLastModified(const QTreeWidgetItem *); + static Mantid::Types::Core::DateAndTime getLastModified(const QTreeWidgetItem *); int m_sortPos; }; } diff --git a/qt/widgets/common/src/AlgorithmDialog.cpp b/qt/widgets/common/src/AlgorithmDialog.cpp index 8a444acc89d..22c41ec3597 100644 --- a/qt/widgets/common/src/AlgorithmDialog.cpp +++ b/qt/widgets/common/src/AlgorithmDialog.cpp @@ -26,6 +26,7 @@ using namespace MantidQt::API; using namespace Mantid::Kernel::DateAndTimeHelpers; using Mantid::API::IAlgorithm; +using Mantid::Types::Core::DateAndTime; namespace { Mantid::Kernel::Logger g_log("AlgorithmDialog"); diff --git a/qt/widgets/common/src/CatalogHelper.cpp b/qt/widgets/common/src/CatalogHelper.cpp index e34ebad2ef4..43773f76a3d 100644 --- a/qt/widgets/common/src/CatalogHelper.cpp +++ b/qt/widgets/common/src/CatalogHelper.cpp @@ -1,13 +1,13 @@ -#include "MantidQtWidgets/Common/CatalogHelper.h" #include "MantidAPI/CatalogManager.h" -#include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidQtWidgets/Common/CatalogHelper.h" #include "MantidQtWidgets/Common/AlgorithmDialog.h" #include "MantidQtWidgets/Common/InterfaceManager.h" +#include "MantidKernel/DateAndTime.h" +#include <boost/algorithm/string/regex.hpp> #include <Poco/ActiveResult.h> #include <QCoreApplication> #include <QTime> -#include <boost/algorithm/string/regex.hpp> namespace MantidQt { namespace MantidWidgets { @@ -238,8 +238,7 @@ time_t CatalogHelper::getTimevalue(const std::string &inputDate) { std::string isoDate = dateSegments.at(2) + "-" + dateSegments.at(1) + "-" + dateSegments.at(0) + " 0:00:00.000"; // Return the date as time_t value. - return Mantid::Types::DateAndTimeHelpers::createFromISO8601(isoDate) - .to_time_t(); + return Mantid::Types::Core::DateAndTime(isoDate).to_time_t(); } /** diff --git a/qt/widgets/common/src/MantidTreeWidgetItem.cpp b/qt/widgets/common/src/MantidTreeWidgetItem.cpp index 65034216da3..b15a1202e13 100644 --- a/qt/widgets/common/src/MantidTreeWidgetItem.cpp +++ b/qt/widgets/common/src/MantidTreeWidgetItem.cpp @@ -1,31 +1,31 @@ #include "MantidQtWidgets/Common/MantidTreeWidgetItem.h" #include "MantidQtWidgets/Common/MantidTreeWidget.h" -#include "MantidAPI/WorkspaceHistory.h" #include <MantidAPI/Workspace.h> +#include "MantidAPI/WorkspaceHistory.h" using namespace Mantid::Kernel; using namespace Mantid::API; -using Mantid::Types::DateAndTime; +using Mantid::Types::Core::DateAndTime; namespace MantidQt { namespace MantidWidgets { /**Constructor. - * Must be passed its parent MantidTreeWidget, to facilitate correct sorting. - */ +* Must be passed its parent MantidTreeWidget, to facilitate correct sorting. +*/ MantidTreeWidgetItem::MantidTreeWidgetItem(MantidTreeWidget *parent) : QTreeWidgetItem(parent), m_parent(parent), m_sortPos(0) {} /**Constructor. - * Must be passed its parent MantidTreeWidget, to facilitate correct sorting. - */ +* Must be passed its parent MantidTreeWidget, to facilitate correct sorting. +*/ MantidTreeWidgetItem::MantidTreeWidgetItem(QStringList list, MantidTreeWidget *parent) : QTreeWidgetItem(list), m_parent(parent), m_sortPos(0) {} /**Overidden operator. - * Must be passed its parent MantidTreeWidget, to facilitate correct sorting. - */ +* Must be passed its parent MantidTreeWidget, to facilitate correct sorting. +*/ bool MantidTreeWidgetItem::operator<(const QTreeWidgetItem &other) const { // If this and/or other has been set to have a Qt::UserRole, then // it has an accompanying sort order that we must maintain, no matter @@ -86,9 +86,9 @@ bool MantidTreeWidgetItem::operator<(const QTreeWidgetItem &other) const { } /**Finds the date and time of the last modification made to the workspace who's - * details - * are found in the given QTreeWidgetItem. - */ +* details +* are found in the given QTreeWidgetItem. +*/ DateAndTime MantidTreeWidgetItem::getLastModified(const QTreeWidgetItem *item) { QVariant userData = item->data(0, Qt::UserRole); if (userData.isNull()) @@ -103,5 +103,5 @@ DateAndTime MantidTreeWidgetItem::getLastModified(const QTreeWidgetItem *item) { const auto lastAlgHist = wsHist.getAlgorithmHistory(indexOfLast); return lastAlgHist->executionDate(); } -} // namespace MantidWidgets -} // namespace MantidQt +} +} diff --git a/qt/widgets/common/src/SlitCalculator.cpp b/qt/widgets/common/src/SlitCalculator.cpp index 3fe12802c7b..dfd6eea230b 100644 --- a/qt/widgets/common/src/SlitCalculator.cpp +++ b/qt/widgets/common/src/SlitCalculator.cpp @@ -29,7 +29,7 @@ SlitCalculator::~SlitCalculator() {} void SlitCalculator::setInstrument(std::string instrumentName) { // we want to get the most up-to-date definition, so we use the current // date/time - auto date = Mantid::Types::DateAndTime::getCurrentTime().toISO8601String(); + auto date = Mantid::Types::Core::DateAndTime::getCurrentTime().toISO8601String(); // find the full path to the definition file auto filename = Mantid::API::ExperimentInfo::getInstrumentFilename(instrumentName, date); diff --git a/qt/widgets/plugins/algorithm_dialogs/src/StartLiveDataDialog.cpp b/qt/widgets/plugins/algorithm_dialogs/src/StartLiveDataDialog.cpp index d7e9524e339..db8225f29ca 100644 --- a/qt/widgets/plugins/algorithm_dialogs/src/StartLiveDataDialog.cpp +++ b/qt/widgets/plugins/algorithm_dialogs/src/StartLiveDataDialog.cpp @@ -10,7 +10,7 @@ #include <QtCore/qstringlist.h> #include "MantidAPI/Algorithm.h" #include "MantidAPI/LiveListenerFactory.h" -#include "MantidTypes/DateAndTime.h" +#include "MantidKernel/DateAndTime.h" #include "MantidKernel/SingletonHolder.h" #include "MantidKernel/ConfigService.h" #include "MantidKernel/InstrumentInfo.h" @@ -22,7 +22,7 @@ using namespace MantidQt::CustomDialogs; using namespace MantidQt::API; using Mantid::API::AlgorithmManager; using Mantid::API::Algorithm_sptr; -using Mantid::Types::DateAndTime; +using Mantid::Types::Core::DateAndTime; using Mantid::Kernel::ConfigService; namespace { -- GitLab