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
12class StateRecorderImpl final : public StateRecorder
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 virtual void ReadBytes(void *outData, size_t inNumBytes) override;
27
28 // See StreamIn
29 virtual bool IsEOF() const override { return mStream.eof(); }
30
31 // See StreamIn / StreamOut
32 virtual bool IsFailed() const override { return mStream.fail(); }
33
35 bool IsEqual(StateRecorderImpl &inReference);
36
38 string GetData() const { return mStream.str(); }
39
40private:
41 std::stringstream mStream;
42};
43
#define JPH_NAMESPACE_END
Definition: Core.h:240
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:234
Definition: StateRecorder.h:15
Implementation of the StateRecorder class that uses a stringstream as underlying store and that imple...
Definition: StateRecorderImpl.h:13
StateRecorderImpl()=default
Constructor.
virtual void ReadBytes(void *outData, size_t inNumBytes) override
Read a string of bytes from the binary stream.
Definition: StateRecorderImpl.cpp:21
virtual bool IsFailed() const override
Returns true if there was an IO failure.
Definition: StateRecorderImpl.h:32
string GetData() const
Convert the binary data to a string.
Definition: StateRecorderImpl.h:38
virtual bool IsEOF() const override
Returns true when an attempt has been made to read past the end of the file.
Definition: StateRecorderImpl.h:29
void Rewind()
Rewind the stream for reading.
Definition: StateRecorderImpl.cpp:16
StateRecorderImpl(StateRecorderImpl &&inRHS)
Definition: StateRecorderImpl.h:17
virtual void WriteBytes(const void *inData, size_t inNumBytes) override
Write a string of bytes to the binary stream.
Definition: StateRecorderImpl.cpp:11
bool IsEqual(StateRecorderImpl &inReference)
Compare this state with a reference state and ensure they are the same.
Definition: StateRecorderImpl.cpp:50
Definition: Reference.h:207