In the middle of multithreading parsers.

This commit is contained in:
zy4n
2025-03-30 22:38:06 +02:00
parent d18b40a7fc
commit 144126ee7a
80 changed files with 2904 additions and 1450 deletions

View File

@@ -105,13 +105,12 @@ public:
using count_type = ztu::u32;
using component_flag_type = point_cloud_vertex_components::flags;
using data_type = point_cloud_data;
using iterator_type = generic_point_cloud_store_iterator<Ts...>;
using const_iterator = generic_point_cloud_store_iterator<std::add_const_t<Ts>...>;
using view_type = std::ranges::subrange<iterator_type>;
using const_view_type = std::ranges::subrange<const_iterator>;
using id_type = point_cloud_id;
id_type add(const point_cloud_data& point_cloud);
id_type add(id_type id, const data_type& point_cloud);
[[nodiscard]] std::pair<iterator_type, bool> find(id_type id);
@@ -133,10 +132,6 @@ public:
const_iterator cend() const;
view_type view();
const_view_type view() const;
protected:
std::tuple<std::add_pointer_t<Ts>...> component_iterators();

View File

@@ -7,7 +7,7 @@ namespace assets
using material_store = detail::generic_material_store<
material_components::surface_properties,
material_components::transparency,
material_components::alpha,
texture_store::id_type,
texture_store::id_type,
texture_store::id_type,

View File

@@ -0,0 +1,137 @@
#pragma once
#include "generic/generic_basic_store.hpp"
#include "assets/identifiers.hpp"
#include "assets/data/pose_list_data.hpp"
#include "assets/data_views/pose_list_view.hpp"
namespace assets
{
class pose_list_store;
template<typename Char>
class pose_list_store_iterator
{
public:
using size_type = std::size_t;
using length_type = ztu::u32;
using id_type = pose_list_id;
using value_type = std::pair<id_type, pose_list_view>;
using id_iterator_type = id_type const*;
using pose_iterator_type = Char*;
using length_iterator_type = const length_type*;
using offset_type = size_type;
using difference_type = std::ptrdiff_t;
using pointer = value_type*;
using reference = value_type;
using iterator_category = std::random_access_iterator_tag;
private:
friend pose_list_store;
pose_list_store_iterator(
id_iterator_type ids,
pose_iterator_type poses,
length_iterator_type lengths,
std::size_t index,
const offset_type& offset
);
public:
constexpr pose_list_store_iterator() noexcept = default;
constexpr pose_list_store_iterator(const pose_list_store_iterator&) noexcept = default;
constexpr pose_list_store_iterator(pose_list_store_iterator&&) noexcept = default;
constexpr pose_list_store_iterator& operator=(const pose_list_store_iterator&) noexcept = default;
constexpr pose_list_store_iterator& operator=(pose_list_store_iterator&&) noexcept = default;
reference operator*() const;
pose_list_store_iterator& operator++();
pose_list_store_iterator operator++(int);
pose_list_store_iterator& operator--();
pose_list_store_iterator operator--(int);
pose_list_store_iterator& operator+=(difference_type n);
pose_list_store_iterator& operator-=(difference_type n);
pose_list_store_iterator operator+(difference_type n) const;
pose_list_store_iterator operator-(difference_type n) const;
difference_type operator-(const pose_list_store_iterator& other) const;
reference operator[](difference_type n) const;
bool operator==(const pose_list_store_iterator& other) const;
bool operator!=(const pose_list_store_iterator& other) const;
bool operator<(const pose_list_store_iterator& other) const;
bool operator<=(const pose_list_store_iterator& other) const;
bool operator>(const pose_list_store_iterator& other) const;
bool operator>=(const pose_list_store_iterator& other) const;
protected:
void calc_offset(difference_type n);
reference dereference() const;
private:
id_iterator_type m_ids{};
pose_iterator_type m_poses{};
length_iterator_type m_lengths{};
size_type m_index{};
offset_type m_offset{};
};
class pose_list_store
{
public:
using size_type = std::size_t;
using count_type = ztu::u32;
using iterator_type = pose_list_store_iterator<char>;
using const_iterator = pose_list_store_iterator<const char>;
using data_type = pose_list_data;
using id_type = pose_list_id;
// TODO not storing metadata
inline id_type add(
id_type id,
const data_type& pose_list
);
[[nodiscard]] inline std::pair<iterator_type, bool> find(id_type id);
[[nodiscard]] inline std::pair<const_iterator, bool> find(id_type id) const;
inline void remove(const iterator_type& it);
inline void clear();
[[nodiscard]] inline iterator_type begin();
[[nodiscard]] inline iterator_type end();
[[nodiscard]] inline const_iterator begin() const;
[[nodiscard]] inline const_iterator end() const;
[[nodiscard]] inline const_iterator cbegin() const;
[[nodiscard]] inline const_iterator cend() const;
private:
std::vector<id_type> m_ids;
std::vector<char> m_poses;
std::vector<count_type> m_lengths;
};
}
#define INCLUDE_POSE_LIST_STORE_IMPLEMENTATION
#include "assets/data_stores/pose_list_store.ipp"
#undef INCLUDE_POSE_LIST_STORE_IMPLEMENTATION

View File

@@ -15,12 +15,14 @@ class shader_source_store_iterator
public:
using size_type = std::size_t;
using length_type = ztu::u32;
using id_type = ztu::id_type_for<shader_source_store, ztu::u32>;
using id_type = shader_source_id;
using metadata_type = shader_source_data::metadata;
using value_type = std::pair<id_type, shader_source_view>;
using id_iterator_type = id_type const*;
using string_iterator_type = Char*;
using length_iterator_type = const length_type*;
using metadata_iterator_type = const metadata_type*;
using offset_type = size_type;
using difference_type = std::ptrdiff_t;
@@ -35,6 +37,7 @@ private:
id_iterator_type ids,
string_iterator_type strings,
length_iterator_type lengths,
metadata_iterator_type metadata,
std::size_t index,
const offset_type& offset
);
@@ -80,6 +83,7 @@ private:
id_iterator_type m_ids{};
string_iterator_type m_strings{};
length_iterator_type m_lengths{};
metadata_iterator_type m_metadata{};
size_type m_index{};
offset_type m_offset{};
};
@@ -95,9 +99,13 @@ public:
using const_iterator = shader_source_store_iterator<const char>;
using view_type = std::ranges::subrange<iterator_type>;
using const_view_type = std::ranges::subrange<const_iterator>;
using id_type = ztu::id_type_for<shader_source_store, ztu::u32>;
using id_type = shader_source_id;
inline id_type add(const shader_source_data& shader_source);
// TODO not storing metadata
inline id_type add(
shader_source_id id,
const shader_source_data& shader_source
);
[[nodiscard]] inline std::pair<iterator_type, bool> find(id_type id);
@@ -119,15 +127,12 @@ public:
[[nodiscard]] inline const_iterator cend() const;
[[nodiscard]] inline view_type view();
[[nodiscard]] inline const_view_type view() const;
private:
std::vector<id_type> m_ids;
std::vector<char> m_strings;
std::vector<count_type> m_lengths;
id_type m_next_data_id{ 1 };
std::vector<shader_source_data::metadata> m_metadata;
};
}