NDEVR
API Documentation
ConnectionPipeStream.h
1#pragma once
2#include "DLLInfo.h"
3#include <NDEVR/LogStream.h>
4#include <NDEVR/Connection.h>
5namespace NDEVR
6{
11 class HARDWARE_API ConnectionPipeStream : public LogStream
12 {
13 public:
19 {
20 public:
21 static constexpr StringView const message_line = "[message]\n";
22 static constexpr StringView const message_time_line = "[time] [message]\n";
23 };
24
29 {
30 public:
31 static constexpr StringView const percent = "Progress: [%]%\r";
32 static constexpr StringView const progress = "Progress: [p]\r";
33 static constexpr StringView const progress_and_time = "Progress: [p]\r";
34 };
35
46 ConnectionPipeStream(Connection* connection, bool open_connection);
61 bool setConnection(const ConnectionInfo& connect_info);
71 bool setConnection(Connection* connection, bool open_connection);
80 virtual void setProgress(uint04 id, fltp04 progress) override;
86 virtual void addMessage(uint04 id, const LogMessage& message) override;
90 bool canSendMessages() const;
96 void setTimeSendFormat(const String& format, bool use_local_time);
102 void setMessageSendFormat(const String& format);
108 void setProgressSendFormat(const String& format);
109 private:
110 Connection* m_connection = nullptr;
111 String m_time_send_format = String("YYYY-MM-DD hh:mm:ss");
112 String m_message_send_format = String("[time] [message]\n");
113 String m_progress_format = String("Percent [%]\r");
114 fltp04 m_progress_epsilon = Constant<fltp04>::Invalid;
115 fltp04 m_previous_progress = 1.0f;
116 bool m_owns_connection = false;
117 bool m_use_local_time = false;
118 };
119}
Common formats for sending messages over the pipe using setMessageSendFormat Default progress format ...
static constexpr StringView const message_time_line
Format that prepends a timestamp to the message.
static constexpr StringView const message_line
Format that sends only the message followed by a newline.
Common formats for sending messages over the pipe using setMessageProgressFormat Default progress for...
static constexpr StringView const progress
Sends progress as a raw progress value.
static constexpr StringView const percent
Sends progress as a percentage value.
static constexpr StringView const progress_and_time
Sends progress with time information.
void clearConnection()
Clears the connection.
ConnectionPipeStream(Connection *connection, bool open_connection)
Sets the connection, if a connection is already set, removes that connection.
virtual void setProgress(uint04 id, fltp04 progress) override
Will send progress across the network based on the given format parameters.
void setMessageSendFormat(const String &format)
Sets the message format where [message] will be replaced with the raw log message,...
bool setConnection(const ConnectionInfo &connect_info)
Sets the connection, if a connection is already set, clears that connection (see clearConnection).
bool canSendMessages() const
Returns true if the connection exists and is ready to send.
void setProgressSendFormat(const String &format)
Sets the message format where [message] will be replaced with the raw log message,...
ConnectionPipeStream()
Default constructor, no connection instance.
ConnectionPipeStream(const ConnectionInfo &connection)
Sets the connection, if a connection is already set, removes that connection.
void setTimeSendFormat(const String &format, bool use_local_time)
Sets the Time format for the time string (See https://ndevr.org/time-patterns/).
bool setConnection(Connection *connection, bool open_connection)
Sets the connection, if a connection is already set, clears that connection (see clearConnection).
virtual void addMessage(uint04 id, const LogMessage &message) override
Will send message across the network based on the given format parameters.
A standard interface for all types of connections that allow transmitting and receiving of data betwe...
Definition Connection.h:316
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
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
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...
A structure designed to store information about a specific Connection.
Definition Connection.h:90