Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
MemoryView.hpp
1 // Copyright (C) 2017 Jérôme Leclercq
2 // This file is part of the "Nazara Engine - Core module"
3 // For conditions of distribution and use, see copyright notice in Config.hpp
4 
5 #pragma once
6 
7 #ifndef NAZARA_MEMORYVIEW_HPP
8 #define NAZARA_MEMORYVIEW_HPP
9 
10 #include <Nazara/Prerequesites.hpp>
11 #include <Nazara/Core/Stream.hpp>
12 
13 namespace Nz
14 {
15  class NAZARA_CORE_API MemoryView : public Stream
16  {
17  public:
18  MemoryView(void* ptr, UInt64 size);
19  MemoryView(const void* ptr, UInt64 size);
20  MemoryView(const MemoryView&) = delete;
21  MemoryView(MemoryView&&) = delete;
22  ~MemoryView() = default;
23 
24  bool EndOfStream() const override;
25 
26  UInt64 GetCursorPos() const override;
27  UInt64 GetSize() const override;
28 
29  bool SetCursorPos(UInt64 offset) override;
30 
31  MemoryView& operator=(const MemoryView&) = delete;
32  MemoryView& operator=(MemoryView&&) = delete;
33 
34  private:
35  void FlushStream() override;
36  std::size_t ReadBlock(void* buffer, std::size_t size) override;
37  std::size_t WriteBlock(const void* buffer, std::size_t size) override;
38 
39  UInt8* m_ptr;
40  UInt64 m_pos;
41  UInt64 m_size;
42  };
43 }
44 
45 #endif // NAZARA_MEMORYVIEW_HPP
TODO: Inherit SoundEmitter from Node.
Definition: Algorithm.hpp:12
Core class that represents a view of the memory behaving like a stream.
Definition: MemoryView.hpp:15
Core class that represents a stream.
Definition: Stream.hpp:19