Bläddra i källkod

ReferenceCountable: Unnecessary virtual methods

Michael Ragazzon 6 år sedan
förälder
incheckning
2d0aea1872
2 ändrade filer med 9 tillägg och 13 borttagningar
  1. 9 7
      Include/Rocket/Core/ReferenceCountable.h
  2. 0 6
      Source/Core/ReferenceCountable.cpp

+ 9 - 7
Include/Rocket/Core/ReferenceCountable.h

@@ -44,23 +44,25 @@ public:
 	/// Constructor.
 	/// Constructor.
 	/// @param[in] initial_count The initial reference count of the object.
 	/// @param[in] initial_count The initial reference count of the object.
 	ReferenceCountable(int initial_count = 1);
 	ReferenceCountable(int initial_count = 1);
-	/// Destructor. The reference count must be 0 when this is invoked.
-	virtual ~ReferenceCountable();
 
 
 	/// Returns the number of references outstanding against this object.
 	/// Returns the number of references outstanding against this object.
-	virtual int GetReferenceCount();
+	int GetReferenceCount();
 	/// Increases the reference count. If this pushes the count above 0, OnReferenceActivate() will be called. 
 	/// Increases the reference count. If this pushes the count above 0, OnReferenceActivate() will be called. 
-	virtual void AddReference();
+	void AddReference();
 	/// Decreases the reference count. If this pushes the count to 0, OnReferenceDeactivate() will be called. 
 	/// Decreases the reference count. If this pushes the count to 0, OnReferenceDeactivate() will be called. 
-	virtual void RemoveReference();
+	void RemoveReference();
 
 
-	/// Catches incorrect copy attempts.
-	ReferenceCountable& operator=(const ReferenceCountable& copy);
+	/// 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.
 	/// If any reference countable objects are still allocated, this function will write a leak report to the log.
 	static void DumpLeakReport();
 	static void DumpLeakReport();
 
 
 protected:		
 protected:		
+	/// Destructor. The reference count must be 0 when this is invoked.
+	~ReferenceCountable();
+
 	/// A hook method called when the reference count climbs from 0.
 	/// A hook method called when the reference count climbs from 0.
 	virtual void OnReferenceActivate();
 	virtual void OnReferenceActivate();
 	/// A hook method called when the reference count drops to 0.
 	/// A hook method called when the reference count drops to 0.

+ 0 - 6
Source/Core/ReferenceCountable.cpp

@@ -74,12 +74,6 @@ void ReferenceCountable::RemoveReference()
 	}
 	}
 }
 }
 
 
-ReferenceCountable& ReferenceCountable::operator=(const ReferenceCountable& /*copy*/)
-{
-	ROCKET_ERRORMSG("Attempting to copy a reference counted object. This is not advisable.");
-	return *this;
-}
-
 // If any reference countable objects are still allocated, this function will write a leak report to the log.
 // If any reference countable objects are still allocated, this function will write a leak report to the log.
 void ReferenceCountable::DumpLeakReport()
 void ReferenceCountable::DumpLeakReport()
 {
 {