Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Platform.h
Go to the documentation of this file.
1
5
6#pragma once
7#ifndef ECS__PLATFORM_H__
8#define ECS__PLATFORM_H__
9
10
11#ifndef ECS_STATIC
12#define ECS_STATIC
13#endif
14
15#ifdef ECS_STATIC
16#define ECS_API
17#else
18#ifdef ECS_EXPORT
19 #define ECS_API __declspec(dllexport)
20#else
21 #define ECS_API __declspec(dllimport)
22#endif
23#endif
24
25// Check if using 64-Bit architecture
26#if (defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__) || defined(_M_AMD64) || defined(_M_ARM64) || defined(_M_X64))
27 #define ECS_64BIT 1
28
29// Check if using 32-Bit architecture
30#elif (defined(_WIN32) && !defined(_WIN64)) || defined(_M_IX86)
31 #define ECS_32BIT 1
32#endif
33
34namespace ECS
35{
36
37 // signed integer type
38 using i8 = int8_t;
39 using i16 = int16_t;
40 using i32 = int32_t;
41
42#ifdef ECS_64BIT
43 using i64 = int64_t;
44#else
45 using i64 = int32_t;
46#endif
47
48 // unsigned integer type
49 using u8 = uint8_t;
50 using u16 = uint16_t;
51 using u32 = uint32_t;
52#ifdef ECS_64BIT
53 using u64 = uint64_t;
54#else
55 using u64 = uint32_t;
56#endif
57
58 // floating point
59 using f32 = float_t;
60 using f64 = double_t;
61
62 // pointer
63 using iptr = intptr_t;
64 using uptr = uintptr_t;
65
66 using ObjectID = size_t;
67 using TypeID = size_t;
68
69 static const ObjectID INVALID_OBJECT_ID = std::numeric_limits<ObjectID>::max();
70 static const TypeID INVALID_TYPE_ID = std::numeric_limits<TypeID>::max();
71
72
74 {
77
79 {}
80
81 TimeStamp(f32 floatValue) : asFloat(floatValue)
82 {}
83
84 operator u32() const { return this->asUInt; }
85
86 inline bool operator==(const TimeStamp& other) const { return this->asUInt == other.asUInt; }
87 inline bool operator!=(const TimeStamp& other) const { return this->asUInt != other.asUInt; }
88
89 inline bool operator<(const TimeStamp& other) const { return this->asFloat < other.asFloat; }
90 inline bool operator>(const TimeStamp& other) const { return this->asFloat > other.asFloat; }
91
92 }; // union TimeStamp
93
94} // namespace ECS
95
96
97#endif // ECS__PLATFORM_H__
size_t TypeID
Definition: Platform.h:67
uint32_t u64
Definition: Platform.h:55
float_t f32
Definition: Platform.h:59
int8_t i8
Definition: Platform.h:38
size_t ObjectID
Definition: Platform.h:66
uintptr_t uptr
Definition: Platform.h:64
uint16_t u16
Definition: Platform.h:50
static const ObjectID INVALID_OBJECT_ID
Definition: Platform.h:69
int32_t i64
Definition: Platform.h:45
uint8_t u8
Definition: Platform.h:49
double_t f64
Definition: Platform.h:60
uint32_t u32
Definition: Platform.h:51
static const TypeID INVALID_TYPE_ID
Definition: Platform.h:70
intptr_t iptr
Definition: Platform.h:63
int16_t i16
Definition: Platform.h:39
int32_t i32
Definition: Platform.h:40
bool operator>(const TimeStamp &other) const
Definition: Platform.h:90
bool operator!=(const TimeStamp &other) const
Definition: Platform.h:87
TimeStamp(f32 floatValue)
Definition: Platform.h:81
bool operator==(const TimeStamp &other) const
Definition: Platform.h:86
bool operator<(const TimeStamp &other) const
Definition: Platform.h:89