summaryrefslogtreecommitdiff
path: root/Runtime/Utilities
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-10-19 09:13:58 +0800
committerchai <chaifix@163.com>2020-10-19 09:13:58 +0800
commitf0807fc44dde14531759306317611bab87c8fccf (patch)
tree6e78fed61c16a70cda5fa732635f89f9faac9720 /Runtime/Utilities
parent639b34294ffc20721c66db46e59e07d9100ac4b8 (diff)
+gamelab proj
Diffstat (limited to 'Runtime/Utilities')
-rw-r--r--Runtime/Utilities/Assert.h8
-rw-r--r--Runtime/Utilities/Base64.cpp0
-rw-r--r--Runtime/Utilities/Base64.h0
-rw-r--r--Runtime/Utilities/Exception.h6
-rw-r--r--Runtime/Utilities/NonCopyable.h14
-rw-r--r--Runtime/Utilities/Singleton.h43
-rw-r--r--Runtime/Utilities/Type.h21
-rw-r--r--Runtime/Utilities/UIDGenerator.h20
-rw-r--r--Runtime/Utilities/Utf8.cpp0
-rw-r--r--Runtime/Utilities/Utf8.h0
-rw-r--r--Runtime/Utilities/UtilMacros.h16
11 files changed, 128 insertions, 0 deletions
diff --git a/Runtime/Utilities/Assert.h b/Runtime/Utilities/Assert.h
new file mode 100644
index 0000000..aab7b73
--- /dev/null
+++ b/Runtime/Utilities/Assert.h
@@ -0,0 +1,8 @@
+#ifndef ASSERT_H
+#define ASSERT_H
+
+#include <assert.h>
+
+#define Assert(c) assert(c)
+
+#endif \ No newline at end of file
diff --git a/Runtime/Utilities/Base64.cpp b/Runtime/Utilities/Base64.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Runtime/Utilities/Base64.cpp
diff --git a/Runtime/Utilities/Base64.h b/Runtime/Utilities/Base64.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Runtime/Utilities/Base64.h
diff --git a/Runtime/Utilities/Exception.h b/Runtime/Utilities/Exception.h
new file mode 100644
index 0000000..bd73c6b
--- /dev/null
+++ b/Runtime/Utilities/Exception.h
@@ -0,0 +1,6 @@
+#ifndef EXCEPTION_H
+#define EXCEPTION_H
+
+
+
+#endif \ No newline at end of file
diff --git a/Runtime/Utilities/NonCopyable.h b/Runtime/Utilities/NonCopyable.h
new file mode 100644
index 0000000..7135827
--- /dev/null
+++ b/Runtime/Utilities/NonCopyable.h
@@ -0,0 +1,14 @@
+#ifndef NON_COPYABLE_H
+#define NON_COPYABLE_H
+
+class NonCopyable
+{
+public:
+ NonCopyable() {}
+
+private:
+ NonCopyable(const NonCopyable&);
+ NonCopyable& operator=(const NonCopyable&);
+};
+
+#endif
diff --git a/Runtime/Utilities/Singleton.h b/Runtime/Utilities/Singleton.h
new file mode 100644
index 0000000..f864a42
--- /dev/null
+++ b/Runtime/Utilities/Singleton.h
@@ -0,0 +1,43 @@
+#ifndef SINGLETON_H
+#define SINGLETON_H
+
+template<class T>
+class Singleton
+{
+public:
+
+ static T* Instance()
+ {
+ if (!instance) instance = new T;
+ return instance;
+ }
+
+ static void Destroy()
+ {
+ delete instance;
+ instance = nullptr;
+ }
+
+protected:
+
+ Singleton()
+ {
+ instance = static_cast<T*>(this);
+ };
+
+ virtual ~Singleton() {};
+
+ static T* instance;
+
+private:
+
+ Singleton(const Singleton& singleton);
+
+ Singleton& operator = (const Singleton& singleton);
+
+};
+
+template<class T>
+T* Singleton<T>::instance = nullptr;
+
+#endif \ No newline at end of file
diff --git a/Runtime/Utilities/Type.h b/Runtime/Utilities/Type.h
new file mode 100644
index 0000000..b3d0826
--- /dev/null
+++ b/Runtime/Utilities/Type.h
@@ -0,0 +1,21 @@
+#ifndef TYPE_H
+#define TYPE_H
+
+#include <cstdlib>
+#include <stdint.h>
+
+typedef int8_t int8;
+typedef uint8_t uint8;
+typedef unsigned char byte;
+typedef char sbyte;
+typedef int16_t int16;
+typedef uint16_t uint16;
+typedef int32_t int32;
+typedef uint32_t uint32;
+typedef int64_t int64;
+typedef uint64_t uint64;
+
+typedef uint32_t uint;
+typedef int32_t sint;
+
+#endif \ No newline at end of file
diff --git a/Runtime/Utilities/UIDGenerator.h b/Runtime/Utilities/UIDGenerator.h
new file mode 100644
index 0000000..81918f0
--- /dev/null
+++ b/Runtime/Utilities/UIDGenerator.h
@@ -0,0 +1,20 @@
+#ifndef UID_GENERATOR_H
+#define UID_GENERATOR_H
+
+class UIDGenerator
+{
+public:
+ UIDGenerator(int from = 0)
+ : m_Index(from)
+ {
+ };
+ ~UIDGenerator(){};
+
+ int GenUID(){return m_Index++;};
+
+private:
+ int m_Index;
+
+};
+
+#endif \ No newline at end of file
diff --git a/Runtime/Utilities/Utf8.cpp b/Runtime/Utilities/Utf8.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Runtime/Utilities/Utf8.cpp
diff --git a/Runtime/Utilities/Utf8.h b/Runtime/Utilities/Utf8.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Runtime/Utilities/Utf8.h
diff --git a/Runtime/Utilities/UtilMacros.h b/Runtime/Utilities/UtilMacros.h
new file mode 100644
index 0000000..1941d7f
--- /dev/null
+++ b/Runtime/Utilities/UtilMacros.h
@@ -0,0 +1,16 @@
+#ifndef UTIL_MACROS_H
+#define UTIL_MACROS_H
+
+#define GET_SET(TYPE,PROP,VAR) \
+ inline void Set##PROP (TYPE val) { VAR = val; } \
+ inline TYPE Get##PROP () {return VAR; }
+
+#define GET(TYPE, PROP, VAR) \
+ inline TYPE Get##PROP () const {return VAR; }
+
+#define SET(TYPE, PROP, VAR) \
+ inline void Set##PROP (TYPE val) { VAR = val; } \
+
+#define Mask(v) (1 << v)
+
+#endif \ No newline at end of file