In the middle of multithreading parsers.
This commit is contained in:
@@ -230,13 +230,13 @@ assets::detail::generic_point_cloud_store<Ts...>::array_counts() const
|
||||
|
||||
template<typename... Ts>
|
||||
typename assets::detail::generic_point_cloud_store<Ts...>::id_type assets::detail::generic_point_cloud_store<Ts...>::add(
|
||||
const point_cloud_data& point_cloud
|
||||
const id_type id,
|
||||
const data_type& point_cloud
|
||||
) {
|
||||
|
||||
const auto id = id_type{ m_next_data_id.index++ };
|
||||
m_ids.push_back(id);
|
||||
|
||||
const auto& vertices = point_cloud.vertices;
|
||||
const auto& vertices = point_cloud.component_arrays;
|
||||
|
||||
auto component_flags = component_flag_type{};
|
||||
auto min_component_count = count_type{};
|
||||
@@ -403,14 +403,3 @@ typename assets::detail::generic_point_cloud_store<Ts...>::const_iterator assets
|
||||
{
|
||||
return const_cast<const generic_point_cloud_store*>(this)->end();
|
||||
}
|
||||
|
||||
template<typename... Ts>
|
||||
typename assets::detail::generic_point_cloud_store<Ts...>::view_type assets::detail::generic_point_cloud_store<Ts...>::view()
|
||||
{
|
||||
return { begin(), end() };
|
||||
}
|
||||
template<typename... Ts>
|
||||
typename assets::detail::generic_point_cloud_store<Ts...>::const_view_type assets::detail::generic_point_cloud_store<Ts...>::view() const
|
||||
{
|
||||
return { begin(), end() };
|
||||
}
|
||||
|
||||
289
source/assets/data_stores/pose_list_store.ipp
Normal file
289
source/assets/data_stores/pose_list_store.ipp
Normal file
@@ -0,0 +1,289 @@
|
||||
#ifndef INCLUDE_POSE_LIST_STORE_IMPLEMENTATION
|
||||
# error Never include this file directly include 'pose_list_store.hpp'
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <span>
|
||||
#include <tuple>
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
template<typename Char>
|
||||
assets::pose_list_store_iterator<Char>::pose_list_store_iterator(
|
||||
id_iterator_type ids,
|
||||
pose_iterator_type poses,
|
||||
length_iterator_type lengths,
|
||||
std::size_t index,
|
||||
const offset_type& offset
|
||||
) :
|
||||
m_ids{ ids },
|
||||
m_poses{ poses },
|
||||
m_lengths{ lengths },
|
||||
m_index{ index },
|
||||
m_offset{ offset } {}
|
||||
|
||||
|
||||
template<typename Char>
|
||||
typename assets::pose_list_store_iterator<Char>::reference assets::pose_list_store_iterator<Char>::operator*() const {
|
||||
return dereference(std::index_sequence_for<Char>{});
|
||||
}
|
||||
|
||||
template<typename Char>
|
||||
assets::pose_list_store_iterator<Char>& assets::pose_list_store_iterator<Char>::operator++() {
|
||||
adjust_offsets(std::index_sequence_for<Char>{}, 1);
|
||||
++m_index;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename Char>
|
||||
assets::pose_list_store_iterator<Char> assets::pose_list_store_iterator<Char>::operator++(int) {
|
||||
pose_list_store_iterator tmp = *this;
|
||||
++(*this);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template<typename Char>
|
||||
assets::pose_list_store_iterator<Char>& assets::pose_list_store_iterator<Char>::operator--() {
|
||||
adjust_offsets(std::index_sequence_for<Char>{}, -1);
|
||||
--m_index;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename Char>
|
||||
assets::pose_list_store_iterator<Char> assets::pose_list_store_iterator<Char>::operator--(int) {
|
||||
auto tmp = *this;
|
||||
--(*this);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template<typename Char>
|
||||
assets::pose_list_store_iterator<Char>& assets::pose_list_store_iterator<Char>::operator+=(const difference_type n)
|
||||
{
|
||||
adjust_offsets(std::index_sequence_for<Char>{}, n);
|
||||
m_index += n;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename Char>
|
||||
assets::pose_list_store_iterator<Char>& assets::pose_list_store_iterator<Char>::operator-=(const difference_type n)
|
||||
{
|
||||
return (*this) += -n;
|
||||
}
|
||||
|
||||
template<typename Char>
|
||||
assets::pose_list_store_iterator<Char> assets::pose_list_store_iterator<Char>::operator+(const difference_type n) const
|
||||
{
|
||||
auto tmp = *this;
|
||||
return tmp += n; // TODO clion says n is unused
|
||||
}
|
||||
|
||||
template<typename Char>
|
||||
assets::pose_list_store_iterator<Char> assets::pose_list_store_iterator<Char>::operator-(const difference_type n) const
|
||||
{
|
||||
auto tmp = *this;
|
||||
return tmp -= n; // TODO clion says n is unused
|
||||
}
|
||||
|
||||
template<typename Char>
|
||||
typename assets::pose_list_store_iterator<Char>::difference_type
|
||||
assets::pose_list_store_iterator<Char>::operator-(const pose_list_store_iterator& other) const
|
||||
{
|
||||
return static_cast<difference_type>(m_index) - static_cast<difference_type>(other.m_index);
|
||||
}
|
||||
|
||||
template<typename Char>
|
||||
typename assets::pose_list_store_iterator<Char>::reference assets::pose_list_store_iterator<Char>::operator[](
|
||||
const difference_type n
|
||||
) const {
|
||||
return *(*this + n);
|
||||
}
|
||||
|
||||
template<typename Char>
|
||||
bool assets::pose_list_store_iterator<Char>::operator==(const pose_list_store_iterator& other) const
|
||||
{
|
||||
return m_ids == other.m_ids and m_index == other.m_index;
|
||||
}
|
||||
|
||||
template<typename Char>
|
||||
bool assets::pose_list_store_iterator<Char>::operator!=(const pose_list_store_iterator& other) const
|
||||
{
|
||||
return not (*this == other);
|
||||
}
|
||||
|
||||
template<typename Char>
|
||||
bool assets::pose_list_store_iterator<Char>::operator<(const pose_list_store_iterator& other) const
|
||||
{
|
||||
return m_index < other.m_index;
|
||||
}
|
||||
|
||||
template<typename Char>
|
||||
bool assets::pose_list_store_iterator<Char>::operator<=(const pose_list_store_iterator& other) const
|
||||
{
|
||||
return m_index <= other.m_index;
|
||||
}
|
||||
|
||||
template<typename Char>
|
||||
bool assets::pose_list_store_iterator<Char>::operator>(const pose_list_store_iterator& other) const
|
||||
{
|
||||
return m_index > other.m_index;
|
||||
}
|
||||
|
||||
template<typename Char>
|
||||
bool assets::pose_list_store_iterator<Char>::operator>=(const pose_list_store_iterator& other) const
|
||||
{
|
||||
return m_index >= other.m_index;
|
||||
}
|
||||
|
||||
template<typename Char>
|
||||
void assets::pose_list_store_iterator<Char>::calc_offset(
|
||||
difference_type n
|
||||
) {
|
||||
|
||||
const auto negative = n < difference_type{ 0 };
|
||||
const auto positive = n > difference_type{ 0 };
|
||||
const auto step = difference_type{ positive } - difference_type{ negative };
|
||||
n = negative ? -n : n;
|
||||
|
||||
// TODO template optimize for single steps
|
||||
|
||||
while (n--)
|
||||
{
|
||||
const auto& count = m_lengths[m_index];
|
||||
m_offset += step * count;
|
||||
m_index += step;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Char>
|
||||
typename assets::pose_list_store_iterator<Char>::reference
|
||||
assets::pose_list_store_iterator<Char>::dereference() const
|
||||
{
|
||||
return std::make_pair(
|
||||
m_ids[m_index],
|
||||
pose_list_view{
|
||||
m_poses[m_offset],
|
||||
m_lengths[m_index]
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
assets::pose_list_store::id_type assets::pose_list_store::add(
|
||||
const pose_list_id id,
|
||||
const pose_list_data& pose_list
|
||||
) {
|
||||
|
||||
m_ids.push_back(id);
|
||||
|
||||
m_poses.insert(m_poses.end(), pose_list.begin(), pose_list.end());
|
||||
|
||||
m_lengths.push_back(pose_list.size());
|
||||
return id;
|
||||
}
|
||||
|
||||
std::pair<assets::pose_list_store::iterator_type, bool> assets::pose_list_store::find(id_type id)
|
||||
{
|
||||
const auto id_it = std::ranges::upper_bound(m_ids, id);
|
||||
|
||||
const auto match = (
|
||||
id_it != m_ids.begin() and
|
||||
*std::prev(id_it) == id
|
||||
);
|
||||
|
||||
const auto index = id_it - m_ids.begin() - match;
|
||||
|
||||
auto it = begin();
|
||||
it += index;
|
||||
|
||||
return { it, match };
|
||||
}
|
||||
|
||||
std::pair<assets::pose_list_store::const_iterator, bool> assets::pose_list_store::find(id_type id) const
|
||||
{
|
||||
const auto id_it = std::ranges::upper_bound(m_ids, id);
|
||||
|
||||
const auto match = (
|
||||
id_it != m_ids.begin() and
|
||||
*std::prev(id_it) == id
|
||||
);
|
||||
|
||||
const auto index = id_it - m_ids.begin() - match;
|
||||
|
||||
auto it = begin();
|
||||
it += index;
|
||||
|
||||
return { it, match };
|
||||
}
|
||||
|
||||
void assets::pose_list_store::remove(const iterator_type& it)
|
||||
{
|
||||
m_ids.erase(m_ids.begin() + it.m_index);
|
||||
|
||||
const auto begin = m_poses.begin() + it.m_offset;
|
||||
const auto end = begin + it.m_lengths[it.m_index];
|
||||
m_poses.erase(begin, end);
|
||||
|
||||
m_lengths.erase(m_lengths.begin() + it.m_index);
|
||||
}
|
||||
|
||||
void assets::pose_list_store::clear()
|
||||
{
|
||||
m_ids.clear();
|
||||
m_poses.clear();
|
||||
m_lengths.clear();
|
||||
}
|
||||
|
||||
assets::pose_list_store::iterator_type assets::pose_list_store::begin()
|
||||
{
|
||||
return iterator_type{
|
||||
m_ids.data(),
|
||||
m_poses.data(),
|
||||
m_lengths.data(),
|
||||
0,
|
||||
{}
|
||||
};
|
||||
}
|
||||
|
||||
assets::pose_list_store::iterator_type assets::pose_list_store::end()
|
||||
{
|
||||
return iterator_type{
|
||||
m_ids.data(),
|
||||
m_poses.data(),
|
||||
m_lengths.data(),
|
||||
m_lengths.size(),
|
||||
m_poses.size()
|
||||
};
|
||||
}
|
||||
|
||||
assets::pose_list_store::const_iterator assets::pose_list_store::begin() const
|
||||
{
|
||||
return const_iterator{
|
||||
m_ids.data(),
|
||||
m_poses.data(),
|
||||
m_lengths.data(),
|
||||
0,
|
||||
{}
|
||||
};
|
||||
}
|
||||
|
||||
assets::pose_list_store::const_iterator assets::pose_list_store::end() const
|
||||
{
|
||||
return const_iterator{
|
||||
m_ids.data(),
|
||||
m_poses.data(),
|
||||
m_lengths.data(),
|
||||
m_lengths.size(),
|
||||
m_poses.size()
|
||||
};
|
||||
}
|
||||
|
||||
assets::pose_list_store::const_iterator assets::pose_list_store::cbegin() const
|
||||
{
|
||||
return this->begin();
|
||||
}
|
||||
|
||||
assets::pose_list_store::const_iterator assets::pose_list_store::cend() const
|
||||
{
|
||||
return this->end();
|
||||
}
|
||||
@@ -9,17 +9,21 @@
|
||||
#include <type_traits>
|
||||
#include <algorithm>
|
||||
|
||||
#include "opengl/metadata/shader_source_metadata.hpp"
|
||||
|
||||
template<typename Char>
|
||||
assets::shader_source_store_iterator<Char>::shader_source_store_iterator(
|
||||
id_iterator_type ids,
|
||||
string_iterator_type strings,
|
||||
length_iterator_type lengths,
|
||||
metadata_iterator_type metadata,
|
||||
std::size_t index,
|
||||
const offset_type& offset
|
||||
) :
|
||||
m_ids{ ids },
|
||||
m_strings{ strings },
|
||||
m_lengths{ lengths },
|
||||
m_metadata{ metadata },
|
||||
m_index{ index },
|
||||
m_offset{ offset } {}
|
||||
|
||||
@@ -156,25 +160,23 @@ void assets::shader_source_store_iterator<Char>::calc_offset(
|
||||
}
|
||||
|
||||
template<typename Char>
|
||||
template<std::size_t... Is>
|
||||
typename assets::shader_source_store_iterator<Char>::reference
|
||||
assets::shader_source_store_iterator<Char>::dereference(std::index_sequence<Is...>) const
|
||||
assets::shader_source_store_iterator<Char>::dereference() const
|
||||
{
|
||||
return std::make_pair(
|
||||
m_ids[m_index],
|
||||
shader_source_view(
|
||||
m_strings[m_offset],
|
||||
m_lengths[m_index]
|
||||
)
|
||||
shader_source_view{
|
||||
.source = { m_strings[m_offset], m_lengths[m_index] },
|
||||
.meta = m_metadata[m_index]
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
assets::shader_source_store::id_type assets::shader_source_store::add(
|
||||
const shader_source_id id,
|
||||
const shader_source_data& shader_source
|
||||
) {
|
||||
|
||||
const auto id = id_type{ m_next_data_id.index++ };
|
||||
m_ids.push_back(id);
|
||||
|
||||
m_strings.reserve(m_strings.size() + shader_source.source.size() + 1);
|
||||
@@ -183,6 +185,8 @@ assets::shader_source_store::id_type assets::shader_source_store::add(
|
||||
|
||||
m_lengths.push_back(shader_source.source.size());
|
||||
|
||||
m_metadata.push_back(shader_source.meta);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -229,6 +233,7 @@ void assets::shader_source_store::remove(const iterator_type& it)
|
||||
m_strings.erase(begin, end);
|
||||
|
||||
m_lengths.erase(m_lengths.begin() + it.m_index);
|
||||
m_metadata.erase(m_metadata.begin() + it.m_index);
|
||||
}
|
||||
|
||||
void assets::shader_source_store::clear()
|
||||
@@ -236,6 +241,7 @@ void assets::shader_source_store::clear()
|
||||
m_ids.clear();
|
||||
m_strings.clear();
|
||||
m_lengths.clear();
|
||||
m_metadata.clear();
|
||||
}
|
||||
|
||||
assets::shader_source_store::iterator_type assets::shader_source_store::begin()
|
||||
@@ -244,6 +250,7 @@ assets::shader_source_store::iterator_type assets::shader_source_store::begin()
|
||||
m_ids.data(),
|
||||
m_strings.data(),
|
||||
m_lengths.data(),
|
||||
m_metadata.data(),
|
||||
0,
|
||||
{}
|
||||
};
|
||||
@@ -255,6 +262,7 @@ assets::shader_source_store::iterator_type assets::shader_source_store::end()
|
||||
m_ids.data(),
|
||||
m_strings.data(),
|
||||
m_lengths.data(),
|
||||
m_metadata.data(),
|
||||
m_lengths.size(),
|
||||
m_strings.size()
|
||||
};
|
||||
@@ -266,6 +274,7 @@ assets::shader_source_store::const_iterator assets::shader_source_store::begin()
|
||||
m_ids.data(),
|
||||
m_strings.data(),
|
||||
m_lengths.data(),
|
||||
m_metadata.data(),
|
||||
0,
|
||||
{}
|
||||
};
|
||||
@@ -277,6 +286,7 @@ assets::shader_source_store::const_iterator assets::shader_source_store::end() c
|
||||
m_ids.data(),
|
||||
m_strings.data(),
|
||||
m_lengths.data(),
|
||||
m_metadata.data(),
|
||||
m_lengths.size(),
|
||||
m_strings.size()
|
||||
};
|
||||
@@ -284,20 +294,10 @@ assets::shader_source_store::const_iterator assets::shader_source_store::end() c
|
||||
|
||||
assets::shader_source_store::const_iterator assets::shader_source_store::cbegin() const
|
||||
{
|
||||
return const_cast<const shader_source_store*>(this)->begin();
|
||||
return this->begin();
|
||||
}
|
||||
|
||||
assets::shader_source_store::const_iterator assets::shader_source_store::cend() const
|
||||
{
|
||||
return const_cast<const shader_source_store*>(this)->end();
|
||||
}
|
||||
|
||||
assets::shader_source_store::view_type assets::shader_source_store::view()
|
||||
{
|
||||
return { begin(), end() };
|
||||
}
|
||||
|
||||
assets::shader_source_store::const_view_type assets::shader_source_store::view() const
|
||||
{
|
||||
return { begin(), end() };
|
||||
return this->end();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user