Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
PlatformDefines.h File Reference

Go to the source code of this file.

Classes

class  function_view< TReturn(TArgs...)>
 
struct  Divide::SysInfo
 
union  Divide::Float_t
 
union  Divide::Double_t
 
class  Divide::detail::ScopeGuard< Fun >
 
class  Divide::detail::UncaughtExceptionCounter
 
class  Divide::detail::ScopeGuardForNewException< FunctionType, executeOnException >
 
struct  Divide::Handle< T >
 
struct  Divide::safe_static_cast_helper< false, false >
 
struct  Divide::safe_static_cast_helper< false, true >
 
struct  Divide::safe_static_cast_helper< true, false >
 
struct  Divide::safe_static_cast_helper< true, true >
 

Namespaces

namespace  Divide
 Handle console commands that start with a forward slash.
 
namespace  Divide::detail
 
namespace  Divide::Assert
 

Concepts

concept  Divide::has_reserve
 
concept  Divide::has_emplace_back
 
concept  Divide::has_assign
 

Macros

#define DVD_PLATFORM_DEFINES_H_
 
#define EXP(x)   x
 
#define GET_3RD_ARG(arg1, arg2, arg3, ...)   arg3
 
#define GET_4TH_ARG(arg1, arg2, arg3, arg4, ...)   arg4
 
#define GET_5TH_ARG(arg1, arg2, arg3, arg4, arg5, ...)   arg5
 
#define GET_6TH_ARG(arg1, arg2, arg3, arg4, arg5, arg6, ...)   arg6
 
#define STUBBED(x)   static_assert(true, "")
 
#define TO_STRING_NAME(X)   #X
 
#define TO_STRING(X)   TO_STRING_NAME(X)
 
#define TYPEDEF_SMART_POINTERS_FOR_TYPE(T)
 
#define FWD_DECLARE_MANAGED_CLASS(T)
 
#define FWD_DECLARE_MANAGED_STRUCT(T)
 
#define CONCATENATE_IMPL(s1, s2)   s1##s2
 
#define CONCATENATE(s1, s2)   CONCATENATE_IMPL(s1, s2)
 
#define ANONYMOUSE_VARIABLE(str)   CONCATENATE(str, __LINE__)
 
#define _FUNCTION_NAME_AND_SIG_   __FUNCTION__
 
#define NO_DESTROY
 
#define ALIAS_TEMPLATE_FUNCTION(highLevelF, lowLevelF)
 
#define NOP()   static_assert(true, "")
 
#define SCOPE_FAIL   auto ANONYMOUS_VARIABLE(SCOPE_FAIL_STATE) = detail::ScopeGuardOnFail() + [&]() noexcept
 
#define SCOPE_SUCCESS   auto ANONYMOUS_VARIABLE(SCOPE_FAIL_STATE) = detail::ScopeGuardOnSuccess() + [&]()
 
#define SCOPE_EXIT   auto ANONYMOUS_VARIABLE(SCOPE_EXIT_STATE) = detail::ScopeGuardOnExit() + [&]() noexcept
 
#define DIVIDE_ASSERT_2_ARGS(expression, msg)   Assert::DIVIDE_ASSERT_FUNC(expression, #expression, __FILE__, __LINE__, msg)
 
#define DIVIDE_ASSERT_1_ARGS(expression)   DIVIDE_ASSERT_2_ARGS(expression, "UNEXPECTED CALL")
 
#define ___DETAIL_DIVIDE_ASSERT(...)   EXP(GET_3RD_ARG(__VA_ARGS__, DIVIDE_ASSERT_2_ARGS, DIVIDE_ASSERT_1_ARGS, ))
 
#define DIVIDE_ASSERT(...)   EXP(___DETAIL_DIVIDE_ASSERT(__VA_ARGS__)(__VA_ARGS__))
 
#define DIVIDE_UNEXPECTED_CALL_MSG(X)   DIVIDE_ASSERT(false, X)
 
