From fe1b5fe740c987a5fca05493c9fdf6147a42f7b8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Tr=C3=A1vn=C3=AD=C4=8Dek?= <jan.travnicek@fit.cvut.cz>
Date: Thu, 17 Feb 2022 16:16:14 +0100
Subject: [PATCH] abstraction: make type-fixed ObjectFactoryImpl's not inlined
 + extern a common templated instantiation

---
 alib2abstraction/src/object/ObjectFactory.cpp | 51 +++++++++++++++++++
 alib2abstraction/src/object/ObjectFactory.h   | 46 +++++------------
 2 files changed, 64 insertions(+), 33 deletions(-)
 create mode 100644 alib2abstraction/src/object/ObjectFactory.cpp

diff --git a/alib2abstraction/src/object/ObjectFactory.cpp b/alib2abstraction/src/object/ObjectFactory.cpp
new file mode 100644
index 0000000000..d092fc5f0f
--- /dev/null
+++ b/alib2abstraction/src/object/ObjectFactory.cpp
@@ -0,0 +1,51 @@
+#include "ObjectFactory.h"
+
+namespace object {
+
+Object ObjectFactoryImpl < Object >::construct ( Object && object ) {
+	return std::move ( object );
+}
+
+Object ObjectFactoryImpl < const Object & >::construct ( const Object & object ) {
+	return object;
+}
+
+Object ObjectFactoryImpl < Object & >::construct ( Object & object ) {
+	return object;
+}
+
+Object ObjectFactoryImpl < const char * const & >::construct ( const char * const string ) {
+	return ObjectFactoryImpl < std::string >::construct ( std::string ( string ) );
+}
+
+Object ObjectFactoryImpl < char * const & >::construct ( char * const string ) {
+	return ObjectFactoryImpl < std::string >::construct ( std::string ( string ) );
+}
+
+Object ObjectFactoryImpl < const char * & >::construct ( const char * const string ) {
+	return ObjectFactoryImpl < std::string >::construct ( std::string ( string ) );
+}
+
+Object ObjectFactoryImpl < char * & >::construct ( char * const string ) {
+	return ObjectFactoryImpl < std::string >::construct ( std::string ( string ) );
+}
+
+Object ObjectFactoryImpl < const char * const >::construct ( const char * const string ) {
+	return ObjectFactoryImpl < std::string >::construct ( std::string ( string ) );
+}
+
+Object ObjectFactoryImpl < char * const >::construct ( char * const string ) {
+	return ObjectFactoryImpl < std::string >::construct ( std::string ( string ) );
+}
+
+Object ObjectFactoryImpl < const char * >::construct ( const char * string ) {
+	return ObjectFactoryImpl < std::string >::construct ( std::string ( string ) );
+}
+
+Object ObjectFactoryImpl < char * >::construct ( char * string ) {
+	return ObjectFactoryImpl < std::string >::construct ( std::string ( string ) );
+}
+
+template Object ObjectFactoryImpl < std::string >::construct ( std::string && );
+
+} /* namespace core */
diff --git a/alib2abstraction/src/object/ObjectFactory.h b/alib2abstraction/src/object/ObjectFactory.h
index d9fc8bca16..67b94f6888 100644
--- a/alib2abstraction/src/object/ObjectFactory.h
+++ b/alib2abstraction/src/object/ObjectFactory.h
@@ -21,89 +21,67 @@ public:
 template < >
 class ObjectFactoryImpl < Object > {
 public:
-	static Object construct ( Object && object ) {
-		return std::move ( object );
-	}
+	static Object construct ( Object && object );
 };
 
 template < >
 class ObjectFactoryImpl < const Object & > {
 public:
-	static Object construct ( const Object & object ) {
-		return object;
-	}
+	static Object construct ( const Object & object );
 };
 
 template < >
 class ObjectFactoryImpl < Object & > {
 public:
-	static Object construct ( Object & object ) {
-		return object;
-	}
+	static Object construct ( Object & object );
 };
 
 template < >
 class ObjectFactoryImpl < const char * const & > {
 public:
-	static Object construct ( const char * const string ) {
-		return ObjectFactoryImpl < std::string >::construct ( std::string ( string ) );
-	}
+	static Object construct ( const char * const string );
 };
 
 template < >
 class ObjectFactoryImpl < char * const & > {
 public:
-	static Object construct ( char * const string ) {
-		return ObjectFactoryImpl < std::string >::construct ( std::string ( string ) );
-	}
+	static Object construct ( char * const string );
 };
 
 template < >
 class ObjectFactoryImpl < const char * & > {
 public:
-	static Object construct ( const char * const string ) {
-		return ObjectFactoryImpl < std::string >::construct ( std::string ( string ) );
-	}
+	static Object construct ( const char * const string );
 };
 
 template < >
 class ObjectFactoryImpl < char * & > {
 public:
-	static Object construct ( char * const string ) {
-		return ObjectFactoryImpl < std::string >::construct ( std::string ( string ) );
-	}
+	static Object construct ( char * const string );
 };
 
 template < >
 class ObjectFactoryImpl < const char * const > {
 public:
-	static Object construct ( const char * const string ) {
-		return ObjectFactoryImpl < std::string >::construct ( std::string ( string ) );
-	}
+	static Object construct ( const char * const string );
 };
 
 template < >
 class ObjectFactoryImpl < char * const > {
 public:
-	static Object construct ( char * const string ) {
-		return ObjectFactoryImpl < std::string >::construct ( std::string ( string ) );
-	}
+	static Object construct ( char * const string );
 };
 
 template < >
 class ObjectFactoryImpl < const char * > {
 public:
-	static Object construct ( const char * string ) {
-		return ObjectFactoryImpl < std::string >::construct ( std::string ( string ) );
-	}
+	static Object construct ( const char * string );
 };
 
 template < >
 class ObjectFactoryImpl < char * > {
 public:
-	static Object construct ( char * string ) {
-		return ObjectFactoryImpl < std::string >::construct ( std::string ( string ) );
-	}
+	static Object construct ( char * string );
 };
 
 namespace details {
@@ -217,4 +195,6 @@ public:
 	}
 };
 
+extern template Object ObjectFactoryImpl < std::string >::construct ( std::string && );
+
 } /* namespace core */
-- 
GitLab