Plasma Engine  2.0
Loading...
Searching...
No Matches
Basics.h
1#pragma once
2
3#define PL_INCLUDING_BASICS_H
4
5// Very basic Preprocessor defines
6#include <Foundation/Basics/PreprocessorUtils.h>
7
8// Set all feature #defines to PL_OFF
9#include <Foundation/Basics/AllDefinesOff.h>
10
11// General detection of the OS and hardware
12#include <Foundation/Basics/Platform/DetectArchitecture.h>
13#include <Foundation/Basics/Platform/DetectPlatform.h>
14
15// Options by the user to override the build
16#include <Foundation/UserConfig.h>
17
18// Configure the DLL Import/Export Define
19#if PL_ENABLED(PL_COMPILE_ENGINE_AS_DLL)
20# ifdef BUILDSYSTEM_BUILDING_FOUNDATION_LIB
21# define PL_FOUNDATION_DLL PL_DECL_EXPORT
22# define PL_FOUNDATION_DLL_FRIEND PL_DECL_EXPORT_FRIEND
23# else
24# define PL_FOUNDATION_DLL PL_DECL_IMPORT
25# define PL_FOUNDATION_DLL_FRIEND PL_DECL_IMPORT_FRIEND
26# endif
27#else
28# define PL_FOUNDATION_DLL
29# define PL_FOUNDATION_DLL_FRIEND
30#endif
31
32#include <Foundation/FoundationInternal.h>
33
34// include the different headers for the supported platforms
35#if PL_ENABLED(PL_PLATFORM_WINDOWS)
36# include <Foundation/Basics/Platform/Win/Platform_win.h>
37#elif PL_ENABLED(PL_PLATFORM_OSX)
38# include <Foundation/Basics/Platform/OSX/Platform_OSX.h>
39#elif PL_ENABLED(PL_PLATFORM_LINUX) || PL_ENABLED(PL_PLATFORM_ANDROID)
40# include <Foundation/Basics/Platform/Linux/Platform_Linux.h>
41#else
42# error "Undefined platform!"
43#endif
44
45// include headers for the supported compilers
46#include <Foundation/Basics/Compiler/Clang.h>
47#include <Foundation/Basics/Compiler/GCC.h>
48#include <Foundation/Basics/Compiler/MSVC.h>
49
50// Here all the different features that each platform supports are declared.
51#include <Foundation/Basics/Platform/PlatformFeatures.h>
52
53// Include this last, it will ensure the previous includes have setup everything correctly
54#include <Foundation/Basics/Platform/CheckDefinitions.h>
55
56// Include common definitions and macros (e.g. static_assert)
57#include <Foundation/Basics/Platform/Common.h>
58
59// Include magic preprocessor macros
60#include <Foundation/Basics/Platform/BlackMagic.h>
61
62// Now declare all fundamental types
63#include <Foundation/Types/Types.h>
64
65// Type trait utilities
66#include <Foundation/Types/TypeTraits.h>
67
68// Assert macros should always be available
69#include <Foundation/Basics/Assert.h>
70
71// String formatting is needed by the asserts
72#include <Foundation/Strings/FormatString.h>
73
74
75class PL_FOUNDATION_DLL plFoundation
76{
77public:
78 static plAllocator* s_pDefaultAllocator;
79 static plAllocator* s_pAlignedAllocator;
80
82 PL_ALWAYS_INLINE static plAllocator* GetDefaultAllocator()
83 {
84 if (s_bIsInitialized)
85 return s_pDefaultAllocator;
86 else // the default allocator is not yet set so we return the static allocator instead.
87 return GetStaticsAllocator();
88 }
89
91 PL_ALWAYS_INLINE static plAllocator* GetAlignedAllocator()
92 {
93 PL_ASSERT_ALWAYS(s_pAlignedAllocator != nullptr,
94 "plFoundation must have been initialized before this function can be called."
95 "This error can occur when you have a global variable or a static member variable that (indirectly) requires an allocator."
96 "Check out the documentation for 'plStaticsAllocatorWrapper' for more information about this issue.");
97 return s_pAlignedAllocator;
98 }
99
101 static plAllocator* GetStaticsAllocator();
102
103private:
104 friend class plStartup;
105 friend struct plStaticsAllocatorWrapper;
106
107 static void Initialize();
108 static bool s_bIsInitialized;
109};
110
111#undef PL_INCLUDING_BASICS_H
Base class for all memory allocators.
Definition Allocator.h:23
Definition Basics.h:76
static PL_ALWAYS_INLINE plAllocator * GetDefaultAllocator()
The default allocator can be used for any kind of allocation if no alignment is required.
Definition Basics.h:82
static PL_ALWAYS_INLINE plAllocator * GetAlignedAllocator()
The aligned allocator should be used for all allocations which need alignment.
Definition Basics.h:91
The startup system makes sure to initialize and shut down all known subsystems in the proper order.
Definition Startup.h:77
Definition AllocatorWrapper.h:20