6 #ifndef METALL_KERNEL_OBJECT_ATTRIBUTE_ACCESSOR_HPP
7 #define METALL_KERNEL_OBJECT_ATTRIBUTE_ACCESSOR_HPP
13 #include <metall/kernel/attributed_object_directory.hpp>
19 namespace attraccs_detail {
24 template <
typename _offset_type,
typename _
size_type>
27 using object_directory_type =
28 kernel::attributed_object_directory<_offset_type, _size_type>;
31 object_directory_type object_directory{};
39 using size_type =
typename object_directory_type::size_type;
40 using name_type =
typename object_directory_type::name_type;
41 using offset_type =
typename object_directory_type::offset_type;
42 using length_type =
typename object_directory_type::length_type;
50 const std::
string &object_attribute_file_path) noexcept {
51 priv_alloc_core_data();
53 m_core_data->object_attribute_file_path = object_attribute_file_path;
54 const bool succeeded = m_core_data->object_directory.deserialize(
55 m_core_data->object_attribute_file_path.c_str());
57 m_core_data.reset(
nullptr);
61 "Filed to initialize the core data");
62 m_core_data.reset(
nullptr);
68 if (priv_alloc_core_data()) {
69 priv_copy_core_data(other);
78 priv_copy_core_data(other);
87 bool good() const noexcept {
return !!m_core_data; }
92 if (!m_core_data)
return 0;
93 return m_core_data->object_directory.size();
101 if (!m_core_data)
return 0;
102 return m_core_data->object_directory.count(name);
112 return m_core_data->object_directory.find(name);
121 return m_core_data->object_directory.begin();
130 return m_core_data->object_directory.end();
141 if (!m_core_data)
return false;
143 if (position ==
end())
return false;
145 if (!m_core_data->object_directory.set_description(position, description) ||
146 !m_core_data->object_directory.serialize(
147 m_core_data->object_attribute_file_path.c_str())) {
149 "Filed to set description");
168 bool priv_alloc_core_data() noexcept {
170 m_core_data = std::make_unique<core_data>();
172 m_core_data.reset(
nullptr);
178 bool priv_copy_core_data(
181 m_core_data = other.m_core_data;
184 "Filed to copy the core data");
185 m_core_data.reset(
nullptr);
191 std::unique_ptr<core_data> m_core_data{
nullptr};
198 template <
typename _offset_type,
typename _
size_type>
218 const std::
string &object_attribute_file_path) noexcept
219 :
base_type(object_attribute_file_path) {}
225 template <
typename _offset_type,
typename _
size_type>
245 const std::
string &object_attribute_file_path) noexcept
246 :
base_type(object_attribute_file_path) {}
259 template <
typename T>
276 template <
typename T>
309 template <
typename T>
319 template <
typename _offset_type,
typename _
size_type>
322 using object_directory_type =
323 kernel::attributed_object_directory<_offset_type, _size_type>;
326 object_directory_type object_directory{};
334 using size_type =
typename object_directory_type::size_type;
335 using name_type =
typename object_directory_type::name_type;
345 const std::
string &object_attribute_file_path) noexcept {
346 priv_alloc_core_data();
348 m_core_data->object_attribute_file_path = object_attribute_file_path;
349 const bool succeeded = m_core_data->object_directory.deserialize(
350 m_core_data->object_attribute_file_path.c_str());
352 m_core_data.reset(
nullptr);
356 "Filed to initialize the core data");
357 m_core_data.reset(
nullptr);
363 if (priv_alloc_core_data()) {
364 priv_copy_core_data(other);
373 priv_copy_core_data(other);
382 bool good() const noexcept {
return !!m_core_data; }
387 if (!m_core_data)
return 0;
388 return m_core_data->object_directory.size();
396 return m_core_data->object_directory.begin();
404 return m_core_data->object_directory.end();
415 if (!m_core_data)
return false;
417 if (position ==
end())
return false;
419 if (!m_core_data->object_directory.set_description(position, description) ||
420 !m_core_data->object_directory.serialize(
421 m_core_data->object_attribute_file_path.c_str())) {
423 "Filed to set description");
431 bool priv_alloc_core_data() noexcept {
433 m_core_data = std::make_unique<core_data>();
435 m_core_data.reset(
nullptr);
441 bool priv_copy_core_data(
444 m_core_data = other.m_core_data;
447 "Filed to copy the core data");
448 m_core_data.reset(
nullptr);
454 std::unique_ptr<core_data> m_core_data{
nullptr};