Ver código fonte

Delete Generic

Daniele Bartolini 12 anos atrás
pai
commit
4e15eff5af

+ 0 - 1
engine/Android.mk

@@ -37,7 +37,6 @@ LOCAL_SRC_FILES :=\
 	core/bv/Rect.cpp\
 \
 	core/compressors/ZipCompressor.cpp\
-	core/containers/Generic.cpp\
 \
 	core/filesystem/File.cpp\
 	core/filesystem/DiskFile.cpp\

+ 0 - 2
engine/CMakeLists.txt

@@ -142,14 +142,12 @@ set (BV_HEADERS
 )
 
 set (CONTAINERS_SRC
-	core/containers/Generic.cpp
 )
 
 set (CONTAINERS_HEADERS
 	core/containers/Queue.h
 	core/containers/PriorityQueue.h
 	core/containers/Map.h
-	core/containers/Generic.h
 	core/containers/List.h
 	core/containers/Vector.h
 	core/containers/RBTree.h

+ 0 - 1
engine/Crown.h

@@ -60,7 +60,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "RBTree.h"
 #include "List.h"
 #include "Vector.h"
-#include "Generic.h"
 #include "Queue.h"
 #include "PriorityQueue.h"
 #include "IdTable.h"

+ 0 - 364
engine/core/containers/Generic.cpp

@@ -1,364 +0,0 @@
-/*
-Copyright (c) 2013 Daniele Bartolini, Michele Rossi
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include "Generic.h"
-#include "Types.h"
-
-namespace crown
-{
-
-//-----------------------------------------------------------------------------
-Generic::Generic() : m_type(GT_UNDEFINED)
-{
-}
-
-//-----------------------------------------------------------------------------
-Generic::Generic(const Generic& other)
-{
-	*this = other;
-}
-
-//-----------------------------------------------------------------------------
-Generic::~Generic()
-{
-}
-
-//-----------------------------------------------------------------------------
-Generic::Generic(int32_t value) : m_type(GT_INT)
-{
-	m_data.int32_t_value = value;
-}
-
-//-----------------------------------------------------------------------------
-Generic::Generic(uint32_t value) : m_type(GT_UINT)
-{
-	m_data.uint32_t_value = value;
-}
-
-//-----------------------------------------------------------------------------
-Generic::Generic(uint16_t value) : m_type(GT_USHORT)
-{
-	m_data.uint16_t_value = value;
-}
-
-//-----------------------------------------------------------------------------
-Generic::Generic(float value) : m_type(GT_FLOAT)
-{
-	m_data.float_value = value;
-}
-
-//-----------------------------------------------------------------------------
-Generic::Generic(bool value) : m_type(GT_BOOL)
-{
-	m_data.bool_value = value;
-}
-
-//-----------------------------------------------------------------------------
-bool Generic::as_int32_t(int32_t& out) const
-{
-	if (m_type == GT_INT)
-	{
-		out = m_data.int32_t_value;
-		return true;
-	}
-
-	if (m_type == GT_UINT)
-	{
-		out = (int32_t)m_data.uint32_t_value;
-		return true;
-	}
-
-	if (m_type == GT_USHORT)
-	{
-		out = (int32_t)m_data.uint16_t_value;
-		return true;
-	}
-
-	if (m_type == GT_FLOAT)
-	{
-		out = (int32_t)m_data.float_value;
-		return true;
-	}
-
-	if (m_type == GT_BOOL)
-	{
-		out = m_data.bool_value ? 1 : 0;
-		return true;
-	}
-
-	return false;
-}
-
-//-----------------------------------------------------------------------------
-int32_t Generic::as_int32_t() const
-{
-	int32_t value = 0;
-	as_int32_t(value);
-	return value;
-}
-
-//-----------------------------------------------------------------------------
-bool Generic::as_uint32_t(uint32_t& out) const
-{
-	if (m_type == GT_INT)
-	{
-		out = (uint32_t)m_data.int32_t_value;
-		return true;
-	}
-
-	if (m_type == GT_UINT)
-	{
-		out = m_data.uint32_t_value;
-		return true;
-	}
-
-	if (m_type == GT_USHORT)
-	{
-		out = (uint32_t)m_data.uint16_t_value;
-		return true;
-	}
-
-	if (m_type == GT_FLOAT)
-	{
-		out = (uint32_t)m_data.float_value;
-		return true;
-	}
-
-	if (m_type == GT_BOOL)
-	{
-		out = m_data.bool_value?1:0;
-		return true;
-	}
-
-	return false;
-}
-
-//-----------------------------------------------------------------------------
-uint32_t Generic::as_uint32_t() const
-{
-	uint32_t value = 0;
-	as_uint32_t(value);
-	return value;
-}
-
-//-----------------------------------------------------------------------------
-bool Generic::as_uint16_t(uint16_t& out) const
-{
-	if (m_type == GT_INT)
-	{
-		out = (uint16_t)m_data.int32_t_value;
-		return true;
-	}
-
-	if (m_type == GT_UINT)
-	{
-		out = (uint16_t)m_data.uint32_t_value;
-		return true;
-	}
-
-	if (m_type == GT_USHORT)
-	{
-		out = m_data.uint16_t_value;
-		return true;
-	}
-
-	if (m_type == GT_FLOAT)
-	{
-		out = (uint16_t)m_data.float_value;
-		return true;
-	}
-
-	if (m_type == GT_BOOL)
-	{
-		out = m_data.bool_value?1:0;
-		return true;
-	}
-
-	return false;
-}
-
-//-----------------------------------------------------------------------------
-uint16_t Generic::as_uint16_t() const
-{
-	uint16_t value = 0;
-	as_uint16_t(value);
-	return value;
-}
-
-//-----------------------------------------------------------------------------
-bool Generic::as_float(float& out) const
-{
-	if (m_type == GT_INT)
-	{
-		out = (float)m_data.int32_t_value;
-		return true;
-	}
-
-	if (m_type == GT_UINT)
-	{
-		out = (float)m_data.uint32_t_value;
-		return true;
-	}
-
-	if (m_type == GT_USHORT)
-	{
-		out = (float)m_data.uint16_t_value;
-		return true;
-	}
-
-	if (m_type == GT_FLOAT)
-	{
-		out = m_data.float_value;
-		return true;
-	}
-
-	if (m_type == GT_BOOL)
-	{
-		out = m_data.bool_value?1.0f:0.0f;
-		return true;
-	}
-
-	return false;
-}
-
-//-----------------------------------------------------------------------------
-float Generic::as_float() const
-{
-	float value = 0.0f;
-	as_float(value);
-	return value;
-}
-
-//-----------------------------------------------------------------------------
-bool Generic::as_bool(bool& out) const
-{
-	if (m_type == GT_INT)
-	{
-		out = m_data.int32_t_value==0?false:true;
-		return true;
-	}
-
-	if (m_type == GT_UINT)
-	{
-		out = m_data.uint32_t_value==0?false:true;
-		return true;
-	}
-
-	if (m_type == GT_USHORT)
-	{
-		out = m_data.uint16_t_value==0?false:true;
-		return true;
-	}
-
-	if (m_type == GT_FLOAT)
-	{
-		//Does it make sense?
-		out = m_data.float_value==0.0f?false:true;
-		return true;
-	}
-
-	if (m_type == GT_BOOL)
-	{
-		out = m_data.bool_value;
-		return true;
-	}
-
-	return false;
-}
-
-//-----------------------------------------------------------------------------
-bool Generic::as_bool() const
-{
-	bool value = false;
-	as_bool(value);
-	return value;
-}
-
-//-----------------------------------------------------------------------------
-bool Generic::operator==(const Generic& other)
-{
-	if (m_type != other.m_type)
-	{
-		return false;
-	}
-
-	switch (m_type)
-	{
-		case GT_INT:
-			return m_data.int32_t_value == other.m_data.int32_t_value;
-			break;
-		case GT_UINT:
-			return m_data.uint32_t_value == other.m_data.uint32_t_value;
-			break;
-		case GT_USHORT:
-			return m_data.uint16_t_value == other.m_data.uint16_t_value;
-			break;
-		case GT_FLOAT:
-			return m_data.float_value == other.m_data.float_value;
-			break;
-		case GT_BOOL:
-			return m_data.bool_value == other.m_data.bool_value;
-			break;
-		case GT_UNDEFINED:
-			return true;
-			break;
-	}
-
-	return false;
-}
-
-//-----------------------------------------------------------------------------
-const Generic& Generic::operator=(const Generic& other)
-{
-	m_type = other.m_type;
-
-	switch (m_type)
-	{
-		case GT_INT:
-			m_data.int32_t_value = other.m_data.int32_t_value;
-			break;
-		case GT_UINT:
-			m_data.uint32_t_value = other.m_data.uint32_t_value;
-			break;
-		case GT_USHORT:
-			m_data.uint16_t_value = other.m_data.uint16_t_value;
-			break;
-		case GT_FLOAT:
-			m_data.float_value = other.m_data.float_value;
-			break;
-		case GT_BOOL:
-			m_data.bool_value = other.m_data.bool_value;
-			break;
-		case GT_UNDEFINED:
-			//Copy nothing
-			break;
-	}
-
-	return other;
-}
-
-} // namespace crown
-

+ 0 - 126
engine/core/containers/Generic.h

@@ -1,126 +0,0 @@
-/*
-Copyright (c) 2013 Daniele Bartolini, Michele Rossi
-Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#pragma once
-
-#include "Types.h"
-
-namespace crown
-{
-
-class Generic
-{
-public:
-
-	enum Type
-	{
-		GT_UNDEFINED	= 0,
-
-		// Basic types
-		GT_INT			= 1,
-		GT_UINT			= 2,
-		GT_USHORT		= 3,
-		GT_FLOAT		= 4,
-		GT_BOOL			= 5
-	};
-
-					Generic();
-					Generic(const Generic& other);
-					~Generic();
-
-	explicit		Generic(int32_t value);
-	explicit		Generic(uint32_t value);
-	explicit		Generic(uint16_t value);
-	explicit		Generic(float value);
-	explicit		Generic(bool value);
-	explicit		Generic(const char* value);
-
-	inline Type		get_type() const { return m_type; }
-
-	bool			as_int32_t(int32_t& out) const;
-	int32_t			as_int32_t() const;
-
-	bool			as_uint32_t(uint32_t& out) const;
-	uint32_t		as_uint32_t() const;
-
-	bool			as_uint16_t(uint16_t& out) const;
-	uint16_t	as_uint16_t() const;
-
-	bool			as_float(float& out) const;
-	float			as_float() const;
-
-	bool			as_bool(bool& out) const;
-	bool			as_bool() const;
-
-	template <typename T>
-	bool			as_type(T* out) const;
-	template <typename T>
-	T*				as_type() const;
-
-	const Generic&	operator=(const Generic& other);
-
-	bool			operator==(const Generic& other);
-
-private:
-
-	union Data
-	{
-		int32_t		int32_t_value;
-		uint32_t	uint32_t_value;
-		uint16_t	uint16_t_value;
-		float		float_value;
-		bool		bool_value;
-	};
-
-	Type			m_type;
-	Data			m_data;
-};
-
-template <typename T>
-bool Generic::as_type(T* out) const
-{
-//	if (mType == GT_Object)
-//	{
-//		*out = dynamic_cas_t<T>(mData.object_value);
-//		return *out != NULL || mData.object_value == NULL;
-//	}
-
-	return false;
-}
-
-template <typename T>
-T* Generic::as_type() const
-{
-//	if (mType == GT_Object)
-//	{
-//		return dynamic_cast<T*>(mData.object_value);
-//	}
-
-	return NULL;
-}
-
-} //namespace crown
-