#define DIVIDE_UNEXPECTED_CALL()   DIVIDE_UNEXPECTED_CALL_MSG("UNEXPECTED CALL")
 

Typedefs

using Divide::PlayerIndex = U8
 
template<typename Ret , typename... Args>
using Divide::DELEGATE_EASTL = eastl::function< Ret(Args...) >
 
template<typename Ret , typename... Args>
using Divide::DELEGATE_STD = std::function< Ret(Args...) >
 
template<typename Ret , typename... Args>
using Divide::DELEGATE = DELEGATE_STD< Ret, Args... >
 

Enumerations

enum class  Divide::ThreadPriority : U8 {
  Divide::IDLE = 0 , Divide::BELOW_NORMAL , Divide::NORMAL , Divide::ABOVE_NORMAL ,
  Divide::HIGHEST , Divide::TIME_CRITICAL , Divide::COUNT
}
 
enum class  Divide::detail::ScopeGuardOnExit
 
enum class  Divide::detail::ScopeGuardOnFail
 
enum class  Divide::detail::ScopeGuardOnSuccess
 

Functions

template<typename... Args>
constexpr auto ArrayCount (Args &&... args) -> decltype(std::size(FWD(args)...))
 
constexpr U64 Divide::_ID_VIEW (const char *const str, const size_t len, const U64 value=val_64_const) noexcept
 
constexpr U64 Divide::_ID (const char *const str, const U64 value=val_64_const) noexcept
 
constexpr U64 Divide::_ID (const std::string_view str, const U64 value=val_64_const) noexcept
 
constexpr U64 Divide::operator""_id (const char *str, const size_t len)
 
SysInfo & Divide::sysInfo () noexcept
 
const SysInfo & Divide::const_sysInfo () noexcept
 
void Divide::InitSysInfo (SysInfo &info, I32 argc, char **argv)
 
F32 Divide::PlatformDefaultDPI () noexcept
 
void Divide::GetWindowHandle (void *window, WindowHandle &handleOut) noexcept
 
void Divide::SetThreadPriority (ThreadPriority priority)
 
void Divide::SetThreadName (std::string_view threadName) noexcept
 
bool Divide::CallSystemCmd (std::string_view cmd, std::string_view args)
 
bool Divide::DebugBreak (const bool condition) noexcept
 
ErrorCode Divide::PlatformInit (int argc, char **argv)
 
bool Divide::PlatformClose ()
 
bool Divide::GetAvailableMemory (SysInfo &info)
 
void Divide::EnforceDPIScaling () noexcept
 
const char * Divide::GetClipboardText () noexcept
 
void Divide::SetClipboardText (const char *text) noexcept
 
void Divide::ToggleCursor (bool state) noexcept
 
bool Divide::CursorState () noexcept
 
std::string Divide::CurrentDateTimeString ()
 
template<typename T >
constexpr T Divide::toBit (const T X)
 Converts an arbitrary positive integer value to a bitwise value used for masks.
 
constexpr U32 Divide::powerOfTwo (U32 X) noexcept
 
constexpr U32 Divide::previousPowerOfTwo (const U32 X) noexcept
 
constexpr U32 Divide::mipLevels (U32 width, U32 height) noexcept
 
template<typename T >
requires std::is_unsigned_v<T>
constexpr bool Divide::isPowerOfTwo (const T x) noexcept
 
constexpr size_t Divide::realign_offset (const size_t offset, const size_t align) noexcept
 
template<typename Iterator , typename Pred >
void Divide::for_each_interval (Iterator from, Iterator to, std::ptrdiff_t partition_size, Pred &&operation)
 
template<typename C >
requires (!has_reserve<C>)
void Divide::optional_reserve (C &, std::size_t)
 
template<typename C >
requires has_reserve<C>
void Divide::optional_reserve (C &c, std::size_t n)
 
template<typename T , std::size_t ... Is>
constexpr std::array< T, sizeof...(Is)> Divide::detail::create_array (T value, index_sequence< Is... >)
 
