NDEVR
API Documentation
LogStream.h
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: LogStream
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/BaseValues.h>
35#include <NDEVR/InfoPipe.h>
36#include <NDEVR/Buffer.h>
37#include <NDEVR/LogMessage.h>
38#include <NDEVR/Dictionary.h>
39#include "ProgressSource.h"
40namespace NDEVR
41{
42 class LogMessage;
49 {
50 public:
54 inline virtual ~LogStream()
55 {
56 clearLinks();
57 }
58
62 inline virtual void attach(InfoPipe* stream)
63 {
64 m_linked_logs.add(stream);
65 }
66
70 inline virtual void detach(InfoPipe* stream)
71 {
72 m_linked_logs.removeElement(stream);
73 }
74
78 inline virtual void allowCancel(bool) {}
83 inline virtual void allowInput(bool) {}
89 virtual void setProgress(uint04 id, fltp04 progress) = 0;
95 virtual void addMessage(uint04 id, const LogMessage& message) = 0;
102 virtual void addProgressSource(const TranslatedString& name, uint04 idx, fltp04 progress)
103 {
104 m_progress_sources.insert({idx, {name, idx, progress}});
105 };
106
110 virtual void removeProgressSource(uint04 idx)
111 {
112 m_progress_sources.erase(idx);
113 };
114
119 inline virtual void addMessages(uint04 id, const Buffer<LogMessage>& messages)
120 {
121 for (uint04 i = 0; i < messages.size(); i++)
122 addMessage(id, messages[i]);
123 }
124
127 inline void clearLinks()
128 {
129 for (uint04 i = 0; i < m_linked_logs.size(); i++)
130 {
131 m_linked_logs[i]->removeStream(this);
132 }
133 m_linked_logs.clear();
134 }
135
139 inline void setIgnoreMessages(bool ignore)
140 {
141 m_ignore_message = ignore;
142 }
143
147 inline bool ignoringMessages() const
148 {
149 return m_ignore_message;
150 }
151 protected:
154 bool m_ignore_message = false;
155 };
156}
157
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
A light-weight base class for Log that allows processes to update, without the need for additional in...
A class that allows for specific log information to be conveyed to a InfoPipe object including inform...
Definition LogMessage.h:48
A listener that receives and processes log messages and progress updates from an InfoPipe.
Definition LogStream.h:49
virtual void removeProgressSource(uint04 idx)
Removes a previously registered progress source from this stream.
Definition LogStream.h:110
void setIgnoreMessages(bool ignore)
Sets whether this stream should ignore incoming messages.
Definition LogStream.h:139
virtual void allowInput(bool)
Sets whether this stream allows user input during an operation.
Definition LogStream.h:83
virtual void attach(InfoPipe *stream)
Attaches this LogStream to the given InfoPipe so it receives log updates.
Definition LogStream.h:62
Buffer< InfoPipe * > m_linked_logs
Collection of InfoPipe objects this stream is listening to.
Definition LogStream.h:153
virtual void setProgress(uint04 id, fltp04 progress)=0
Updates the progress value for a tracked operation.
virtual ~LogStream()
Destructor.
Definition LogStream.h:54
Dictionary< uint04, ProgressSource > m_progress_sources
Maps progress source indices to their ProgressSource data.
Definition LogStream.h:152
bool ignoringMessages() const
Returns whether this stream is currently ignoring messages.
Definition LogStream.h:147
virtual void allowCancel(bool)
Sets whether this stream allows the user to cancel an in-progress operation.
Definition LogStream.h:78
void clearLinks()
Detaches this LogStream from all linked InfoPipe objects and clears the link list.
Definition LogStream.h:127
bool m_ignore_message
Whether this stream should ignore incoming messages.
Definition LogStream.h:154
virtual void addMessages(uint04 id, const Buffer< LogMessage > &messages)
Adds multiple log messages to this stream at once.
Definition LogStream.h:119
virtual void detach(InfoPipe *stream)
Detaches this LogStream from the given InfoPipe, stopping further updates from it.
Definition LogStream.h:70
virtual void addMessage(uint04 id, const LogMessage &message)=0
Adds a single log message to this stream.
virtual void addProgressSource(const TranslatedString &name, uint04 idx, fltp04 progress)
Registers a new progress source to be tracked by this stream.
Definition LogStream.h:102
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...
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
@ name
The display name of the object.