diff --git a/src/phasicFlow/containers/pointField/boundaryField.cpp b/src/phasicFlow/containers/pointField/boundaryField.cpp index 230be98b..1b6ba9c1 100644 --- a/src/phasicFlow/containers/pointField/boundaryField.cpp +++ b/src/phasicFlow/containers/pointField/boundaryField.cpp @@ -50,7 +50,8 @@ pFlow::uniquePtr> { printKeys ( - fatalError << "Ctor Selector "<< bType << " dose not exist. \n" + fatalError << "Ctor Selector "<< bType << "for type "<< + Yellow_Text(getTypeName()) << " dose not exist.\n" <<"Avaiable ones are: \n\n" , boundaryBasevCtorSelector_ diff --git a/src/phasicFlow/typeSelection/typeInfo.hpp b/src/phasicFlow/typeSelection/typeInfo.hpp index 8eec379d..74794729 100644 --- a/src/phasicFlow/typeSelection/typeInfo.hpp +++ b/src/phasicFlow/typeSelection/typeInfo.hpp @@ -44,6 +44,96 @@ Licence: }; +namespace pFlow +{ + // + template + struct checkStatic + { + has_static_member(TYPENAME); + + static constexpr + bool hasMember() + { + return has_static_member_TYPENAME::value; + } + }; + + template + inline word basicTypeName() + { + int status; + auto& ti = typeid(T); + char* realname = abi::__cxa_demangle(ti.name(), 0, 0, &status); + word name(realname); + free(realname); + return name; + } + + template<> + inline word basicTypeName(){ return "word"; } + + template<> + inline word basicTypeName(){ return "int64"; } + + template<> + inline word basicTypeName(){ return "int32"; } + + template<> + inline word basicTypeName(){ return "int8"; } + + template<> + inline word basicTypeName(){ return "uint64"; } + + template<> + inline word basicTypeName(){ return "uint32"; } + + template<> + inline word basicTypeName(){ return "uint8"; } + + template<> + inline word basicTypeName(){ return "real"; } + + + template + word constexpr getTypeName() + { + + if constexpr ( checkStatic::hasMember() ) + { + return T::TYPENAME(); + }else + { + return basicTypeName(); + } + } + template + word constexpr getTypeName(const T&) + { + if constexpr ( checkStatic::hasMember() ) + { + return T::TYPENAME(); + }else + { + return basicTypeName(); + } + } + + // compare the overriden typeName of object with concrete TYPENAME + // of Type1 + template + bool checkType(Type2* object) + { + return getTypeName() == object->typeName(); + } + + template + bool checkType(Type2& object) + { + return getTypeName() == object.typeName(); + } +} + #define TypeInfo(tName) \ inline static word TYPENAME() {return tName; } \ @@ -55,6 +145,52 @@ Licence: #define TypeInfoTemplate11(tName, Type) \ + has_static_member(TYPENAME); \ + inline static word TYPENAME() \ + { \ + return word(tName)+"<"+getTypeName()+">"; \ + } \ + virtual word typeName() const { return TYPENAME();} + +#define TypeInfoTemplate12(tName, Type1, Type2) \ + inline static word TYPENAME() \ + { \ + return word(tName)+"<"+getTypeName()+","+getTypeName()+">";} \ + } \ + virtual word typeName() const { return TYPENAME();} + +#define TypeInfoTemplate13(tName, Type1, Type2, Type3) \ + inline static word TYPENAME() \ + { \ + return word(tName)+"<"+getTypeName()+","+getTypeName()+","+getTypeName()+">";\ + } \ + virtual word typeName() const { return TYPENAME();} + +// this is the non-virtual version +#define TypeInfoTemplateNV11(tName, Type) \ + inline static word TYPENAME() \ + { \ + return word(tName)+"<"+getTypeName()+">"; \ + } \ + inline word typeName() const { return TYPENAME();} + + +#define TypeInfoTemplateNV111(tName, Type, tName2) \ + inline static word TYPENAME() \ + { \ + return word(tName)+"<"+getTypeName()+","+word(tName2)+">"; \ + } \ + inline word typeName() const { return TYPENAME();} + +#define TypeInfoTemplate111(tName, Type, tName2) \ + inline static word TYPENAME() \ + { \ + return word(tName)+"<"+getTypeName()+","+word(tName2)+">"; \ + } \ + virtual word typeName() const { return TYPENAME();} + + +/*#define TypeInfoTemplate11(tName, Type) \ has_static_member(TYPENAME); \ inline static word TYPENAME() \ { \ @@ -121,7 +257,7 @@ Licence: return word(tName)+"<"+basicTypeName()+","+word(tName2)+">"; \ return "noTYPE"; \ } \ - virtual word typeName() const { return TYPENAME();} + virtual word typeName() const { return TYPENAME();}*/ @@ -131,55 +267,7 @@ Licence: namespace pFlow { - template - inline word basicTypeName() - { - int status; - auto& ti = typeid(T); - char* realname = abi::__cxa_demangle(ti.name(), 0, 0, &status); - word name(realname); - free(realname); - return name; - } - - template<> - inline word basicTypeName(){ return "word"; } - - template<> - inline word basicTypeName(){ return "int64"; } - - template<> - inline word basicTypeName(){ return "int32"; } - - template<> - inline word basicTypeName(){ return "int8"; } - - template<> - inline word basicTypeName(){ return "uint64"; } - - template<> - inline word basicTypeName(){ return "uint32"; } - - template<> - inline word basicTypeName(){ return "uint8"; } - - template<> - inline word basicTypeName(){ return "real"; } - - - // compare the overriden typeName of object with concrete TYPENAME - // of Type1 - template - bool checkType(Type2* object) - { - return word(Type1::TYPENAME()) == object->typeName(); - } - - template - bool checkType(Type2& object) - { - return word(Type1::TYPENAME()) == object.typeName(); - } +