template<typename T , std::size_t ... Is>
constexpr eastl::array< T, sizeof...(Is)> Divide::detail::create_eastl_array (T value, index_sequence< Is... >)
 
template<std::size_t N, typename T >
constexpr std::array< T, N > Divide::create_array (const T &value)
 
template<std::size_t N, typename T >
constexpr eastl::array< T, N > Divide::create_eastl_array (const T &value)
 
bool Divide::AlmostEqualUlpsAndAbs (const F32 A, const F32 B, const F32 maxDiff, const I32 maxUlpsDiff) noexcept
 
bool Divide::AlmostEqualUlpsAndAbs (const D64 A, const D64 B, const D64 maxDiff, const I32 maxUlpsDiff) noexcept
 
bool Divide::AlmostEqualRelativeAndAbs (const F32 A, const F32 B, const F32 maxDiff, const F32 maxRelDiff) noexcept
 
bool Divide::AlmostEqualRelativeAndAbs (D64 A, D64 B, const D64 maxDiff, const D64 maxRelDiff) noexcept
 
template<typename Fun >
auto Divide::detail::operator+ (ScopeGuardOnExit, Fun &&fn) noexcept
 
template<typename Fun >
auto Divide::detail::operator+ (ScopeGuardOnFail, Fun &&fn)
 
template<typename Fun >
auto Divide::detail::operator+ (ScopeGuardOnSuccess, Fun &&fn)
 
template<typename T , typename U = T>
bool Divide::IS_IN_RANGE_INCLUSIVE (const T x, const U min, const U max) noexcept
 
template<typename T , typename U = T>
bool Divide::IS_IN_RANGE_EXCLUSIVE (const T x, const U min, const U max) noexcept
 
template<typename T >
bool Divide::IS_ZERO (const T X) noexcept
 
template<>
bool Divide::IS_ZERO (const F32 X) noexcept
 
template<>
bool Divide::IS_ZERO (const D64 X) noexcept
 
template<typename T >
bool Divide::IS_TOLERANCE (const T X, const T TOLERANCE) noexcept
 
template<typename T , typename U = T>
bool Divide::COMPARE_TOLERANCE (const T X, const U Y, const T TOLERANCE) noexcept
 
template<typename T , typename U = T>
bool Divide::COMPARE_TOLERANCE_ACCURATE (const T X, const T Y, const T TOLERANCE) noexcept
 
template<>
bool Divide::COMPARE_TOLERANCE_ACCURATE (const F32 X, const F32 Y, const F32 TOLERANCE) noexcept
 
template<>
bool Divide::COMPARE_TOLERANCE_ACCURATE (const D64 X, const D64 Y, const D64 TOLERANCE) noexcept
 
template<typename T , typename U = T>
bool Divide::COMPARE (T X, U Y) noexcept
 
template<>
bool Divide::COMPARE (const F32 X, const F32 Y) noexcept
 
template<>
bool Divide::COMPARE (const D64 X, const D64 Y) noexcept
 
template<typename T >
bool Divide::IS_GEQUAL (T X, T Y) noexcept
 should be fast enough as the first condition is almost always true
 
template<typename T >
bool Divide::IS_LEQUAL (T X, T Y) noexcept
 
template<typename TO , typename FROM >
TO Divide::safe_static_cast (FROM from)
 
template<typename TO >
TO Divide::safe_static_cast (F32 from)
 
template<typename TO >
TO Divide::safe_static_cast (D64 from)
 
void Divide::DIVIDE_ASSERT_MSG_BOX (const char *failMessage) noexcept
 
bool Divide::Assert::DIVIDE_ASSERT_FUNC (bool expression, const char *expressionStr, const char *file, int line, const char *failMessage) noexcept
 It is safe to call evaluate expressions and call functions inside the assert check as it will compile for every build type.
 

Variables

constexpr U32 Divide::val_32_const = 0x811c9dc5
 
