Mantid
Loading...
Searching...
No Matches
PropertyWithValue.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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 +
9
10// PropertyWithValue implementation
12#include "MantidKernel/PropertyWithValue.tcc"
13
14#include <NeXusFile.hpp>
15
16namespace Mantid::Kernel {
17
18#define PROPERTYWITHVALUE_SAVEPROPERTY(type) \
19 template <> void PropertyWithValue<type>::saveProperty(::NeXus::File *file) { \
20 file->makeGroup(this->name(), "NXlog", true); \
21 file->writeData("value", m_value); \
22 file->openData("value"); \
23 file->putAttr("units", this->units()); \
24 file->closeData(); \
25 file->closeGroup(); \
26 }
27
35PROPERTYWITHVALUE_SAVEPROPERTY(std::vector<double>)
36PROPERTYWITHVALUE_SAVEPROPERTY(std::vector<int32_t>)
37
38
39template class MANTID_KERNEL_DLL PropertyWithValue<uint16_t>;
40template class MANTID_KERNEL_DLL PropertyWithValue<bool>;
41template class MANTID_KERNEL_DLL PropertyWithValue<OptionalBool>;
42template class MANTID_KERNEL_DLL PropertyWithValue<std::vector<float>>;
43template class MANTID_KERNEL_DLL PropertyWithValue<std::vector<uint16_t>>;
44template class MANTID_KERNEL_DLL PropertyWithValue<std::vector<uint32_t>>;
45template class MANTID_KERNEL_DLL PropertyWithValue<std::vector<int64_t>>;
46template class MANTID_KERNEL_DLL PropertyWithValue<std::vector<uint64_t>>;
47template class MANTID_KERNEL_DLL PropertyWithValue<std::vector<bool>>;
48template class MANTID_KERNEL_DLL PropertyWithValue<std::vector<OptionalBool>>;
49template class MANTID_KERNEL_DLL PropertyWithValue<std::vector<std::string>>;
50template class MANTID_KERNEL_DLL PropertyWithValue<Matrix<float>>;
51template class MANTID_KERNEL_DLL PropertyWithValue<Matrix<double>>;
52template class MANTID_KERNEL_DLL PropertyWithValue<Matrix<int>>;
53template class MANTID_KERNEL_DLL PropertyWithValue<std::vector<std::vector<int32_t>>>;
54template class MANTID_KERNEL_DLL PropertyWithValue<std::vector<std::vector<std::string>>>;
55template class MANTID_KERNEL_DLL PropertyWithValue<std::shared_ptr<PropertyManager>>;
56#if defined(_WIN32) || defined(__clang__) && defined(__APPLE__)
57// nexus does not support writeData for long type on mac, so we save as int64
58template <> void PropertyWithValue<long>::saveProperty(::NeXus::File *file) {
59 file->makeGroup(this->name(), "NXlog", true);
60 file->writeData("value", static_cast<int64_t>(m_value));
61 file->openData("value");
62 file->putAttr("units", this->units());
63 file->closeData();
64 file->closeGroup();
65}
66template class MANTID_KERNEL_DLL PropertyWithValue<long>;
67template class MANTID_KERNEL_DLL PropertyWithValue<unsigned long>;
68template class MANTID_KERNEL_DLL PropertyWithValue<std::vector<long>>;
69template class MANTID_KERNEL_DLL PropertyWithValue<std::vector<unsigned long>>;
70template class MANTID_KERNEL_DLL PropertyWithValue<std::vector<std::vector<long>>>;
71#endif
72#ifdef __linux__
73template class MANTID_KERNEL_DLL PropertyWithValue<long long>;
74template class MANTID_KERNEL_DLL PropertyWithValue<unsigned long long>;
75template class MANTID_KERNEL_DLL PropertyWithValue<std::vector<long long>>;
76template class MANTID_KERNEL_DLL PropertyWithValue<std::vector<unsigned long long>>;
77template class MANTID_KERNEL_DLL PropertyWithValue<std::vector<std::vector<long long>>>;
78#endif
80
81// The explicit template instantiations for some types does not have an export
82// macro
83// since this produces a warning on "gcc: warning: type attributes ignored after
84// type is already define". We can remove the issue, by removing the visibility
85// attribute
86template class PropertyWithValue<float>;
87template class PropertyWithValue<double>;
88template class PropertyWithValue<int32_t>;
89template class PropertyWithValue<uint32_t>;
90template class PropertyWithValue<int64_t>;
91template class PropertyWithValue<uint64_t>;
92
93template class PropertyWithValue<std::vector<double>>;
94template class PropertyWithValue<std::vector<int32_t>>;
95
96template class PropertyWithValue<std::string>;
97
98} // namespace Mantid::Kernel
const std::string & m_value
Definition: Algorithm.cpp:71
#define PROPERTYWITHVALUE_SAVEPROPERTY(type)
void saveProperty(::NeXus::File *file) override