Skip to content

Commit 22cc5e3

Browse files
fix horrible circular references and self namespace nesting
1 parent 704d892 commit 22cc5e3

File tree

5 files changed

+27
-33
lines changed

5 files changed

+27
-33
lines changed
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
#ifndef _NBL_SYSTEM_C_FILE_VIEW_VIRTUAL_ALLOCATOR_POSIX_H_INCLUDED_
22
#define _NBL_SYSTEM_C_FILE_VIEW_VIRTUAL_ALLOCATOR_POSIX_H_INCLUDED_
33

4-
5-
#include "nbl/system/IFileViewAllocator.h"
6-
7-
8-
#if defined(_NBL_PLATFORM_LINUX_) || defined(_NBL_PLATFORM_ANDROID_)
9-
namespace nbl::system
4+
namespace nbl::system
105
{
11-
6+
#if defined(_NBL_PLATFORM_LINUX_) || defined(_NBL_PLATFORM_ANDROID_)
127
class CFileViewVirtualAllocatorPOSIX : public IFileViewAllocator
138
{
149
public:
1510
void* alloc(size_t size) override;
1611
bool dealloc(void* data, size_t size) override;
1712
};
18-
19-
}
2013
#endif
14+
}
15+
2116
#endif

include/nbl/system/CFileViewVirtualAllocatorWin32.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#ifndef _NBL_SYSTEM_C_FILE_VIEW_VIRTUAL_ALLOCATOR_WIN32_H_INCLUDED_
22
#define _NBL_SYSTEM_C_FILE_VIEW_VIRTUAL_ALLOCATOR_WIN32_H_INCLUDED_
33

4-
5-
#include "nbl/system/IFileViewAllocator.h"
6-
7-
84
namespace nbl::system
95
{
106
#ifdef _NBL_PLATFORM_WINDOWS_
Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
#ifndef _NBL_SYSTEM_I_FILE_ALLOCATOR_H_INCLUDED_
22
#define _NBL_SYSTEM_I_FILE_ALLOCATOR_H_INCLUDED_
33

4+
#include "nbl/core/declarations.h"
5+
46
#include <cstdint>
57
#include <cstdlib>
68

79
namespace nbl::system
810
{
911

10-
// This interface class provides the callbacks for `CFileView` which creates a mapped file over some memory
11-
class IFileViewAllocator
12-
{
12+
// This interface class provides the callbacks for `CFileView` which creates a mapped file over some memory
13+
class IFileViewAllocator
14+
{
1315
public:
1416
virtual void* alloc(size_t size) = 0;
1517
virtual bool dealloc(void* data, size_t size) = 0;
16-
};
18+
};
1719

18-
// Regular old file in RAM
19-
class CPlainHeapAllocator : public IFileViewAllocator
20-
{
20+
// Regular old file in RAM
21+
class CPlainHeapAllocator : public IFileViewAllocator
22+
{
2123
public:
2224
void* alloc(size_t size) override
2325
{
@@ -28,12 +30,12 @@ namespace nbl::system
2830
free(data);
2931
return true;
3032
}
31-
};
33+
};
3234

33-
// This allocator is useful to create an `IFile` over memory that already contains something or is owned by some other component
34-
// e.g. memory mapped IGPUBuffer, string_view or a string, or buffers handed out by other APIs
35-
class CNullAllocator : public IFileViewAllocator
36-
{
35+
// This allocator is useful to create an `IFile` over memory that already contains something or is owned by some other component
36+
// e.g. memory mapped IGPUBuffer, string_view or a string, or buffers handed out by other APIs
37+
class CNullAllocator : public IFileViewAllocator
38+
{
3739
public:
3840
void* alloc(size_t size) override
3941
{
@@ -43,17 +45,18 @@ namespace nbl::system
4345
{
4446
return true;
4547
}
46-
};
48+
};
49+
50+
}
4751

4852
#ifdef _NBL_PLATFORM_WINDOWS_
49-
#include <nbl/system/CFileViewVirtualAllocatorWin32.h>
50-
using VirtualMemoryAllocator = CFileViewVirtualAllocatorWin32;
53+
#include "nbl/system/CFileViewVirtualAllocatorWin32.h"
54+
using VirtualMemoryAllocator = nbl::system::CFileViewVirtualAllocatorWin32;
5155
#elif defined(_NBL_PLATFORM_LINUX_) || defined(_NBL_PLATFORM_ANDROID_)
52-
#include <nbl/system/CFileViewVirtualAllocatorPOSIX.h>
53-
using VirtualMemoryAllocator = CFileViewVirtualAllocatorPOSIX;
56+
#include "nbl/system/CFileViewVirtualAllocatorPOSIX.h"
57+
using VirtualMemoryAllocator = nbl::system::CFileViewVirtualAllocatorPOSIX;
5458
#else
5559
#error "Unsupported platform!"
5660
#endif
57-
}
5861

5962
#endif

src/nbl/system/CFileViewVirtualAllocatorPOSIX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "nbl/system/CFileViewVirtualAllocatorPOSIX.h"
1+
#include "nbl/system/IFileViewAllocator.h"
22

33
using namespace nbl::system;
44

src/nbl/system/CFileViewVirtualAllocatorWin32.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "nbl/system/CFileViewVirtualAllocatorWin32.h"
1+
#include "nbl/system/IFileViewAllocator.h"
22

33
using namespace nbl::system;
44

0 commit comments

Comments
 (0)