Mantid
Loading...
Searching...
No Matches
IDFObject.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2012 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9#include "MantidGeometry/DllConfig.h"
10#ifndef Q_MOC_RUN
11#include <memory>
12#endif
13#include <Poco/File.h>
14#include <Poco/Path.h>
15#include <stdexcept>
16
17namespace Mantid {
18namespace Geometry {
19
31class MANTID_GEOMETRY_DLL AbstractIDFObject {
32public:
33 AbstractIDFObject() = default;
34 static const std::string expectedExtension();
35 virtual const Poco::Path getParentDirectory() const = 0;
36 virtual const Poco::Path &getFileFullPath() const = 0;
37 virtual const std::string &getFileFullPathStr() const = 0;
38 virtual std::string getFileNameOnly() const = 0;
39 virtual std::string getExtension() const = 0;
40 virtual std::string getMangledName() const = 0;
41 virtual bool exists() const = 0;
42 virtual ~AbstractIDFObject() = default;
43
44private:
47};
48
52class MANTID_GEOMETRY_DLL IDFObject : public AbstractIDFObject {
53public:
54 IDFObject(const std::string &fileName);
55 const Poco::Path getParentDirectory() const override;
56 const Poco::Path &getFileFullPath() const override;
57 const std::string &getFileFullPathStr() const override;
58 std::string getFileNameOnly() const override;
59 std::string getExtension() const override;
60 std::string getMangledName() const override;
61 bool exists() const override;
62
63private:
66 const Poco::File m_defFile;
67 const bool m_hasFileName;
68 const Poco::Path m_cachePath;
69 const Poco::Path m_cacheParentDirectory;
70 const std::string m_cachePathStr;
71};
72
73/*
74 * NULL IDFObject
75 */
76class MANTID_GEOMETRY_DLL NullIDFObject : public AbstractIDFObject {
77private:
78 std::string m_emptyResponse;
79
80public:
81 NullIDFObject() : m_emptyResponse("") {}
82 const Poco::Path getParentDirectory() const override { throw std::runtime_error("Not implemented on NullIDFObject"); }
83 const Poco::Path &getFileFullPath() const override { throw std::runtime_error("Not implemented on NullIDFObject"); }
84 const std::string &getFileFullPathStr() const override { return m_emptyResponse; }
85 std::string getFileNameOnly() const override { return m_emptyResponse; }
86 std::string getExtension() const override { return m_emptyResponse; }
87 std::string getMangledName() const override { throw std::runtime_error("Not implemented on NullIDFObject"); }
88 bool exists() const override { return false; }
89};
90
91using IDFObject_sptr = std::shared_ptr<AbstractIDFObject>;
92using IDFObject_const_sptr = std::shared_ptr<const AbstractIDFObject>;
93
94} // namespace Geometry
95} // namespace Mantid
IDFObject : File object wrapper over an IDF file.
Definition: IDFObject.h:31
virtual std::string getFileNameOnly() const =0
AbstractIDFObject(const AbstractIDFObject &)
AbstractIDFObject & operator=(const AbstractIDFObject &)
virtual const std::string & getFileFullPathStr() const =0
virtual std::string getMangledName() const =0
virtual const Poco::Path getParentDirectory() const =0
virtual std::string getExtension() const =0
virtual const Poco::Path & getFileFullPath() const =0
virtual bool exists() const =0
Concrete IDF Object.
Definition: IDFObject.h:52
IDFObject & operator=(const IDFObject &)
const Poco::File m_defFile
Definition: IDFObject.h:66
const std::string m_cachePathStr
Definition: IDFObject.h:70
IDFObject(const IDFObject &)
const Poco::Path m_cacheParentDirectory
Definition: IDFObject.h:69
const Poco::Path m_cachePath
Definition: IDFObject.h:68
bool exists() const override
Definition: IDFObject.h:88
const std::string & getFileFullPathStr() const override
Definition: IDFObject.h:84
std::string getMangledName() const override
Definition: IDFObject.h:87
const Poco::Path getParentDirectory() const override
Definition: IDFObject.h:82
std::string getExtension() const override
Definition: IDFObject.h:86
const Poco::Path & getFileFullPath() const override
Definition: IDFObject.h:83
std::string getFileNameOnly() const override
Definition: IDFObject.h:85
bool exists(::NeXus::File &file, const std::string &name)
Based on the current group in the file, does the named sub-entry exist?
std::shared_ptr< AbstractIDFObject > IDFObject_sptr
Definition: IDFObject.h:91
std::shared_ptr< const AbstractIDFObject > IDFObject_const_sptr
Definition: IDFObject.h:92
Helper class which provides the Collimation Length for SANS instruments.