From dbf35c9b2d6274e3800b6cc75b18a96b0ec0c43c Mon Sep 17 00:00:00 2001
From: Shon Ferguson <shonferg@users.sourceforge.net>
Date: Sun, 28 May 2006 23:34:59 +0000
Subject: [PATCH] Realized that Ref's functions need to be in the header file
 because it is a template.

---
 niflib.vcproj |   3 --
 obj/Ref.cpp   | 102 -------------------------------------------------
 obj/Ref.h     | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+), 105 deletions(-)
 delete mode 100644 obj/Ref.cpp

diff --git a/niflib.vcproj b/niflib.vcproj
index 2cebf664..fb648bef 100644
--- a/niflib.vcproj
+++ b/niflib.vcproj
@@ -785,9 +785,6 @@
 				<File
 					RelativePath=".\obj\NiZBufferProperty.cpp">
 				</File>
-				<File
-					RelativePath=".\obj\Ref.cpp">
-				</File>
 				<File
 					RelativePath=".\obj\RootCollisionNode.cpp">
 				</File>
diff --git a/obj/Ref.cpp b/obj/Ref.cpp
deleted file mode 100644
index add4863c..00000000
--- a/obj/Ref.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/* Copyright (c) 2006, NIF File Format Library and Tools
-All rights reserved.  Please see niflib.h for licence. */
-
-#include "Ref.h"
-
-template <class T>
-Ref<T>::Ref( T * object = NULL ) : _object(object) {}
-
-template <class T>
-Ref<T>::Ref(const Ref & ref_to_copy ) {
-	_object = ref_to_copy._object;
-	//If object isn't null, increment reference count
-	if ( _object != NULL ) {
-		_object->AddRef();
-	}
-}
-
-template <class T>
-Ref<T>::operator T*() const {
-	return _object;
-}
-
-template <class T>
-T& Ref<T>::operator*() const {
-	return _object;
-}
-
-template <class T>
-T* Ref<T>::operator->() const {
-	return _object;
-}
-
-template <class T>
-Ref<T> & Ref<T>::operator=( T * object ) {
-	//Check if referenced objects are already the same
-	if ( _object == object ) {
-		return this; //Do nothing
-	}
-
-	//Decriment reference count on previously referenced object, if any
-	if ( _object != NULL ) {
-		_object->SubtractRef();
-	}
-
-	//Change reference to new object
-	_object = object;
-
-	//Increment reerence count on new object if it is not NULL
-	if ( _object != NULL ) {
-		_object->AddRef();
-	}
-}
-
-template <class T>
-Ref<T> & Ref<T>::operator=( const Ref & ref ) {
-	//Check if referenced objects are already the same
-	if ( _object == ref._object ) {
-		return this; //Do nothing
-	}
-
-	//Decriment reference count on previously referenced object, if any
-	if ( _object != NULL ) {
-		_object->SubtractRef();
-	}
-
-	//Change reference to new object
-	_object = ref._object;
-
-	//Increment reerence count on new object if it is not NULL
-	if ( _object != NULL ) {
-		_object->AddRef();
-	}
-}
-
-template <class T>
-bool Ref<T>::operator<(const Ref & ref) const {
-	return (_object < ref._object);
-}
-
-template <class T>
-bool Ref<T>::operator==(T * object) const {
-	//Compare pointer values of referenced objects
-	return ( _object == object );
-}
-
-template <class T>
-bool Ref<T>::operator!=(T * object) const {
-	//Compare pointer values of referenced objects
-	return ( _object != object );
-}
-
-template <class T>
-bool Ref<T>::operator==(const Ref & ref) const {
-	//Compare pointer values of referenced objects
-	return ( _object == ref._object );
-}
-
-template <class T>
-bool Ref<T>::operator!=(const Ref & ref) const {
-	//Compare pointer values of referenced objects
-	return ( _object != ref._object );
-}
diff --git a/obj/Ref.h b/obj/Ref.h
index e6767f3d..22262137 100644
--- a/obj/Ref.h
+++ b/obj/Ref.h
@@ -31,4 +31,108 @@ protected:
 	T* _object;
 };
 
+template <class T>
+Ref<T>::Ref( T * object = NULL ) : _object(object) {}
+
+template <class T>
+Ref<T>::Ref(const Ref & ref_to_copy ) {
+	_object = ref_to_copy._object;
+	//If object isn't null, increment reference count
+	if ( _object != NULL ) {
+		_object->AddRef();
+	}
+}
+
+template <class T>
+Ref<T>::operator T*() const {
+	return _object;
+}
+
+template <class T>
+T& Ref<T>::operator*() const {
+	return _object;
+}
+
+template <class T>
+T* Ref<T>::operator->() const {
+	return _object;
+}
+
+template <class T>
+Ref<T> & Ref<T>::operator=( T * object ) {
+	//Check if referenced objects are already the same
+	if ( _object == object ) {
+		return *this; //Do nothing
+	}
+
+	//Decriment reference count on previously referenced object, if any
+	if ( _object != NULL ) {
+		_object->SubtractRef();
+	}
+
+	//Change reference to new object
+	_object = object;
+
+	//Increment reerence count on new object if it is not NULL
+	if ( _object != NULL ) {
+		_object->AddRef();
+	}
+
+	return *this;
+}
+
+template <class T>
+Ref<T> & Ref<T>::operator=( const Ref & ref ) {
+	//Check if referenced objects are already the same
+	if ( _object == ref._object ) {
+		return *this; //Do nothing
+	}
+
+	//Decriment reference count on previously referenced object, if any
+	if ( _object != NULL ) {
+		_object->SubtractRef();
+	}
+
+	//Change reference to new object
+	_object = ref._object;
+
+	//Increment reerence count on new object if it is not NULL
+	if ( _object != NULL ) {
+		_object->AddRef();
+	}
+
+	return *this;
+}
+
+//Template functions must be in the header file
+
+template <class T>
+bool Ref<T>::operator<(const Ref & ref) const {
+	return (_object < ref._object);
+}
+
+template <class T>
+bool Ref<T>::operator==(T * object) const {
+	//Compare pointer values of referenced objects
+	return ( _object == object );
+}
+
+template <class T>
+bool Ref<T>::operator!=(T * object) const {
+	//Compare pointer values of referenced objects
+	return ( _object != object );
+}
+
+template <class T>
+bool Ref<T>::operator==(const Ref & ref) const {
+	//Compare pointer values of referenced objects
+	return ( _object == ref._object );
+}
+
+template <class T>
+bool Ref<T>::operator!=(const Ref & ref) const {
+	//Compare pointer values of referenced objects
+	return ( _object != ref._object );
+}
+
 #endif
\ No newline at end of file
-- 
GitLab