ORE Studio 0.0.4
Loading...
Searching...
No Matches
session_reader.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_COMMS_ANALYSER_DOMAIN_SESSION_READER_HPP
21#define ORES_COMMS_ANALYSER_DOMAIN_SESSION_READER_HPP
22
23#include <vector>
24#include <string>
25#include <chrono>
26#include <fstream>
27#include <cstdint>
28#include <expected>
29#include <filesystem>
30#include <boost/uuid/uuid.hpp>
31#include "ores.logging/make_logger.hpp"
32#include "ores.comms/messaging/frame.hpp"
33#include "ores.comms/recording/session_file.hpp"
34
36
41 boost::uuids::uuid session_id;
42 std::chrono::system_clock::time_point start_time;
43 std::string server_address;
44 std::uint16_t protocol_version_major;
45 std::uint16_t protocol_version_minor;
47};
48
53 std::int64_t timestamp_offset_us;
56};
57
62 session_metadata metadata;
63 std::vector<recorded_frame> frames;
64};
65
73class session_reader final {
74private:
75 inline static std::string_view logger_name = "ores.comms.analyser.domain.session_reader";
76
77 static auto& lg() {
78 using namespace ores::logging;
79 static auto instance = make_logger(logger_name);
80 return instance;
81 }
82
83public:
90 static std::expected<session_data, comms::recording::session_file_error>
91 read(const std::filesystem::path& file_path);
92
101 static std::expected<session_metadata, comms::recording::session_file_error>
102 read_metadata(const std::filesystem::path& file_path);
103
104private:
108 static std::expected<std::pair<session_metadata, std::uint16_t>, comms::recording::session_file_error>
109 read_header(std::ifstream& file);
110
114 static std::expected<recorded_frame, comms::recording::session_file_error>
115 read_frame_record(std::ifstream& file);
116};
117
118}
119
120#endif
compression_type
Compression algorithm used for payload compression.
Definition message_types.hpp:259
Domain types for session analysis.
Definition ores.comms.analyser.domain.hpp:28
session_file_error
Error codes for session file operations.
Definition session_file.hpp:119
frame_direction
Direction of a recorded frame.
Definition session_file.hpp:50
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Metadata about a recorded session.
Definition session_reader.hpp:40
A single recorded frame with metadata.
Definition session_reader.hpp:52
Complete session data including metadata and frames.
Definition session_reader.hpp:61
Reads and parses ORES session recording files.
Definition session_reader.hpp:73
static std::expected< session_metadata, comms::recording::session_file_error > read_metadata(const std::filesystem::path &file_path)
Read only the session metadata (header).
Definition session_reader.cpp:82
static std::expected< session_data, comms::recording::session_file_error > read(const std::filesystem::path &file_path)
Read a complete session file.
Definition session_reader.cpp:35
Complete frame with header and payload.
Definition frame.hpp:77