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