Explorar o código

Remove ReferenceCountable, finally!

Michael Ragazzon %!s(int64=6) %!d(string=hai) anos
pai
achega
649c0cc809

+ 1 - 2
Cmake/FileList.cmake

@@ -167,7 +167,6 @@ set(Core_PUB_HDR_FILES
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/PropertyDictionary.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/PropertyParser.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/PropertySpecification.h
-    ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ReferenceCountable.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/RenderInterface.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/ScriptInterface.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Spritesheet.h
@@ -180,6 +179,7 @@ set(Core_PUB_HDR_FILES
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/StyleSheetSpecification.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/SystemInterface.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Texture.h
+    ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Traits.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/Transform.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/TransformPrimitive.h
     ${PROJECT_SOURCE_DIR}/Include/RmlUi/Core/TransformState.h
@@ -296,7 +296,6 @@ set(Core_SRC_FILES
     ${PROJECT_SOURCE_DIR}/Source/Core/PropertyParserString.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/PropertyParserTransform.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/PropertySpecification.cpp
-    ${PROJECT_SOURCE_DIR}/Source/Core/ReferenceCountable.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/RenderInterface.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/Spritesheet.cpp
     ${PROJECT_SOURCE_DIR}/Source/Core/Stream.cpp

+ 1 - 1
Include/RmlUi/Core/Context.h

@@ -31,7 +31,7 @@
 
 #include "Header.h"
 #include "Types.h"
-#include "ReferenceCountable.h"
+#include "Traits.h"
 #include "Input.h"
 #include "String.h"
 #include "ScriptInterface.h"

+ 1 - 1
Include/RmlUi/Core/ContextInstancer.h

@@ -29,8 +29,8 @@
 #ifndef RMLUICORECONTEXTINSTANCER_H
 #define RMLUICORECONTEXTINSTANCER_H
 
-#include "ReferenceCountable.h"
 #include "Header.h"
+#include "Traits.h"
 
 namespace Rml {
 namespace Core {

+ 1 - 1
Include/RmlUi/Core/ElementInstancer.h

@@ -29,7 +29,7 @@
 #ifndef RMLUICOREELEMENTINSTANCER_H
 #define RMLUICOREELEMENTINSTANCER_H
 
-#include "ReferenceCountable.h"
+#include "Traits.h"
 #include "XMLParser.h"
 #include "Header.h"
 

+ 1 - 1
Include/RmlUi/Core/EventInstancer.h

@@ -29,7 +29,7 @@
 #ifndef RMLUICOREEVENTINSTANCER_H
 #define RMLUICOREEVENTINSTANCER_H
 
-#include "ReferenceCountable.h"
+#include "Traits.h"
 #include "Header.h"
 
 namespace Rml {

+ 1 - 1
Include/RmlUi/Core/EventListenerInstancer.h

@@ -29,7 +29,7 @@
 #ifndef RMLUICOREEVENTLISTENERINSTANCER_H
 #define RMLUICOREEVENTLISTENERINSTANCER_H
 
-#include "ReferenceCountable.h"
+#include "Traits.h"
 #include "String.h"
 #include "Header.h"
 #include "Element.h"

+ 1 - 1
Include/RmlUi/Core/FileInterface.h

@@ -31,7 +31,7 @@
 
 #include "Header.h"
 #include "Types.h"
-#include "ReferenceCountable.h"
+#include "Traits.h"
 
 namespace Rml {
 namespace Core {

+ 1 - 1
Include/RmlUi/Core/FontEffectInstancer.h

@@ -29,7 +29,7 @@
 #ifndef RMLUICOREFONTEFFECTINSTANCER_H
 #define RMLUICOREFONTEFFECTINSTANCER_H
 
-#include "ReferenceCountable.h"
+#include "Traits.h"
 #include "Header.h"
 #include "PropertyDictionary.h"
 #include "PropertySpecification.h"

+ 1 - 1
Include/RmlUi/Core/RenderInterface.h

@@ -29,7 +29,7 @@
 #ifndef RMLUICORERENDERINTERFACE_H
 #define RMLUICORERENDERINTERFACE_H
 
-#include "ReferenceCountable.h"
+#include "Traits.h"
 #include "Header.h"
 #include "Texture.h"
 #include "Vertex.h"

+ 1 - 1
Include/RmlUi/Core/ScriptInterface.h

@@ -30,7 +30,7 @@
 #define RMLUICORESCRIPTINTERFACE_H
 
 #include "Header.h"
-#include "ReferenceCountable.h"
+#include "Traits.h"
 #include "Types.h"
 
 namespace Rml {

+ 1 - 1
Include/RmlUi/Core/Stream.h

@@ -30,7 +30,7 @@
 #define RMLUICORESTREAM_H
 
 #include "Header.h"
-#include "ReferenceCountable.h"
+#include "Traits.h"
 #include "Types.h"
 #include "URL.h"
 #include <list>

+ 1 - 1
Include/RmlUi/Core/StyleSheet.h

@@ -29,7 +29,7 @@
 #ifndef RMLUICORESTYLESHEET_H
 #define RMLUICORESTYLESHEET_H
 
-#include "ReferenceCountable.h"
+#include "Traits.h"
 #include "PropertyDictionary.h"
 #include "Spritesheet.h"
 #include <set>

+ 1 - 1
Include/RmlUi/Core/SystemInterface.h

@@ -30,7 +30,7 @@
 #define RMLUICORESYSTEMINTERFACE_H
 
 #include "Log.h"
-#include "ReferenceCountable.h"
+#include "Traits.h"
 #include "String.h"
 #include "Header.h"
 

+ 1 - 43
Include/RmlUi/Core/ReferenceCountable.h → Include/RmlUi/Core/Traits.h

@@ -66,54 +66,12 @@ template<typename T>
 class RMLUICORE_API Releaser final : public ReleaserBase {
 public:
 	void operator()(T* target) const {
-		static_assert(std::is_base_of<Releasable, T>::value, "Releaser can only operate with classes derived from Releasable.");
+		static_assert(std::is_base_of<Releasable, T>::value, "Rml::Core::Releaser can only operate with classes derived from Rml::Core::Releasable.");
 		Release(static_cast<Releasable*>(target));
 	}
 };
 
 
-
-
-/**
-	A base class for any class that wishes to be reference counted.
-	@author Robert Curry
-*/
-
-class RMLUICORE_API ReferenceCountable
-{
-public:
-	/// Constructor.
-	/// @param[in] initial_count The initial reference count of the object.
-	ReferenceCountable(int initial_count = 1);
-
-	/// Returns the number of references outstanding against this object.
-	int GetReferenceCount();
-	/// Increases the reference count. If this pushes the count above 0, OnReferenceActivate() will be called. 
-	void AddReference();
-	/// Decreases the reference count. If this pushes the count to 0, OnReferenceDeactivate() will be called. 
-	void RemoveReference();
-
-	/// Reference countable objects should not be copied
-	ReferenceCountable(const ReferenceCountable&) = delete;
-	ReferenceCountable& operator=(const ReferenceCountable&) = delete;
-
-	/// If any reference countable objects are still allocated, this function will write a leak report to the log.
-	static void DumpLeakReport();
-
-protected:		
-	/// Destructor. The reference count must be 0 when this is invoked.
-	~ReferenceCountable();
-
-	/// A hook method called when the reference count climbs from 0.
-	virtual void OnReferenceActivate();
-	/// A hook method called when the reference count drops to 0.
-	virtual void OnReferenceDeactivate();
-
-private:
-	// The number of references against this object.
-	int reference_count;
-};
-
 }
 }
 

+ 1 - 1
Include/RmlUi/Core/Types.h

@@ -48,7 +48,7 @@
 
 #include "Platform.h"
 #include "Debug.h"
-#include "ReferenceCountable.h"
+#include "Traits.h"
 
 #ifdef RMLUI_DEBUG
 #include <unordered_map>

+ 1 - 1
Include/RmlUi/Core/XMLNodeHandler.h

@@ -29,7 +29,7 @@
 #ifndef RMLUICOREXMLNODEHANDLER_H
 #define RMLUICOREXMLNODEHANDLER_H
 
-#include "ReferenceCountable.h"
+#include "Traits.h"
 #include "XMLParser.h"
 #include "Header.h"
 

+ 1 - 1
Source/Core/ElementDefinition.h

@@ -30,7 +30,7 @@
 #define RMLUICOREELEMENTDEFINITION_H
 
 #include "../../Include/RmlUi/Core/Dictionary.h"
-#include "../../Include/RmlUi/Core/ReferenceCountable.h"
+#include "../../Include/RmlUi/Core/Traits.h"
 
 namespace Rml {
 namespace Core {

+ 1 - 1
Source/Core/FontFaceHandle.h

@@ -29,7 +29,7 @@
 #ifndef RMLUICOREFONTFACEHANDLE_H
 #define RMLUICOREFONTFACEHANDLE_H
 
-#include "../../Include/RmlUi/Core/ReferenceCountable.h"
+#include "../../Include/RmlUi/Core/Traits.h"
 #include "UnicodeRange.h"
 #include "../../Include/RmlUi/Core/Font.h"
 #include "../../Include/RmlUi/Core/FontEffect.h"

+ 0 - 1
Source/Core/FreeType/FontFaceHandle.h

@@ -29,7 +29,6 @@
 #ifndef RMLUICOREFREETYPEFONTFACEHANDLE_H
 #define RMLUICOREFREETYPEFONTFACEHANDLE_H
 
-#include "../../../Include/RmlUi/Core/ReferenceCountable.h"
 #include "../UnicodeRange.h"
 #include "../FontFaceHandle.h"
 #include "../../../Include/RmlUi/Core/FontEffect.h"

+ 0 - 96
Source/Core/ReferenceCountable.cpp

@@ -1,96 +0,0 @@
-/*
- * This source file is part of RmlUi, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://github.com/mikke89/RmlUi
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- * Copyright (c) 2019 The RmlUi Team, and contributors
- *
- * 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 "precompiled.h"
-#include "../../Include/RmlUi/Core/ReferenceCountable.h"
-
-namespace Rml {
-namespace Core {
-
-static int num_outstanding_objects = 0;
-
-// Constructor.
-ReferenceCountable::ReferenceCountable(int initial_count)
-{
-	reference_count = initial_count;
-	++num_outstanding_objects;
-}
-
-// Destructor. The reference count must be 0 when this is invoked.
-ReferenceCountable::~ReferenceCountable()
-{
-	RMLUI_ASSERT(reference_count == 0);
-	--num_outstanding_objects;
-}
-
-// Returns the number of references outstanding against this object.
-int ReferenceCountable::GetReferenceCount()
-{
-	return reference_count;
-}
-
-// Adds a reference to the object.
-void ReferenceCountable::AddReference()
-{	
-	reference_count++;
-	if (reference_count == 1)
-	{
-		OnReferenceActivate();
-	}
-}
-
-// Removes a reference from the object.
-void ReferenceCountable::RemoveReference()
-{
-	RMLUI_ASSERT(reference_count > 0);
-	reference_count--;	
-	if (reference_count == 0)
-	{
-		OnReferenceDeactivate();
-	}
-}
-
-// If any reference countable objects are still allocated, this function will write a leak report to the log.
-void ReferenceCountable::DumpLeakReport()
-{
-	if (num_outstanding_objects > 0)
-		Log::Message(Log::LT_WARNING, "%d %s still allocated.", num_outstanding_objects, num_outstanding_objects == 1 ? "object" : "objects");
-}
-
-// A hook method called when the reference count climbs from 0.
-void ReferenceCountable::OnReferenceActivate()
-{
-}
-
-// A hook method called when the reference count drops to 0.
-void ReferenceCountable::OnReferenceDeactivate()
-{
-}
-
-}
-}

+ 1 - 1
Source/Core/TextureResource.h

@@ -29,7 +29,7 @@
 #ifndef RMLUICORETEXTURERESOURCE_H
 #define RMLUICORETEXTURERESOURCE_H
 
-#include "../../Include/RmlUi/Core/ReferenceCountable.h"
+#include "../../Include/RmlUi/Core/Traits.h"
 #include "../../Include/RmlUi/Core/Texture.h"
 
 namespace Rml {