Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
BufferAccessor.cpp
1/*
2Copyright (C) 2019,2021,2025 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17#include "aeongames/BufferAccessor.hpp"
18#include "aeongames/Buffer.hpp"
19#include "aeongames/MemoryPoolBuffer.hpp"
20
21namespace AeonGames
22{
23 BufferAccessor::BufferAccessor ( MemoryPoolBuffer* aMemoryPoolBuffer, size_t aOffset, size_t aSize ) :
24 mMemoryPoolBuffer{aMemoryPoolBuffer}, mOffset{aOffset}, mSize{aSize}
25 {}
26
32
33 void BufferAccessor::WriteMemory ( size_t aOffset, size_t aSize, const void *aData ) const
34 {
35 if ( mMemoryPoolBuffer != nullptr )
36 {
37 mMemoryPoolBuffer->GetBuffer().WriteMemory ( mOffset + aOffset, aSize, aData );
38 }
39 }
40 void* BufferAccessor::Map ( size_t aOffset, size_t aSize ) const
41 {
42 aSize = ( aSize != 0 ) ? aSize : mSize;
43 return ( mMemoryPoolBuffer != nullptr ) ? mMemoryPoolBuffer->GetBuffer().Map ( mOffset + aOffset, aSize ) : nullptr;
44 }
46 {
47 if ( mMemoryPoolBuffer != nullptr )
48 {
49 mMemoryPoolBuffer->GetBuffer().Unmap();
50 }
51 }
53 {
54 return mOffset;
55 }
57 {
58 return mSize;
59 }
61 {
62 return mMemoryPoolBuffer;
63 }
64}
Provides access to a region within a memory pool buffer.
DLL const MemoryPoolBuffer * GetMemoryPoolBuffer() const
Get the underlying memory pool buffer.
DLL void WriteMemory(size_t aOffset, size_t aSize, const void *aData=nullptr) const
Write data into the buffer region.
DLL BufferAccessor & operator=(const BufferAccessor &)
Copy assignment operator.
DLL size_t GetOffset() const
Get the byte offset of this accessor within the memory pool buffer.
DLL void Unmap() const
Unmap a previously mapped buffer region.
DLL BufferAccessor()
Default constructor.
DLL size_t GetSize() const
Get the size of the accessible region.
DLL void * Map(size_t aOffset=0, size_t aSize=0) const
Map the buffer region into host-accessible memory.
Abstract interface for a pool-based buffer allocator.
<- This is here just for the literals
Definition AABB.hpp:31