SimpleAI
 All Classes Namespaces Files Functions Variables Typedefs Macros Groups Pages
Types.h
Go to the documentation of this file.
1 
4 #pragma once
5 
6 #include "Log.h"
7 #include <string>
8 #include <unordered_map>
9 #include <cassert>
10 #include <cstdio>
11 
15 #ifndef ai_log
16 #define ai_log(...) ai::Log::info(__VA_ARGS__)
17 #endif
18 
22 #ifndef ai_log_error
23 #define ai_log_error(...) ai::Log::error(__VA_ARGS__)
24 #endif
25 
29 #ifndef ai_log_warn
30 #define ai_log_warn(...) ai::Log::warn(__VA_ARGS__)
31 #endif
32 
36 #ifndef ai_log_debug
37 #define ai_log_debug(...) ai::Log::debug(__VA_ARGS__)
38 #endif
39 
43 #ifndef ai_log_trace
44 #define ai_log_trace(...) ai::Log::trace(__VA_ARGS__)
45 #endif
46 
47 #if !(__GNUC__ || __GNUC__)
48 #define __PRETTY_FUNCTION__ __FUNCSIG__
49 #endif
50 
54 #ifndef ai_assert_always
55  #ifdef __clang_analyzer__
56  #define ai_assert_always(condition, ...) assert(condition)
57  #else
58  #define ai_assert_always(condition, ...) \
59  if ( !(condition) ) { \
60  ai_log_error(__VA_ARGS__); \
61  ai_log_error("%s:%i", __FILE__, __LINE__); \
62  assert(condition); \
63  }
64  #endif
65 #endif
66 
71 #ifndef ai_assert
72  #ifdef DEBUG
73  #define ai_assert ai_assert_always
74  #else
75  #define ai_assert(condition, ...)
76  #endif
77 #endif
78 
83 template<class T, class S>
84 inline T ai_assert_cast(const S object) {
85 #ifdef __cpp_rtti
86  ai_assert(dynamic_cast<T>(object) == static_cast<T>(object), "Types don't match");
87 #endif
88  return static_cast<T>(object);
89 }
90 
91 #define AI_STRINGIFY_INTERNAL(x) #x
92 #define AI_STRINGIFY(x) AI_STRINGIFY_INTERNAL(x)
93 
98 #ifndef AI_EXCEPTIONS
99 #define AI_EXCEPTIONS 0
100 #endif
101 
105 #ifndef AI_LUA_SANTITY
106 #define AI_LUA_SANTITY 1
107 #endif
108 
109 #ifdef _WIN32
110 # ifdef SIMPLEAI_EXPORT
111 # define SIMPLEAI_LIB __declspec(dllexport)
112 # elif defined(SIMPLEAI_IMPORT)
113 # define SIMPLEAI_LIB __declspec(dllimport)
114 # else
115 # define SIMPLEAI_LIB
116 # endif
117 #else
118 # define SIMPLEAI_LIB
119 #endif
120 
121 namespace ai {
122 
129 typedef int CharacterId;
130 #define PRIChrId PRId32
131 
135 typedef std::unordered_map<std::string, std::string> CharacterAttributes;
136 
137 }
#define ai_assert(condition,...)
Provide your own assert - this is only executed in DEBUG mode.
Definition: Types.h:75
T ai_assert_cast(const S object)
If you compile with RTTI activated, you get additional sanity checks when using this macro to perform...
Definition: Types.h:84