PLCnext API Documentation  21.0.0.35466
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 
16 class Stream
17 {
18 public: // construction/destruction
20  Stream(void);
22  Stream(const Stream& arg) = delete;
24  Stream& operator=(const Stream& arg) = delete;
26  virtual ~Stream(void);
27 
28 public: // setter/getter operations
29  virtual boolean CanRead(void) = 0;
30  virtual boolean CanWrite(void) = 0;
31  virtual boolean CanSeek(void) = 0;
32  virtual size_t GetLength(void) = 0;
33  virtual void SetLength(size_t length) = 0;
34  virtual size_t GetPosition(void) = 0;
35  virtual void SetPosition(size_t position) = 0;
36 
37 public: // operations
38  virtual void Flush(void) = 0;
39  virtual size_t Seek(size_t offset, SeekOrigin origin) = 0;
40  virtual size_t Read(byte* pBuffer, size_t bufferSize, size_t offset, size_t count) = 0;
41  virtual void Write(const byte* pBuffer, size_t bufferSize, size_t offset, size_t count) = 0;
42 
43  virtual byte ReadByte(void);
44  virtual void WriteByte(byte value);
45 
46  void Dispose(void);
47  void Close(void);
48 
49 protected: // operations
50  boolean IsDisposed(void);
51  void CheckDisposed(void);
52  virtual void InternalDispose(void) = 0;
53 
54 private: // methods
55 
56 private: // fields
57  bool isDisposed;
58 };
59 
61 // inline methods of class Stream
62 
63 inline Stream::Stream(void)
64  : isDisposed(false)
65 {
66 }
67 
68 inline Stream::~Stream(void)
69 {
70 }
71 
72 inline boolean Stream::IsDisposed(void)
73 {
74  return this->isDisposed;
75 }
76 
77 }}}} // end of namespace Arp::System::Commons::Io
Stream(void)
Constructs an Stream instance.
Definition: Stream.hpp:63
virtual ~Stream(void)
Destructs this instance and frees all resources.
Definition: Stream.hpp:68
Stream & operator=(const Stream &arg)=delete
Assignment operator.
Provides a generic view of a sequence of bytes.
Definition: Stream.hpp:16
Root namespace for the PLCnext API
SeekOrigin
Provides seek reference points. To seek to the end of a stream, call stream.Seek(0, SeekOrigin.End).
Definition: SeekOrigin.hpp:19
System components used by the System, Device, Plc or Io domains.
unsigned char byte
The Arp character type.
Definition: PrimitiveTypes.hpp:23