In the middle of multithreading parsers.
This commit is contained in:
66
include/assets/file_parsers/kitti_pose_parser.hpp
Normal file
66
include/assets/file_parsers/kitti_pose_parser.hpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include "assets/path_id_lookups.hpp"
|
||||
#include "assets/data_stores/pose_list_store.hpp"
|
||||
#include "assets/data/pose_list_data.hpp"
|
||||
|
||||
|
||||
namespace assets
|
||||
{
|
||||
|
||||
struct kitti_pose_parser
|
||||
{
|
||||
static constexpr auto name = std::string_view("kitti_pose");
|
||||
using data_type = pose_list_data;
|
||||
using store_type = pose_list_store;
|
||||
using lookup_type = pose_list_id_lookup;
|
||||
|
||||
[[nodiscard]] std::error_code prefetch(
|
||||
path_id_lookups& lookups
|
||||
);
|
||||
|
||||
[[nodiscard]] std::error_code parse(
|
||||
const path_id_lookups& lookups,
|
||||
store_type& store,
|
||||
bool pedantic = false
|
||||
);
|
||||
|
||||
private:
|
||||
static constexpr auto pose_filename = std::string_view{ "pose.txt" };
|
||||
|
||||
class parser_context
|
||||
{
|
||||
public:
|
||||
parser_context(
|
||||
store_type& m_store,
|
||||
std::mutex& m_store_mutex
|
||||
);
|
||||
|
||||
void operator()(lookup_type::const_pointer entry) noexcept;
|
||||
|
||||
protected:
|
||||
void reset();
|
||||
|
||||
private:
|
||||
store_type* m_store;
|
||||
std::mutex* m_store_mutex;
|
||||
data_type m_buffer{};
|
||||
};
|
||||
|
||||
static std::error_code parse_file(
|
||||
const std::filesystem::path& filename,
|
||||
data_type &poses
|
||||
);
|
||||
|
||||
static std::error_code parse_pose(
|
||||
std::ifstream& in,
|
||||
pose_data& pose
|
||||
);
|
||||
|
||||
private:
|
||||
std::vector<lookup_type::const_pointer> m_path_buffer;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user