From 97f0ddf82e0b9c743b377453b361368fadd4ca90 Mon Sep 17 00:00:00 2001
From: Hamidreza Norouzi <hamid.r.norouzi@gmail.com>
Date: Thu, 11 Apr 2024 13:48:37 -0700
Subject: [PATCH] modifications to typeInfo.hpp and type system

- ClassInfo is added to support for non-polymorphic typename
- removal template specialization for realx3 and etc.
- addition of new TypeInfo for triple and quadruple
- change in Logial TypeInfo to remove recursive include in some files
---
 src/phasicFlow/typeSelection/typeInfo.hpp    | 35 ++++++++++++++++++--
 src/phasicFlow/types/basicTypes/Logical.hpp  | 12 +++++--
 src/phasicFlow/types/quadruple/quadruple.hpp |  8 ++---
 src/phasicFlow/types/triple/triple.hpp       |  2 ++
 src/phasicFlow/types/types.hpp               |  8 ++---
 5 files changed, 52 insertions(+), 13 deletions(-)

diff --git a/src/phasicFlow/typeSelection/typeInfo.hpp b/src/phasicFlow/typeSelection/typeInfo.hpp
index b33a17cb..1cd0e284 100644
--- a/src/phasicFlow/typeSelection/typeInfo.hpp
+++ b/src/phasicFlow/typeSelection/typeInfo.hpp
@@ -58,7 +58,8 @@ struct checkStatic
 };
 
 template <typename T>
-inline word basicTypeName()
+inline
+word basicTypeName()
 {
 	int   status;
 	auto &ti       = typeid(T);
@@ -117,7 +118,8 @@ inline word basicTypeName<real>()
 }
 
 template <typename T>
-word constexpr getTypeName()
+inline
+word getTypeName()
 {
 	if constexpr (checkStatic<T>::hasMember())
 	{
@@ -130,7 +132,8 @@ word constexpr getTypeName()
 }
 
 template <typename T>
-word constexpr getTypeName(const T &)
+inline
+word getTypeName(const T &)
 {
 	if constexpr (checkStatic<T>::hasMember())
 	{
@@ -157,6 +160,32 @@ bool checkType(Type2 &object)
 }
 } // namespace pFlow
 
+#define QuadrupleTypeInfoNV(T)			\
+	inline static word TYPENAME()		\
+	{									\
+		return getTypeName<T>()+"x4"; 	\
+	}									\
+	word typeName() const 		  		\
+	{                             		\
+		return TYPENAME();        		\
+	}
+
+#define TripleTypeInfoNV(T)				\
+	inline static word TYPENAME()		\
+	{									\
+		return getTypeName<T>()+"x3"; 	\
+	}									\
+	word typeName() const 		  		\
+	{                             		\
+		return TYPENAME();        		\
+	}
+
+#define ClassInfo(tName)           \
+	inline static word TYPENAME() \
+	{                             \
+		return tName;             \
+	}
+
 #define TypeInfo(tName)           \
 	inline static word TYPENAME() \
 	{                             \
diff --git a/src/phasicFlow/types/basicTypes/Logical.hpp b/src/phasicFlow/types/basicTypes/Logical.hpp
index b664c54f..9b6a01d6 100755
--- a/src/phasicFlow/types/basicTypes/Logical.hpp
+++ b/src/phasicFlow/types/basicTypes/Logical.hpp
@@ -22,7 +22,7 @@ Licence:
 
 #include "builtinTypes.hpp"
 #include "bTypesFunctions.hpp"
-#include "typeInfo.hpp"
+
 
 
 namespace pFlow
@@ -62,7 +62,15 @@ private:
 public:
 
 	/// Type info
-	TypeInfoNV("Logical");
+	inline static word TYPENAME()
+	{
+		return "Logical";
+	}
+
+	inline word typeName()const
+	{
+		return TYPENAME();
+	}
 
 	//// Constructors
 
diff --git a/src/phasicFlow/types/quadruple/quadruple.hpp b/src/phasicFlow/types/quadruple/quadruple.hpp
index cf775b1b..6b4133da 100644
--- a/src/phasicFlow/types/quadruple/quadruple.hpp
+++ b/src/phasicFlow/types/quadruple/quadruple.hpp
@@ -22,6 +22,7 @@ Licence:
 #define __quadruple_hpp__
 
 #include "error.hpp"
+#include "typeInfo.hpp"
 #include "iIstream.hpp"
 #include "iOstream.hpp"
 #include "token.hpp"
@@ -40,14 +41,13 @@ class iIstream;
 // you can see it as a sequence of four elements (w,x,y,z) or an (scalar and
 // vector)
 template<typename T>
-class quadruple
+struct quadruple
 {
-public:
-
 	T         s_;
 	triple<T> v_;
 
-public:
+
+	QuadrupleTypeInfoNV(T);
 
 	//// constructors
 	INLINE_FUNCTION_HD
diff --git a/src/phasicFlow/types/triple/triple.hpp b/src/phasicFlow/types/triple/triple.hpp
index d9f45043..390c04f4 100644
--- a/src/phasicFlow/types/triple/triple.hpp
+++ b/src/phasicFlow/types/triple/triple.hpp
@@ -22,6 +22,7 @@ Licence:
 
 #include "pFlowMacros.hpp"
 #include "numericConstants.hpp"
+#include "typeInfo.hpp"
 #include "uniquePtr.hpp"
 #include "iOstream.hpp"
 #include "iIstream.hpp"
@@ -49,6 +50,7 @@ struct triple
 	T y_;
 	T z_;
 
+	TripleTypeInfoNV(T);
 	//// Constructors
 
 	/// Initilize to zero
diff --git a/src/phasicFlow/types/types.hpp b/src/phasicFlow/types/types.hpp
index 8d1f593f..37587517 100644
--- a/src/phasicFlow/types/types.hpp
+++ b/src/phasicFlow/types/types.hpp
@@ -50,16 +50,16 @@ using realx4 = quadruple<real>;
 
 using realx4x3 = quadruple<realx3>;
 
-template<>
+/*template<>
 inline word
-basicTypeName<int8x3>()
+triple<int8>::TYPENAME()
 {
 	return "int8x3";
 }
 
 template<>
 inline word
-basicTypeName<int32x3>()
+triple<int32>::TYPENAME()
 {
 	return "int32x3";
 }
@@ -132,7 +132,7 @@ inline word
 basicTypeName<realx4x3>()
 {
 	return "realx4x3";
-}
+}*/
 
 extern const realx3   zero3;
 extern const realx3   one3;