CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
Stream.Pipe.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "Stream.hpp"
11
12namespace CeresEngine {
13
16 class PipeStream : public virtual IStream {
17 protected:
19 struct State;
20
23
24 private:
27
28 public:
29 PipeStream(const PipeStream&) = delete;
30 PipeStream& operator=(const PipeStream&) = delete;
31
34
35 public:
39
40 public: // IStream interface
42 [[nodiscard]] bool isSeekable(Seek mode = Seek::Start) const noexcept final { return false; }
43
45 [[nodiscard]] bool isTellable() const noexcept final { return false; }
46
48 [[nodiscard]] bool isSizeKnown() const noexcept final { return false; }
49 };
50
53
55 class PipeInputStream : public virtual PipeStream, public IInputStream {
56 public:
60
61 public: // IInputStream interface
63 [[nodiscard]] bool isReadable() const noexcept final { return true; }
64
66 [[nodiscard]] size_t read(void* data, size_t n) final;
67
71 };
72
74 class PipeOutputStream : public virtual PipeStream, public IOutputStream {
75 public:
79
80
81 public: // IOutputStream interface
83 [[nodiscard]] bool isWritable() const noexcept final { return true; }
84
86 [[nodiscard]] size_t write(const void* data, size_t n) final;
87
91 };
93} // namespace CeresEngine
#define CE_DISABLE_WARNING_INHERITS_VIA_DOMINANCE
Definition Macros.hpp:501
#define CE_DISABLE_WARNING_POP
Definition Macros.hpp:485
#define CE_DISABLE_WARNING_PUSH
Definition Macros.hpp:484
A stream that provides read-only stream functionality.
Definition Stream.hpp:126
A stream that provides write-only stream functionality.
Definition Stream.hpp:233
An interface that all data streams must implement.
Definition Stream.hpp:58
Seek
An enumeration that describes how a data stream should be seeked.
Definition Stream.hpp:72
A stream that provides read-only stream functionality.
Definition Stream.hpp:210
A stream that provides write-only stream functionality.
Definition Stream.hpp:307
An input stream that allows reading data written by the paired PipeOutputStream.
Definition Stream.Pipe.hpp:55
PipeInputStream(PipeInputStream &&) noexcept=default
bool isReadable() const noexcept final
Checks if the stream is readable.
Definition Stream.Pipe.hpp:63
size_t read(void *data, size_t n) final
Reads data from the data stream to a buffer of raw memory data with length n.
An output stream that allows writing data to be read by the paired PipeInputStream.
Definition Stream.Pipe.hpp:74
PipeOutputStream(PipeOutputStream &&) noexcept=default
bool isWritable() const noexcept final
Checks if the stream is writable.
Definition Stream.Pipe.hpp:83
size_t write(const void *data, size_t n) final
Writes data to the data stream from a buffer of raw memory data with length n.
A base class for streams that allows reading from a PipeInputStream, all data written to the PipeOutp...
Definition Stream.Pipe.hpp:16
PipeStream(SPtr< State > state)
Constructs a new stream with an existing state.
bool isSeekable(Seek mode=Seek::Start) const noexcept final
Checks if the stream is seekable.
Definition Stream.Pipe.hpp:42
PipeStream & operator=(const PipeStream &)=delete
SPtr< State > mState
Definition Stream.Pipe.hpp:22
static Pair< InputStream, OutputStream > open()
Opens a new pair of PipeInputStream and PipeOutputStream.
PipeStream(const PipeStream &)=delete
bool isTellable() const noexcept final
Checks if the stream knows it's current absolute position.
Definition Stream.Pipe.hpp:45
PipeStream(PipeStream &&) noexcept
bool isSizeKnown() const noexcept final
Checks if the stream knows the size of the data.
Definition Stream.Pipe.hpp:48
Definition Application.hpp:19
std::shared_ptr< T > SPtr
SPtr is a smart pointer that retains shared ownership of an object through a pointer.
Definition SmartPtr.hpp:37
std::pair< First, Second > Pair
Pair is a struct template that provides a way to store two heterogeneous objects as a single unit.
Definition Pair.hpp:18
struct CeresEngine::GLState state
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25