Nix (Dev) 3.5.10
dev - 3.5.10 - 1af9301
Loading...
Searching...
No Matches
DownloadLogs.hpp
Go to the documentation of this file.
1#ifndef IV_SRC_LOGS_DOWNLOADLOGS_HPP_
2#define IV_SRC_LOGS_DOWNLOADLOGS_HPP_
3
4#include "core/types.hpp"
5#include "logs/enums.hpp"
6#include "third_party/JSON.hpp"
7
8#include <memory>
9#include <string>
10#include <vector>
11
12namespace iv::logs
13{
14
15using JSON = nlohmann::ordered_json;
16
17class DownloadLogs : public std::enable_shared_from_this<DownloadLogs>
18{
19public:
20 static std::shared_ptr<DownloadLogs> createLog(std::string_view logTitle, std::string_view logMessage,
22
23 std::string title;
24 std::string message;
27
28 std::vector<std::shared_ptr<DownloadLogs>> childLogs;
29 std::weak_ptr<DownloadLogs> parentLog;
30
31 void addChildLog(const std::shared_ptr<DownloadLogs> &log);
32 void addChildLog(std::string_view logTitle, std::string_view logMessage, eDownloadLogState logState,
34
35 JSON toJson() const;
36
37 [[nodiscard]] uint64_t numLogs() const;
38 std::vector<std::weak_ptr<DownloadLogs>> flatList();
39 [[nodiscard]] std::shared_ptr<DownloadLogs> getLog(uint64_t indLog);
40 bool isLeaf() const;
41
42private:
44
45 struct JsonKeys
46 {
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"};
52 };
53};
54
55}// namespace iv::logs
56
57#endif//IV_SRC_LOGS_DOWNLOADLOGS_HPP_
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