1#ifndef IV_SRC_LOGS_DOWNLOADLOGS_HPP_
2#define IV_SRC_LOGS_DOWNLOADLOGS_HPP_
6#include "third_party/JSON.hpp"
15using JSON = nlohmann::ordered_json;
17class DownloadLogs :
public std::enable_shared_from_this<DownloadLogs>
20 static std::shared_ptr<DownloadLogs>
createLog(std::string_view logTitle, std::string_view logMessage,
28 std::vector<std::shared_ptr<DownloadLogs>>
childLogs;
31 void addChildLog(
const std::shared_ptr<DownloadLogs> &log);
37 [[nodiscard]] uint64_t
numLogs()
const;
38 std::vector<std::weak_ptr<DownloadLogs>>
flatList();
39 [[nodiscard]] std::shared_ptr<DownloadLogs>
getLog(uint64_t indLog);
47 static constexpr std::string_view
kTitle {
"title"};
48 static constexpr std::string_view
kMessage {
"message"};
49 static constexpr std::string_view
kState {
"state"};
50 static constexpr std::string_view
kTimestamp {
"timestamp"};
51 static constexpr std::string_view
kChildLogs {
"childLogs"};
Definition DownloadLogs.hpp:18
std::string title
Definition DownloadLogs.hpp:23
std::vector< std::weak_ptr< DownloadLogs > > flatList()
Definition DownloadLogs.cpp:82
JSON toJson() const
Definition DownloadLogs.cpp:48
std::shared_ptr< DownloadLogs > getLog(uint64_t indLog)
Definition DownloadLogs.cpp:98
eDownloadLogState state
Definition DownloadLogs.hpp:25
uint64_t numLogs() const
Definition DownloadLogs.cpp:70
void addChildLog(const std::shared_ptr< DownloadLogs > &log)
Definition DownloadLogs.cpp:20
std::string message
Definition DownloadLogs.hpp:24
std::weak_ptr< DownloadLogs > parentLog
Definition DownloadLogs.hpp:29
iv::types::timestamp timestamp
Definition DownloadLogs.hpp:26
static std::shared_ptr< DownloadLogs > createLog(std::string_view logTitle, std::string_view logMessage, eDownloadLogState logState, iv::types::timestamp timestamp)
Definition DownloadLogs.cpp:9
std::vector< std::shared_ptr< DownloadLogs > > childLogs
Definition DownloadLogs.hpp:28
bool isLeaf() const
Definition DownloadLogs.cpp:120
void updateWithChildState(eDownloadLogState childState)
Definition DownloadLogs.cpp:125
Definition DownloadLogger.cpp:19
eDownloadLogState
Definition enums.hpp:8
nlohmann::ordered_json JSON
Definition DownloadLogs.hpp:15
uint64_t timestamp
Definition types.hpp:21
Definition DownloadLogs.hpp:46
static constexpr std::string_view kTimestamp
Definition DownloadLogs.hpp:50
static constexpr std::string_view kTitle
Definition DownloadLogs.hpp:47
static constexpr std::string_view kMessage
Definition DownloadLogs.hpp:48
static constexpr std::string_view kState
Definition DownloadLogs.hpp:49
static constexpr std::string_view kChildLogs
Definition DownloadLogs.hpp:51