Path: blob/master/thirdparty/jolt_physics/Jolt/Physics/StateRecorderImpl.h
9906 views
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)1// SPDX-FileCopyrightText: 2021 Jorrit Rouwe2// SPDX-License-Identifier: MIT34#pragma once56#include <Jolt/Physics/StateRecorder.h>78JPH_NAMESPACE_BEGIN910/// Implementation of the StateRecorder class that uses a stringstream as underlying store and that implements checking if the state doesn't change upon reading11class JPH_EXPORT StateRecorderImpl final : public StateRecorder12{13public:14/// Constructor15StateRecorderImpl() = default;16StateRecorderImpl(StateRecorderImpl &&inRHS) : StateRecorder(inRHS), mStream(std::move(inRHS.mStream)) { }1718/// Write a string of bytes to the binary stream19virtual void WriteBytes(const void *inData, size_t inNumBytes) override;2021/// Rewind the stream for reading22void Rewind();2324/// Clear the stream for reuse25void Clear();2627/// Read a string of bytes from the binary stream28virtual void ReadBytes(void *outData, size_t inNumBytes) override;2930// See StreamIn31virtual bool IsEOF() const override { return mStream.eof(); }3233// See StreamIn / StreamOut34virtual bool IsFailed() const override { return mStream.fail(); }3536/// Compare this state with a reference state and ensure they are the same37bool IsEqual(StateRecorderImpl &inReference);3839/// Convert the binary data to a string40std::string GetData() const { return mStream.str(); }4142/// Get size of the binary data in bytes43size_t GetDataSize() { return size_t(mStream.tellp()); }4445private:46std::stringstream mStream;47};4849JPH_NAMESPACE_END505152