8#ifndef META_OCEAN_BASE_BASE_H
9#define META_OCEAN_BASE_BASE_H
21#include <unordered_map>
22#include <unordered_set>
26 #include <TargetConditionals.h>
178#if (!defined(ENABLE_LOGGING) || ENABLE_LOGGING != 1) && (!defined(OCEAN_ACTIVATE_MESSENGER) || OCEAN_ACTIVATE_MESSENGER != 1) && (!defined(PROFILE) || PROFILE != 1)
179 #ifndef OCEAN_DEACTIVATED_MESSENGER
180 #define OCEAN_DEACTIVATED_MESSENGER
191#if !defined(OCEAN_DEBUG) && (defined(DEBUG) || defined(_DEBUG))
200 #ifndef OCEAN_INTENSIVE_DEBUG
209#if defined(__ANDROID__) && !defined(_ANDROID)
217#ifndef OCEAN_RUNTIME_SHARED
218 #ifndef OCEAN_RUNTIME_STATIC
219 #define OCEAN_RUNTIME_STATIC
227#if defined(_ANDROID) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1)
228 #ifndef OCEAN_HARDWARE_REDUCED_PERFORMANCE
229 #define OCEAN_HARDWARE_REDUCED_PERFORMANCE
240#ifndef OCEAN_HARDWARE_NEON_VERSION
241 #if defined(__ARM_NEON__) || defined(__ARM_NEON)
243 #define OCEAN_HARDWARE_NEON_VERSION 10
244 #elif defined(_M_ARM64)
246 #define OCEAN_HARDWARE_NEON_VERSION 10
250#ifndef OCEAN_HARDWARE_NEON_VERSION
251 #define OCEAN_HARDWARE_NEON_VERSION 0
259 #define OCEAN_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100)
261 #define OCEAN_GCC_VERSION 0
266 #define OCEAN_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100)
268 #define OCEAN_CLANG_VERSION 0
274 #define OCEAN_MSC_VERSION (_MSC_VER)
276 #define OCEAN_MSC_VERSION 0
298#if defined(OCEAN_CLANG_VERSION) && OCEAN_CLANG_VERSION > 0
300 #define OCEAN_COMPILER_CLANG 1
303 #if defined(OCEAN_COMPILER_GCC) || defined(OCEAN_COMPILER_MSC)
304 #error Invalid compiler configuration.
309#if defined(OCEAN_GCC_VERSION) && OCEAN_GCC_VERSION > 0
311 #if !defined(OCEAN_CLANG_VERSION) || OCEAN_CLANG_VERSION == 0
313 #define OCEAN_COMPILER_GCC 1
316 #if defined(OCEAN_COMPILER_CLANG) || defined(OCEAN_COMPILER_MSC)
317 #error Invalid compiler configuration.
321 #if defined(OCEAN_MSC_VERSION) && OCEAN_MSC_VERSION > 0
322 #error The GCC compiler is used already, either the usage of gcc or msc is wrong.
327#if defined(OCEAN_MSC_VERSION) && OCEAN_MSC_VERSION > 0
329 #if !defined(OCEAN_CLANG_VERSION) || OCEAN_CLANG_VERSION == 0
330 #if !defined(OCEAN_GCC_VERSION) || OCEAN_GCC_VERSION == 0
332 #define OCEAN_COMPILER_MSC 1
335 #if defined(OCEAN_COMPILER_GCC) || defined(OCEAN_COMPILER_CLANG)
336 #error Invalid compiler configuration.
342#if !defined(OCEAN_COMPILER_GCC) && !defined(OCEAN_COMPILER_CLANG) && !defined(OCEAN_COMPILER_MSC)
344 #error Unknown compiler, either GCC, Clang or the Microsoft compiler must be used.
348#if !defined(OCEAN_POSIX_AVAILABLE)
350 #if defined(OCEAN_COMPILER_GCC) || (defined(OCEAN_COMPILER_CLANG) && !defined(_MSC_VER))
352 #define OCEAN_POSIX_AVAILABLE
359#ifndef OCEAN_HARDWARE_SSE_VERSION
360 #if defined(_MSC_VER) && !defined(__clang__)
362 #if defined(_M_IX86_FP) && _M_IX86_FP >= 1
363 #define OCEAN_HARDWARE_SSE_VERSION 41
368 #define OCEAN_HARDWARE_SSE_VERSION 41
371 #elif defined(_MSC_VER) && defined(__clang__)
373 #if defined(__SSE4_1__)
374 #define OCEAN_HARDWARE_SSE_VERSION 41
377 #elif defined(__APPLE__)
379 #if defined(__SSE4_1__)
380 #define OCEAN_HARDWARE_SSE_VERSION 41
383 #elif defined(__linux__) && !defined(_ANDROID)
385 #if defined(__SSE4_1__)
386 #define OCEAN_HARDWARE_SSE_VERSION 41
392#ifndef OCEAN_HARDWARE_SSE_VERSION
393 #define OCEAN_HARDWARE_SSE_VERSION 0
400#if !defined(OCEAN_HARDWARE_AVX_VERSION) && OCEAN_HARDWARE_SSE_VERSION > 0
401 #if defined(_MSC_VER) || defined(__APPLE__) || (defined(__linux__) && !defined(_ANDROID))
403 #if defined(__AVX2__)
404 #define OCEAN_HARDWARE_AVX_VERSION 20
405 #elif defined(__AVX__)
406 #define OCEAN_HARDWARE_AVX_VERSION 10
412#ifndef OCEAN_HARDWARE_AVX_VERSION
413 #define OCEAN_HARDWARE_AVX_VERSION 0
420#if defined(_WINDOWS) || defined(_ANDROID) || defined(__APPLE__) || defined(__linux__) || defined(__EMSCRIPTEN__)
421 #ifndef OCEAN_LITTLE_ENDIAN
422 #define OCEAN_LITTLE_ENDIAN
430#if defined(_WINDOWS) && defined(OCEAN_RUNTIME_SHARED)
431 #ifdef USE_OCEAN_BASE_EXPORT
432 #define OCEAN_BASE_EXPORT __declspec(dllexport)
434 #define OCEAN_BASE_EXPORT __declspec(dllimport)
437 #define OCEAN_BASE_EXPORT
461 #ifdef OCEAN_REDIRECT_ASSERT_TO_MESSENGER
470 extern OCEAN_BASE_EXPORT
void assertErrorMessage(
const char* file,
const int line,
const char* message);
472 #define ocean_assert(e) ((bool(e) != true) ? Ocean::assertErrorMessage(__FILE__, __LINE__, #e) : ((void)0))
476 #define ocean_assert(e) assert(e)
480 #define ocean_assert(e) ((void)0)
493#ifndef ocean_assert_accuracy
495 #define ocean_assert_accuracy(e) if (bool(e) != true) std::cout << "ocean_assert_accuracy(" << #e << "): in file " << __FILE__ << ", line " << __LINE__ << std::endl
497 #define ocean_assert_accuracy(e) ((void)0)
506#ifndef ocean_assert_and_suppress_unused
508 #define ocean_assert_and_suppress_unused(expression, variable) ocean_assert(expression)
510 #define ocean_assert_and_suppress_unused(expression, variable) ((void)(variable))
517#ifndef OCEAN_SUPPORT_RTTI
518 #if defined(OCEAN_COMPILER_MSC)
520 #define OCEAN_SUPPORT_RTTI
522 #elif defined(OCEAN_COMPILER_GCC) && OCEAN_GCC_VERSION >= 40302
524 #define OCEAN_SUPPORT_RTTI
526 #elif defined(OCEAN_COMPILER_CLANG) && OCEAN_CLANG_VERSION >= 20700
527 #if __has_feature(cxx_rtti)
528 #define OCEAN_SUPPORT_RTTI
537#ifndef OCEAN_SUPPORT_EXCEPTIONS
538 #if defined(OCEAN_COMPILER_MSC)
540 #define OCEAN_SUPPORT_EXCEPTIONS
542 #elif defined(OCEAN_COMPILER_GCC) && OCEAN_GCC_VERSION > 0
543 #if defined(__EXCEPTIONS) && __EXCEPTIONS
544 #define OCEAN_SUPPORT_EXCEPTIONS
546 #elif defined(OCEAN_COMPILER_CLANG) && OCEAN_CLANG_VERSION > 0
547 #if defined(__EXCEPTIONS) && __EXCEPTIONS && __has_feature(cxx_exceptions)
548 #define OCEAN_SUPPORT_EXCEPTIONS
560#ifndef OCEAN_WARNING_MISSING_IMPLEMENTATION
561 #ifdef OCEAN_COMPILETIME_WARNING_MISSING_IMPLEMENTATION
562 #ifdef OCEAN_COMPILER_MSC
563 #define OCEAN_WARNING_MISSING_IMPLEMENTATION __pragma(message("Missing implementation!")); assert(false && "Missing implementation!")
565 #define OCEAN_WARNING_MISSING_IMPLEMENTATION _Pragma ("message \"Missing implementation\""); assert(false && "Missing implementation!")
568 #define OCEAN_WARNING_MISSING_IMPLEMENTATION assert(false && "Missing implementation!")
576#ifndef OCEAN_SUPPRESS_UNUSED_WARNING
577 #define OCEAN_SUPPRESS_UNUSED_WARNING(e) ((void)e)
601 #define OCEAN_PLATFORM_BUILD_WINDOWS
603#elif defined(__APPLE__)
605 #define OCEAN_PLATFORM_BUILD_APPLE
607 #if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR == 1
609 #define OCEAN_PLATFORM_BUILD_APPLE_IOS_SIMULATOR
611 #elif defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1
613 #define OCEAN_PLATFORM_BUILD_APPLE_IOS
615 #elif defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1
617 #define OCEAN_PLATFORM_BUILD_APPLE_MACOS
621 #error Missing implementation
625 #if defined(OCEAN_PLATFORM_BUILD_APPLE_IOS_SIMULATOR) || defined(OCEAN_PLATFORM_BUILD_APPLE_IOS)
627 #define OCEAN_PLATFORM_BUILD_APPLE_IOS_ANY
631#elif defined(_ANDROID)
633 #define OCEAN_PLATFORM_BUILD_ANDROID
635#elif defined(__linux__) || defined(__EMSCRIPTEN__)
637 #define OCEAN_PLATFORM_BUILD_LINUX
641 #error Missing implementation
645#if defined(OCEAN_PLATFORM_BUILD_ANDROID) || defined(OCEAN_PLATFORM_BUILD_APPLE_IOS_ANY)
647 #define OCEAN_PLATFORM_BUILD_MOBILE
655#ifndef OCEAN_APPLY_IF_DEBUG
657 #define OCEAN_APPLY_IF_DEBUG(e) e
659 #define OCEAN_APPLY_IF_DEBUG(e) {}
664#ifndef OCEAN_APPLY_IF_WINDOWS
665 #ifdef OCEAN_PLATFORM_BUILD_WINDOWS
666 #define OCEAN_APPLY_IF_WINDOWS(e) e
668 #define OCEAN_APPLY_IF_WINDOWS(e) {}
673#ifndef OCEAN_APPLY_IF_APPLE
674 #ifdef OCEAN_PLATFORM_BUILD_APPLE
675 #define OCEAN_APPLY_IF_APPLE(e) e
677 #define OCEAN_APPLY_IF_APPLE(e) {}
682#ifndef OCEAN_APPLY_IF_LINUX
683 #ifdef OCEAN_PLATFORM_BUILD_LINUX
684 #define OCEAN_APPLY_IF_LINUX(e) e
686 #define OCEAN_APPLY_IF_LINUX(e) {}
691#ifndef OCEAN_APPLY_IF_ANDROID
692 #ifdef OCEAN_PLATFORM_BUILD_ANDROID
693 #define OCEAN_APPLY_IF_ANDROID(e) e
695 #define OCEAN_APPLY_IF_ANDROID(e) {}
700#ifndef OCEAN_APPLY_IF_IPHONE
701 #if defined(OCEAN_PLATFORM_BUILD_APPLE_IOS) || defined(TARGET_IPHONE_SIMULATOR)
702 #define OCEAN_APPLY_IF_IPHONE(e) e
704 #define OCEAN_APPLY_IF_IPHONE(e) {}
709#ifndef OCEAN_APPLY_IF_GCC
710 #if defined(OCEAN_GCC_VERSION) && OCEAN_GCC_VERSION > 0
711 #define OCEAN_APPLY_IF_GCC(e) e
713 #define OCEAN_APPLY_IF_GCC(e) {}
718#ifndef OCEAN_APPLY_IF_SSE
719 #if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION > 0
720 #define OCEAN_APPLY_IF_SSE(e) e
722 #define OCEAN_APPLY_IF_SSE(e) {}
727#ifndef OCEAN_APPLY_IF_AVX
728 #if defined(OCEAN_HARDWARE_AVX_VERSION) && OCEAN_HARDWARE_AVX_VERSION > 0
729 #define OCEAN_APPLY_IF_AVX(e) e
731 #define OCEAN_APPLY_IF_AVX(e) {}
736#ifndef OCEAN_APPLY_IF_NEON
737 #if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION > 0
738 #define OCEAN_APPLY_IF_NEON(e) e
740 #define OCEAN_APPLY_IF_NEON(e) {}
749#ifndef OCEAN_FORCE_INLINE
750 #if defined(OCEAN_COMPILER_MSC)
751 #define OCEAN_FORCE_INLINE __forceinline
752 #elif defined(OCEAN_COMPILER_CLANG)
753 #if __has_attribute(always_inline)
754 #define OCEAN_FORCE_INLINE inline __attribute__((always_inline))
756 #define OCEAN_FORCE_INLINE inline
758 #elif defined(OCEAN_COMPILER_GCC)
759 #define OCEAN_FORCE_INLINE inline __attribute__((always_inline))
761 #define OCEAN_FORCE_INLINE inline
769#ifndef OCEAN_PREVENT_INLINE
770 #if defined(OCEAN_COMPILER_MSC)
771 #define OCEAN_PREVENT_INLINE __declspec(noinline)
772 #elif defined(OCEAN_COMPILER_CLANG)
773 #if __has_attribute(noinline)
774 #define OCEAN_PREVENT_INLINE __attribute__((noinline))
776 #define OCEAN_PREVENT_INLINE
778 #elif defined(OCEAN_COMPILER_GCC)
779 #define OCEAN_PREVENT_INLINE __attribute__((noinline))
781 #define OCEAN_PREVENT_INLINE
789#ifndef OCEAN_DISABLE_SUBSEQUENT_LOOP_OPTIMIZATION
790 #if defined(OCEAN_COMPILER_MSC)
791 #define OCEAN_DISABLE_SUBSEQUENT_LOOP_OPTIMIZATION _Pragma("loop(no_vector)")
792 #elif defined(OCEAN_COMPILER_CLANG)
793 #define OCEAN_DISABLE_SUBSEQUENT_LOOP_OPTIMIZATION _Pragma("clang loop vectorize(disable) interleave(disable)")
794 #elif defined(OCEAN_COMPILER_GCC)
795 #define OCEAN_DISABLE_SUBSEQUENT_LOOP_OPTIMIZATION _Pragma("GCC unroll 1")
797 #define OCEAN_DISABLE_SUBSEQUENT_LOOP_OPTIMIZATION
802#ifndef OCEAN_DISABLE_SUBSEQUENT_LOOP_OPTIMIZATION_IF_NEON
803 #if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION > 0
804 #define OCEAN_DISABLE_SUBSEQUENT_LOOP_OPTIMIZATION_IF_NEON OCEAN_DISABLE_SUBSEQUENT_LOOP_OPTIMIZATION
806 #define OCEAN_DISABLE_SUBSEQUENT_LOOP_OPTIMIZATION_IF_NEON
814#ifndef OCEAN_ALIGN_DATA
815 #if defined(OCEAN_COMPILER_MSC)
816 #define OCEAN_ALIGN_DATA(x) __declspec(align(x))
818 #define OCEAN_ALIGN_DATA(x) __attribute__ ((aligned(x)))
826#if (defined(DEBUG) || defined(OCEAN_DEBUG)) && defined(NDEBUG)
827 #error You cannot define both flags (DEBUG and NDEBUG) concurrently
830#if defined(OCEAN_INTENSIVE_DEBUG) && (!defined(DEBUG) || !defined(OCEAN_DEBUG))
831 #error You cannot define OCEAN_INTENSIVE_DEBUG without defining DEBUG/OCEAN_DEBUG
838 #if !defined(OCEAN_DEBUG) || defined(NDEBUG)
847#ifndef OCEAN_DISABLE_DOCUMENTATION_DIAGNOSTIC
848 #if defined(OCEAN_CLANG_VERSION) && OCEAN_CLANG_VERSION > 0
849 #define OCEAN_DISABLE_DOCUMENTATION_DIAGNOSTIC _Pragma("clang diagnostic push") \
850 _Pragma("clang diagnostic ignored \"-Wdocumentation\"")
852 #define OCEAN_DISABLE_DOCUMENTATION_DIAGNOSTIC
857#ifndef OCEAN_RE_ENABLE_DOCUMENTATION_DIAGNOSTIC
858 #if defined(OCEAN_CLANG_VERSION) && OCEAN_CLANG_VERSION > 0
859 #define OCEAN_RE_ENABLE_DOCUMENTATION_DIAGNOSTIC _Pragma("clang diagnostic pop")
861 #define OCEAN_RE_ENABLE_DOCUMENTATION_DIAGNOSTIC
869#ifndef OCEAN_PRINT_MACRO_VALUE
870 #define OCEAN_PRINT_MACRO_VALUE_INTERNAL_INTERNAL(value) #value
871 #define OCEAN_PRINT_MACRO_VALUE_INTERNAL(value) OCEAN_PRINT_MACRO_VALUE_INTERNAL_INTERNAL(value)
873 #define OCEAN_PRAGMA_INTERNAL(value) _Pragma(#value)
874 #define OCEAN_PRAGMA(value) OCEAN_PRAGMA_INTERNAL(value)
876 #define OCEAN_PRINT_MACRO_VALUE(text, value) OCEAN_PRAGMA(message text OCEAN_PRINT_MACRO_VALUE_INTERNAL(value))
std::vector< IndexPair32 > IndexPairs32
Definition of a vector holding 32 bit index pairs.
Definition Base.h:144
std::pair< Index64, Index64 > IndexPair64
Definition of a pair holding 64 bit indices.
Definition Base.h:150
std::set< Index64 > IndexSet64
Definition of a set holding 64 bit indices.
Definition Base.h:120
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition Base.h:96
std::unordered_set< Index64 > UnorderedIndexSet64
Definition of an unordered_set holding 64 bit indices.
Definition Base.h:132
std::vector< IndexPair64 > IndexPairs64
Definition of a vector holding 64 bit index pairs.
Definition Base.h:156
std::vector< Indices32 > IndexGroups32
Definition of a vector holding 32 bit indices, so we have groups of indices.
Definition Base.h:102
std::vector< std::string > Strings
Definition of a vector holding strings.
Definition Base.h:162
constexpr bool oceanFalse()
This function is a helper function returning false any time.
Definition Base.h:590
std::vector< Index64 > Indices64
Definition of a vector holding 64 bit index values.
Definition Base.h:108
uint32_t Index32
Definition of a 32 bit index value.
Definition Base.h:84
std::pair< Index32, Index32 > IndexPair32
Definition of a pair holding 32 bit indices.
Definition Base.h:138
uint64_t Index64
Definition of a 64 bit index value.
Definition Base.h:90
std::set< Index32 > IndexSet32
Definition of a set holding 32 bit indices.
Definition Base.h:114
std::vector< std::wstring > WStrings
Definition of a vector holding strings.
Definition Base.h:168
OCEAN_BASE_EXPORT void assertErrorMessage(const char *file, const int line, const char *message)
Error message function for redirected asserts.
std::unordered_set< Index32 > UnorderedIndexSet32
Definition of an unordered_set holding 32 bit indices.
Definition Base.h:126
The namespace covering the entire Ocean framework.
Definition Accessor.h:15