From f0807fc44dde14531759306317611bab87c8fccf Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 19 Oct 2020 09:13:58 +0800 Subject: +gamelab proj --- Runtime/Utilities/Assert.h | 8 ++++++++ Runtime/Utilities/Base64.cpp | 0 Runtime/Utilities/Base64.h | 0 Runtime/Utilities/Exception.h | 6 ++++++ Runtime/Utilities/NonCopyable.h | 14 +++++++++++++ Runtime/Utilities/Singleton.h | 43 ++++++++++++++++++++++++++++++++++++++++ Runtime/Utilities/Type.h | 21 ++++++++++++++++++++ Runtime/Utilities/UIDGenerator.h | 20 +++++++++++++++++++ Runtime/Utilities/Utf8.cpp | 0 Runtime/Utilities/Utf8.h | 0 Runtime/Utilities/UtilMacros.h | 16 +++++++++++++++ 11 files changed, 128 insertions(+) create mode 100644 Runtime/Utilities/Assert.h create mode 100644 Runtime/Utilities/Base64.cpp create mode 100644 Runtime/Utilities/Base64.h create mode 100644 Runtime/Utilities/Exception.h create mode 100644 Runtime/Utilities/NonCopyable.h create mode 100644 Runtime/Utilities/Singleton.h create mode 100644 Runtime/Utilities/Type.h create mode 100644 Runtime/Utilities/UIDGenerator.h create mode 100644 Runtime/Utilities/Utf8.cpp create mode 100644 Runtime/Utilities/Utf8.h create mode 100644 Runtime/Utilities/UtilMacros.h (limited to 'Runtime/Utilities') 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 + +#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 diff --git a/Runtime/Utilities/Base64.h b/Runtime/Utilities/Base64.h new file mode 100644 index 0000000..e69de29 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 Singleton +{ +public: + + static T* Instance() + { + if (!instance) instance = new T; + return instance; + } + + static void Destroy() + { + delete instance; + instance = nullptr; + } + +protected: + + Singleton() + { + instance = static_cast(this); + }; + + virtual ~Singleton() {}; + + static T* instance; + +private: + + Singleton(const Singleton& singleton); + + Singleton& operator = (const Singleton& singleton); + +}; + +template +T* Singleton::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 +#include + +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 diff --git a/Runtime/Utilities/Utf8.h b/Runtime/Utilities/Utf8.h new file mode 100644 index 0000000..e69de29 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 -- cgit v1.1-26-g67d0