34#include <NDEVR/LogMessage.h>
35#include <NDEVR/LogStream.h>
36#include <NDEVR/InfoPipe.h>
38#include <NDEVR/LogMessage.h>
39#include <NDEVR/Dictionary.h>
49 class Log final :
public InfoPipe,
public Buffer<LogMessage>
51 friend class LogManager;
68 NDEVR_BASE_API
virtual ~Log();
274 static constexpr
fltp08 s_progress_epsilon = 0.001f;
276 mutable
std::mutex m_mtx;
constexpr Buffer() noexcept
A hash-based key-value store, useful for quick associative lookups.
A class that allows for specific log information to be conveyed to a InfoPipe object including inform...
A listener that receives and processes log messages and progress updates from an InfoPipe.
void addInput(const StringView &s, uint04 idx) final override
Provides input text for a specific input guard by index.
void getInputIdx(String &s, uint04 idx, bool clear) final override
Retrieves the input string for a specific input guard.
Dictionary< uint04, bool > m_request_cancel
Maps cancel guard indices to their cancellation request state.
Dictionary< uint04, ProgressSource > m_progress
Maps progress source indices to their progress tracking data.
void sortMessagesByTime()
Sorts all stored messages by their timestamp.
void setProgressIdx(uint04 idx, fltp04 percent) final override
Sets the progress percentage for a tracked progress source.
bool cancelRequestedIdx(uint04 idx) const final override
Checks whether cancel has been requested for a specific guard.
fltp04 progressIdx(uint04 idx) const final override
Retrieves the current progress percentage for a tracked progress source.
void removeCancelGuard(uint04 idx) final override
Removes a previously registered cancel guard.
void removeInputGuard(uint04 idx) final override
Removes a previously registered input guard.
Log(uint08 id=0)
Constructs a Log with the given identifier.
uint04 addProgressSource(const TranslatedString &name, fltp04 progress) final override
Registers a new progress source with a display name and initial progress.
Log(const Log &log)
Copy constructs a Log from another Log.
void addMessage(uint04 id, const StringView &message, uint01 log_level=10) final override
Adds a message from a string view with a specified log level.
bool cancelRequested() const final override
Checks whether any cancel has been requested across all guards.
void addMessage(uint04 id, const LogMessage &message) final override
Adds a single LogMessage to the log and notifies all subscribed streams.
void requestCancel() final override
Requests cancellation of all active operations.
uint04 addInputGuard(const TranslatedString &name) final override
Registers a new input guard with a display name, returning the assigned index.
virtual ~Log()
Destructor.
uint04 addCancelGuard(const TranslatedString &name) final override
Registers a new cancel guard with a display name.
void addMessages(uint04 id, const Buffer< LogMessage > &messages) final override
Adds multiple LogMessages to the log and notifies all subscribed streams.
void concatenate(const Log &log)
Appends all messages from another Log into this one.
Dictionary< uint04, String > m_input
Maps input guard indices to their stored input strings.
void sortMessagesByPriority()
Sorts all stored messages by their priority level.
void insertMessages(uint04 index, const Buffer< LogMessage > &messages)
Inserts multiple LogMessages at a specific index in the log buffer.
void clearInputIdx(uint04 idx) final override
Clears the stored input for a specific input guard.
void removeStream(LogStream *stream) final override
Unsubscribes a LogStream so it no longer receives log messages.
void addStream(LogStream *stream, bool add_all) final override
Subscribes a LogStream to receive log messages.
void removeProgressSource(uint04 idx) final override
Removes a previously registered progress source.
The core String View class for the NDEVR API.
The core String class for the NDEVR API.
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
@ name
The display name of the object.
Represents a named progress source with an identifier and completion percentage.