Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
StateRecorderImpl.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
8
10
13{
14public:
16 StateRecorderImpl() = default;
17 StateRecorderImpl(StateRecorderImpl &&inRHS) : StateRecorder(inRHS), mStream(std::move(inRHS.mStream)) { }
18
20 virtual void WriteBytes(const void *inData, size_t inNumBytes) override;
21
23 void Rewind();
24
26 void Clear();
27
29 virtual void ReadBytes(void *outData, size_t inNumBytes) override;
30
31 // See StreamIn
32 virtual bool IsEOF() const override { return mStream.eof(); }
33
34 // See StreamIn / StreamOut
35 virtual bool IsFailed() const override { return mStream.fail(); }
36
38 bool IsEqual(StateRecorderImpl &inReference);
39
41 std::string GetData() const { return mStream.str(); }
42
44 size_t GetDataSize() { return size_t(mStream.tellp()); }
45
46private:
47 std::stringstream mStream;
48};
49
#define JPH_EXPORT
Definition Core.h:271
#define JPH_NAMESPACE_END
Definition Core.h:414
#define JPH_NAMESPACE_BEGIN
Definition Core.h:408
Definition StateRecorder.h:110
Implementation of the StateRecorder class that uses a stringstream as underlying store and that imple...
Definition StateRecorderImpl.h:13
StateRecorderImpl()=default
Constructor.
size_t GetDataSize()
Get size of the binary data in bytes.
Definition StateRecorderImpl.h:44
virtual bool IsFailed() const override
Returns true if there was an IO failure.
Definition StateRecorderImpl.h:35
virtual bool IsEOF() const override
Returns true when an attempt has been made to read past the end of the file.
Definition StateRecorderImpl.h:32
StateRecorderImpl(StateRecorderImpl &&inRHS)
Definition StateRecorderImpl.h:17
std::string GetData() const
Convert the binary data to a string.
Definition StateRecorderImpl.h:41
virtual void ReadBytes(void *outData, size_t inNumBytes)=0
Read a string of bytes from the binary stream.
virtual void WriteBytes(const void *inData, size_t inNumBytes)=0
Write a string of bytes to the binary stream.
Definition Array.h:590