constexpr U32 Divide::prime_32_const = 0x1000193
 
constexpr U64 Divide::val_64_const = 0xcbf29ce484222325
 
constexpr U64 Divide::prime_64_const = 0x100000001b3
 
template<typename T >
constexpr Handle< T > Divide::INVALID_HANDLE { {._data = U32_MAX} }
 
constexpr F32 Divide::EPSILON_F32 = std::numeric_limits<F32>::epsilon()
 
constexpr D64 Divide::EPSILON_D64 = std::numeric_limits<D64>::epsilon()
 

Macro Definition Documentation

◆ ___DETAIL_DIVIDE_ASSERT

#define ___DETAIL_DIVIDE_ASSERT (   ...)    EXP(GET_3RD_ARG(__VA_ARGS__, DIVIDE_ASSERT_2_ARGS, DIVIDE_ASSERT_1_ARGS, ))

Definition at line 733 of file PlatformDefines.h.

◆ _FUNCTION_NAME_AND_SIG_

#define _FUNCTION_NAME_AND_SIG_   __FUNCTION__

Definition at line 104 of file PlatformDefines.h.

◆ ALIAS_TEMPLATE_FUNCTION

#define ALIAS_TEMPLATE_FUNCTION (   highLevelF,
  lowLevelF 
)
Value:
template<typename... Args> \
constexpr auto highLevelF(Args&&... args) -> decltype(lowLevelF(FWD(args)...)) \
{ \
return lowLevelF(FWD(args)...); \
}
#define FWD(...)

Definition at line 115 of file PlatformDefines.h.

◆ ANONYMOUSE_VARIABLE

#define ANONYMOUSE_VARIABLE (   str)    CONCATENATE(str, __LINE__)

Definition at line 95 of file PlatformDefines.h.

◆ CONCATENATE

#define CONCATENATE (   s1,
  s2 
)    CONCATENATE_IMPL(s1, s2)

Definition at line 91 of file PlatformDefines.h.

◆ CONCATENATE_IMPL

#define CONCATENATE_IMPL (   s1,
  s2 
)    s1##s2

Definition at line 90 of file PlatformDefines.h.

◆ DIVIDE_ASSERT

#define DIVIDE_ASSERT (   ...)    EXP(___DETAIL_DIVIDE_ASSERT(__VA_ARGS__)(__VA_ARGS__))

Definition at line 734 of file PlatformDefines.h.

◆ DIVIDE_ASSERT_1_ARGS

#define DIVIDE_ASSERT_1_ARGS (   expression)    DIVIDE_ASSERT_2_ARGS(expression, "UNEXPECTED CALL")

Definition at line 731 of file PlatformDefines.h.

◆ DIVIDE_ASSERT_2_ARGS

#define DIVIDE_ASSERT_2_ARGS (   expression,
  msg 
)    Assert::DIVIDE_ASSERT_FUNC(expression, #expression, __FILE__, __LINE__, msg)

Definition at line 730 of file PlatformDefines.h.

◆ DIVIDE_UNEXPECTED_CALL

#define DIVIDE_UNEXPECTED_CALL ( )    DIVIDE_UNEXPECTED_CALL_MSG("UNEXPECTED CALL")

Definition at line 737 of file PlatformDefines.h.

◆ DIVIDE_UNEXPECTED_CALL_MSG

#define DIVIDE_UNEXPECTED_CALL_MSG (   X)    DIVIDE_ASSERT(false, X)

Definition at line 736 of file PlatformDefines.h.

◆ DVD_PLATFORM_DEFINES_H_

#define DVD_PLATFORM_DEFINES_H_

Definition at line 34 of file PlatformDefines.h.

◆ EXP

#define EXP (   x)    x

Definition at line 41 of file PlatformDefines.h.

◆ FWD_DECLARE_MANAGED_CLASS

#define FWD_DECLARE_MANAGED_CLASS (   T)
Value:
class T; \
TYPEDEF_SMART_POINTERS_FOR_TYPE(T)

Definition at line 81 of file PlatformDefines.h.

◆ FWD_DECLARE_MANAGED_STRUCT

#define FWD_DECLARE_MANAGED_STRUCT (   T)
Value:
struct T; \
TYPEDEF_SMART_POINTERS_FOR_TYPE(T)

Definition at line 85 of file PlatformDefines.h.

◆ GET_3RD_ARG

#define GET_3RD_ARG (   arg1,
  arg2,
  arg3,
  ... 
)    arg3

