SmartEngine  1.6.0
MemoryBuffer.h
1 // Copyright (C) Entropy Software LLC - All Rights Reserved
2 
3 #pragma once
4 
5 #include "Object.h"
6 
7 namespace SmartEngine
8 {
9 
14 class SMARTENGINE_EXPORT IMemoryBuffer : public virtual IObject
15 {
16 public:
17  SMARTENGINE_DECLARE_CLASS(IMemoryBuffer)
18 
19 
20  virtual void ResetReadPosition() = 0;
23 
27  virtual void ClearData() = 0;
28 
33  virtual void SetData(const byte* data, int64 count) = 0;
34 
39  virtual const byte* GetData() const = 0;
40 
44  virtual int64 GetCount() const = 0;
45 
46  virtual bool ReadBool() = 0;
47  virtual void WriteBool(bool value) = 0;
48 
49  virtual int ReadInt() = 0;
50  virtual void WriteInt(int value) = 0;
51 
52  virtual int64 ReadInt64() = 0;
53  virtual void WriteInt64(int64 value) = 0;
54 
55  virtual float ReadFloat() = 0;
56  virtual void WriteFloat(float value) = 0;
57 
58  virtual void WriteString(const char* value) = 0;
59 
60  virtual void ReadBuffer(byte* data, int64 len) = 0;
61  virtual void WriteBuffer(byte* data, int64 len) = 0;
62 };
63 
68 
70 extern "C"
71 {
72  SMARTENGINE_EXPORT ObjPtr MemoryBuffer_CreateInstance();
73  SMARTENGINE_EXPORT void MemoryBuffer_ResetReadPosition(ObjPtr object);
74  SMARTENGINE_EXPORT void MemoryBuffer_ClearData(ObjPtr object);
75  SMARTENGINE_EXPORT const byte* MemoryBuffer_GetData(ObjPtr object);
76  SMARTENGINE_EXPORT int64 MemoryBuffer_GetCount(ObjPtr object);
77  SMARTENGINE_EXPORT void MemoryBuffer_SetData(ObjPtr object, byte* data, int64 count);
78  SMARTENGINE_EXPORT int MemoryBuffer_ReadBool(ObjPtr object);
79  SMARTENGINE_EXPORT void MemoryBuffer_WriteBool(ObjPtr object, int value);
80  SMARTENGINE_EXPORT int MemoryBuffer_ReadInt(ObjPtr object);
81  SMARTENGINE_EXPORT void MemoryBuffer_WriteInt(ObjPtr object, int value);
82  SMARTENGINE_EXPORT float MemoryBuffer_ReadFloat(ObjPtr object);
83  SMARTENGINE_EXPORT void MemoryBuffer_WriteFloat(ObjPtr object, float value);
84  SMARTENGINE_EXPORT void MemoryBuffer_ReadBuffer(ObjPtr object, byte* data, int64 len);
85  SMARTENGINE_EXPORT void MemoryBuffer_WriteBuffer(ObjPtr object, byte* data, int64 len);
86 }
88 
89 } // namespace SmartEngine
SmartEngine::IMemoryBuffer::WriteInt64
virtual void WriteInt64(int64 value)=0
SmartEngine::IMemoryBuffer::WriteFloat
virtual void WriteFloat(float value)=0
SmartEngine::IMemoryBuffer::GetCount
virtual int64 GetCount() const =0
Returns the byte count of the data array
SmartEngine::CreateMemoryBuffer
SMARTENGINE_EXPORT ObjectPtr< IMemoryBuffer > CreateMemoryBuffer()
Creates an instance of IMemoryBuffer
SmartEngine::IMemoryBuffer::WriteInt
virtual void WriteInt(int value)=0
SmartEngine::IMemoryBuffer::SetData
virtual void SetData(const byte *data, int64 count)=0
Directly sets the buffer's data.
SmartEngine::ObjectPtr
Smart pointer to an IObject. Automatic ref counting.
Definition: ObjectPtr.h:16
SmartEngine
Definition: A2CTrainer.h:10
SmartEngine::IObject
Base class for SmartEngine AI objects. It is not common to deal with this class directly.
Definition: Object.h:19
SmartEngine::IMemoryBuffer::ReadBuffer
virtual void ReadBuffer(byte *data, int64 len)=0
SmartEngine::IMemoryBuffer::ReadFloat
virtual float ReadFloat()=0
SmartEngine::IMemoryBuffer::WriteBool
virtual void WriteBool(bool value)=0
SmartEngine::IMemoryBuffer::ReadInt
virtual int ReadInt()=0
SmartEngine::IMemoryBuffer::WriteString
virtual void WriteString(const char *value)=0
SmartEngine::IMemoryBuffer::ReadBool
virtual bool ReadBool()=0
SmartEngine::IMemoryBuffer::GetData
virtual const byte * GetData() const =0
Returns the buffer's data as a byte array.
SmartEngine::IMemoryBuffer::ReadInt64
virtual int64 ReadInt64()=0
SmartEngine::IMemoryBuffer::ClearData
virtual void ClearData()=0
Clears all data from the buffer.
SmartEngine::IMemoryBuffer
Simple in memory buffer. Used for serialization, but can be used as a generic buffer too.
Definition: MemoryBuffer.h:15
SmartEngine::IMemoryBuffer::WriteBuffer
virtual void WriteBuffer(byte *data, int64 len)=0