PLCnext API Documentation  22.9.0.33
Stream.hpp
1 //
3 // Copyright PHOENIX CONTACT Electronics GmbH
4 //
6 #pragma once
7 #include "Arp/System/Core/Arp.h"
8 #include "Arp/System/Commons/Io/SeekOrigin.hpp"
9 
10 namespace Arp { namespace System { namespace Commons { namespace Io
11 {
12 
13 // forwards
14 class NullStream;
15 
19 class Stream
20 {
21 public: // construction/destruction
23  Stream(void);
25  Stream(const Stream& arg) = delete;
27  Stream& operator=(const Stream& arg) = delete;
29  virtual ~Stream(void);
30 
31 public: // static properties
32  static NullStream Empty;
33 
34 public: // setter/getter operations
35  virtual boolean CanRead(void) = 0;
36  virtual boolean CanWrite(void) = 0;
37  virtual boolean CanSeek(void) = 0;
38  virtual size_t GetLength(void) = 0;
39  virtual void SetLength(size_t length) = 0;
40  virtual size_t GetPosition(void) = 0;
41  virtual void SetPosition(size_t position) = 0;
42 
43 public: // virutal operations
44  virtual void Flush(void) = 0;
45  virtual size_t Seek(size_t offset, SeekOrigin origin) = 0;
46  virtual size_t Read(byte* pBuffer, size_t bufferSize, size_t offset, size_t count) = 0;
47  virtual void Write(const byte* pBuffer, size_t bufferSize, size_t offset, size_t count) = 0;
48  virtual byte ReadByte(void);
49  virtual void WriteByte(byte value);
50  virtual void CopyTo(Stream& other);
51 
52 public: // operations
53  void Dispose(void);
54  void Close(void);
55 
56 protected: // operations
57  boolean IsDisposed(void);
58  void CheckDisposed(void);
59  virtual void InternalDispose(void) = 0;
60 
61 private: // fields
62  bool isDisposed;
63 };
64 
66 // inline methods of class Stream
67 
68 inline Stream::Stream(void)
69  : isDisposed(false)
70 {
71 }
72 
73 inline Stream::~Stream(void)
74 {
75 }
76 
77 inline boolean Stream::IsDisposed(void)
78 {
79  return this->isDisposed;
80 }
81 
82 }}}} // end of namespace Arp::System::Commons::Io
Definition: NullStream.hpp:14
Provides a generic view of a sequence of bytes.
Definition: Stream.hpp:20
Stream & operator=(const Stream &arg)=delete
Assignment operator.
Stream(const Stream &arg)=delete
Copy constructor.
Stream(void)
Constructs an Stream instance.
Definition: Stream.hpp:68
virtual ~Stream(void)
Destructs this instance and frees all resources.
Definition: Stream.hpp:73
@ System
System components used by the System, Device, Plc or Io domains.
SeekOrigin
Provides seek reference points. To seek to the end of a stream, call stream.Seek(0,...
Definition: SeekOrigin.hpp:20
Root namespace for the PLCnext API