Definition at line 43 of file PlatformDefines.h.

◆ GET_4TH_ARG

#define GET_4TH_ARG (   arg1,
  arg2,
  arg3,
  arg4,
  ... 
)    arg4

Definition at line 44 of file PlatformDefines.h.

◆ GET_5TH_ARG

#define GET_5TH_ARG (   arg1,
  arg2,
  arg3,
  arg4,
  arg5,
  ... 
)    arg5

Definition at line 45 of file PlatformDefines.h.

◆ GET_6TH_ARG

#define GET_6TH_ARG (   arg1,
  arg2,
  arg3,
  arg4,
  arg5,
  arg6,
  ... 
)    arg6

Definition at line 46 of file PlatformDefines.h.

◆ NO_DESTROY

#define NO_DESTROY

Definition at line 111 of file PlatformDefines.h.

◆ NOP

#define NOP ( )    static_assert(true, "")

Definition at line 458 of file PlatformDefines.h.

◆ SCOPE_EXIT

#define SCOPE_EXIT   auto ANONYMOUS_VARIABLE(SCOPE_EXIT_STATE) = detail::ScopeGuardOnExit() + [&]() noexcept

Definition at line 543 of file PlatformDefines.h.

◆ SCOPE_FAIL

#define SCOPE_FAIL   auto ANONYMOUS_VARIABLE(SCOPE_FAIL_STATE) = detail::ScopeGuardOnFail() + [&]() noexcept

Definition at line 541 of file PlatformDefines.h.

◆ SCOPE_SUCCESS

#define SCOPE_SUCCESS   auto ANONYMOUS_VARIABLE(SCOPE_FAIL_STATE) = detail::ScopeGuardOnSuccess() + [&]()

Definition at line 542 of file PlatformDefines.h.

◆ STUBBED

#define STUBBED (   x)    static_assert(true, "")

Definition at line 60 of file PlatformDefines.h.

◆ TO_STRING

#define TO_STRING (   X)    TO_STRING_NAME(X)

Definition at line 65 of file PlatformDefines.h.

◆ TO_STRING_NAME

#define TO_STRING_NAME (   X)    #X

Definition at line 64 of file PlatformDefines.h.

◆ TYPEDEF_SMART_POINTERS_FOR_TYPE

#define TYPEDEF_SMART_POINTERS_FOR_TYPE (   T)
Value:
using T ## _wptr = std::weak_ptr<T>; \
using T ## _ptr = std::shared_ptr<T>; \
using T ## _cwptr = std::weak_ptr<const T>; \
using T ## _cptr = std::shared_ptr<const T>;\
using T ## _uptr = std::unique_ptr<T>;

Makes writing and reading smart pointer types easier and cleaner Faster to write ClassName_uptr than std::unique_ptr<ClassName> Also cleaner and easier to read the managed type in nested templated parameters e.g. std::pair<ClassNameA_uptr, ClassNameB_wptr> vs std::pair<std::unique_ptr<ClassNameA>, std::weak_ptr<ClassNameB>> Also makes it easier to switch smart pointer implementations (i.e. eastl for unique_ptr) using a centralized location

Definition at line 73 of file PlatformDefines.h.

Function Documentation

◆ ArrayCount()

template<typename... Args>
constexpr auto ArrayCount ( Args &&...  args) -> decltype( std::size (FWD(args)...))
constexpr

Definition at line 122 of file PlatformDefines.h.