diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadPSIMuonBin.h b/Framework/DataHandling/inc/MantidDataHandling/LoadPSIMuonBin.h index ec86b55deb45b84503af43c3b5b64ae3080324c4..5606dcdb984ad76c40444412d781368f988a371d 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadPSIMuonBin.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadPSIMuonBin.h @@ -1,9 +1,9 @@ #ifndef MANTID_DATAHANDLING_LOADPSIMUONBIN_H_ #define MANTID_DATAHANDLING_LOADPSIMUONBIN_H_ +#include "MantidAPI/IFileLoader.h" #include "MantidDataHandling/LoadRawHelper.h" #include "MantidDataObjects/Workspace2D.h" -#include "MantidAPI/IFileLoader.h" #include <cstdint> namespace Mantid { @@ -11,31 +11,17 @@ namespace DataHandling { class DLLExport LoadPSIMuonBin : public API::IFileLoader<Kernel::FileDescriptor> { + public: - /// Default constructor - LoadPSIMuonBin(); - /// Algorithm's name for identification overriding a virtual method const std::string name() const override; - /// Summary of algorithms purpose const std::string summary() const override; - - /// Algorithm's version for identification overriding a virtual method int version() const override; - - /// Algorithm's category for identification overriding a virtual method const std::string category() const override; - - /// Returns a confidence value that this algorithm can load a file int confidence(Kernel::FileDescriptor &descriptor) const override; - - /// Returns a value indicating whether or not loader wants to load multiple - /// files into a single workspace bool loadMutipleAsOne() override; private: - /// Overwrites Algorithm method. void init() override; - /// Overwrites Algorithm method void exec() override; // Define the variables of the header @@ -64,17 +50,18 @@ private: float histogramBinWidth; float temperatures[4]; float temperatureDeviation[4]; - float monLow[4]; //No idea what this is + float monLow[4]; // No idea what this is float monHigh[4]; int32_t monNumberOfevents; char monDeviation[12]; - int16_t numberOfDataRecordsFile; //numdef - int16_t lengthOfDataRecordsBin; //lendef - int16_t numberOfDataRecordsHistogram; //kdafhi - int16_t numberOfHistogramsPerRecord; //khidaf + int16_t numberOfDataRecordsFile; // numdef + int16_t lengthOfDataRecordsBin; // lendef + int16_t numberOfDataRecordsHistogram; // kdafhi + int16_t numberOfHistogramsPerRecord; // khidaf int32_t periodOfSave; int32_t periodOfMon; -} + +}; } // namespace DataHandling } // namespace Mantid diff --git a/Framework/DataHandling/src/LoadPSIMuonBin.cpp b/Framework/DataHandling/src/LoadPSIMuonBin.cpp index 809c68ea3b3831d1dbfcd0dd32f73eae2be99e68..fb1263e9df626c17984898942a22bf3e6061ca0c 100644 --- a/Framework/DataHandling/src/LoadPSIMuonBin.cpp +++ b/Framework/DataHandling/src/LoadPSIMuonBin.cpp @@ -1,6 +1,11 @@ #include "MantidDataHandling/LoadPSIMuonBin.h" +#include "MantidAPI/Algorithm.h" +#include "MantidAPI/FileProperty.h" +#include "MantidAPI/MatrixWorkspace.h" +#include "MantidAPI/RegisterFileLoader.h" #include <fstream> +#include <memory> namespace Mantid { namespace DataHandling { @@ -23,16 +28,7 @@ const std::string LoadPSIMuonBin::category() const { return "DataHandling\\PSIMuonBin"; } -// Default constructor TODO: Delete if not needed -LoadPSIMuonBin::LoadPSIMuonBin() {} - -/** - * @brief - * - * @param descriptor - * @return int - */ -int LoadPSIMuonBin::confidence(Kernel::FileDescriptor &descriptor) const override { +int LoadPSIMuonBin::confidence(Kernel::FileDescriptor &descriptor) const { auto &stream = descriptor.data(); // 85th character is a space & 89th character is a ~ stream.seekg(0, std::ios::beg); @@ -48,40 +44,39 @@ int LoadPSIMuonBin::confidence(Kernel::FileDescriptor &descriptor) const overrid } return confidence; } -} // version 1 does not however there is an issue open to create a version which // handles temperatures aswell -bool LoadPSIMuonBin::loadMutipleAsOne() override { return false; } +bool LoadPSIMuonBin::loadMutipleAsOne() { return false; } void LoadPSIMuonBin::init() { const std::vector<std::string> exts{".bin"}; - declareProperty(Kernel::make_unique<FileProperty>("Filename", "", - FileProperty::Load, exts), + declareProperty(Kernel::make_unique<Mantid::API::FileProperty>("Filename", "", + Mantid::API::FileProperty::Load, exts), "The name of the Bin file to load"); - declareProperty(Kernel::make_unique<WorkspaceProperty<Workspace>>( - "OutputWorkspace", "", Mantid::Direction::Output), + declareProperty(Kernel::make_unique<Mantid::API::WorkspaceProperty<Mantid::API::Workspace>>( + "OutputWorkspace", "", Kernel::Direction::Output), "An output workspace."); } void LoadPSIMuonBin::exec() { - if (sizeOf(float) != 4) { + if (sizeof(float) != 4) { // assumpetions made about the binary input won't work but since there is no - // way to guarantee floating points are 32 bits on all Operating systems here - // we are. + // way to guarantee floating points are 32 bits on all Operating systems + // here we are. } std::string binFilename = getPropertyValue("Filename"); - // std::vector<Histogram> readHistogramData; + std::vector<Mantid::HistogramData::Histogram> readHistogramData; - ifstream binFile(binFileName, ios::in|ios::binary:ios::ate); + std::ifstream binFile(binFilename, std::ios::in | std::ios::binary | std::ios::ate); auto size = binFile.tellg(); const int sizeOfHeader = 1024; - const char binFileHeaderBuffer[sizeofHeader]; + const std::unique_ptr<char> binFileHeaderBuffer; binFile.read(binFileHeaderBuffer, sizeOfHeader); std::string fileFormat(binFileHeaderBuffer, 2); @@ -91,6 +86,6 @@ void LoadPSIMuonBin::exec() { } std::memcpy(&tdcResolution, binFileHeaderBuffer + 2, 2); // get resolution -} + } // namespace DataHandling -} // namespace Mantid \ No newline at end of file +} // namespace Mantid