API Documentation
Loading...
Searching...
No Matches
Log.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Base
28File: Log
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/LogMessage.h>
35#include <NDEVR/LogStream.h>
36#include <NDEVR/ProgressInfo.h>
37#include <NDEVR/LogMessage.h>
38#include <mutex>
39namespace NDEVR
40{
41 class String;
42
43 /**--------------------------------------------------------------------------------------------------
44 \brief Serves as the primary program interface for processes to report issues and allows any number of
45 LogStreams to subscribe and receive the log information in real-time.
46 **/
47 class Log final : public ProgressInfo, public Buffer<LogMessage>
48 {
49 friend class LogManager;
50 public:
51 NDEVR_BASE_API explicit Log(uint08 id = 0);
52 NDEVR_BASE_API Log(const Log& log);
54 public:
55 NDEVR_BASE_API void addStream(LogStream* stream, bool add_all) final override;
56 NDEVR_BASE_API void removeStream(LogStream* stream) final override;
57 NDEVR_BASE_API bool addMessage(const LogMessage& message) override;
58 NDEVR_BASE_API bool addMessage(const String& message, uint01 log_level = 10) override;
59 NDEVR_BASE_API bool addMessage(const char* const message, uint01 log_level = 10) final override;
60 NDEVR_BASE_API bool addMessage(const TranslatedString& message, uint01 log_level = 10) override;
61 NDEVR_BASE_API void insertMessages(uint04 index, const Buffer<LogMessage>& messages);
62 bool cancelRequested() const override { return m_request_cancel; }
63 void setCancelRequest(bool cancel) override {
64 m_request_cancel = cancel;
65 }
66
67 NDEVR_BASE_API void concatenate(const Log& log);
70 NDEVR_BASE_API void allowCancel(bool cancel) override;
71 NDEVR_BASE_API bool setProgress(fltp04 percent) final override;
72 protected:
75 private:
76 static constexpr fltp08 s_progress_epsilon = 0.001f;
77 Buffer<LogStream*> m_streams;
78 std::mutex m_mtx;
79 };
80}
81
#define NDEVR_BASE_API
Definition DLLInfo.h:57
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
Serves as the primary program interface for processes to report issues and allows any number of LogSt...
Definition Log.h:48
void sortMessagesByTime()
fltp04 m_progress
Definition Log.h:74
void concatenate(const Log &log)
bool cancelRequested() const override
Definition Log.h:62
bool addMessage(const String &message, uint01 log_level=10) override
bool addMessage(const char *const message, uint01 log_level=10) final override
Log(uint08 id=0)
bool setProgress(fltp04 percent) final override
Log(const Log &log)
void setCancelRequest(bool cancel) override
Definition Log.h:63
void sortMessagesByPriority()
bool m_request_cancel
Definition Log.h:73
void allowCancel(bool cancel) override
void insertMessages(uint04 index, const Buffer< LogMessage > &messages)
virtual ~Log()
bool addMessage(const LogMessage &message) override
void addStream(LogStream *stream, bool add_all) final override
void removeStream(LogStream *stream) final override
A class that has any number of children that also feed into the log. Can be used to easily collect lo...
Definition LogManager.h:14
A class that allows for specific log information to be conveyed to a ProgressInfo object including in...
Definition LogMessage.h:44
A class that listens to a log object and processes the updates in a specified way....
Definition LogStream.h:46
A light-weight base class for Log that allows processes to update, without the need for additional in...
Definition ProgressInfo.hpp:48
The core String class for the NDEVR API.
Definition String.h:69
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
Definition TranslatedString.h:13
Definition ACIColor.h:37
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
Definition BaseValues.hpp:127
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:80
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
Definition BaseValues.hpp:106
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149