API Documentation
Loading...
Searching...
No Matches
LogStream.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: 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/ProgressInfo.h>
36#include <NDEVR/Buffer.h>
37#include <NDEVR/LogMessage.h>
38namespace NDEVR
39{
40 class LogMessage;
41 /**--------------------------------------------------------------------------------------------------
42 \brief A class that listens to a log object and processes the updates in a specified way. Any number
43 of LogStreams can be attached to a ProgressInfo object and will be updated in real time.
44 **/
46 {
47 public:
48 virtual ~LogStream()
49 {
50 clearLinks();
51 }
52 virtual void attach(ProgressInfo* stream)
53 {
54 m_linked_logs.add(stream);
55 }
56 virtual void detach(ProgressInfo* stream)
57 {
58 m_linked_logs.removeElement(stream);
59 }
60 virtual void allowCancel(bool) {}
61 virtual void setProgress(fltp04 progress) = 0;
62 virtual void addMessage(const LogMessage& message) = 0;
63 virtual void addMessages(const Buffer<LogMessage>& messages)
64 {
65 for (uint04 i = 0; i < messages.size(); i++)
66 {
67 addMessage(messages[i]);
68 }
69 }
71 {
72 for (uint04 i = 0; i < m_linked_logs.size(); i++)
73 {
74 m_linked_logs[i]->removeStream(this);
75 }
76 m_linked_logs.clear();
77 }
78 void setIgnoreMessages(bool ignore)
79 {
80 m_ignore_message = ignore;
81 }
82 bool ignoringMessages() const
83 {
84 return m_ignore_message;
85 }
86 protected:
88 bool m_ignore_message = false;
89 };
90}
91
#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
constexpr t_index_type size() const
Definition Buffer.hpp:823
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
virtual void addMessages(const Buffer< LogMessage > &messages)
Definition LogStream.h:63
virtual void attach(ProgressInfo *stream)
Definition LogStream.h:52
virtual void allowCancel(bool)
Definition LogStream.h:60
void setIgnoreMessages(bool ignore)
Definition LogStream.h:78
void clearLinks()
Definition LogStream.h:70
virtual void setProgress(fltp04 progress)=0
virtual ~LogStream()
Definition LogStream.h:48
virtual void detach(ProgressInfo *stream)
Definition LogStream.h:56
virtual void addMessage(const LogMessage &message)=0
Buffer< ProgressInfo * > m_linked_logs
Definition LogStream.h:87
bool ignoringMessages() const
Definition LogStream.h:82
A light-weight base class for Log that allows processes to update, without the need for additional in...
Definition ProgressInfo.hpp:48
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
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96