]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkAny.h
Clean code
[bbtk.git] / kernel / src / bbtkAny.h
index 74efb3ecbf3028bb088290f1837ab9f91b600914..9f161c97f08842ef35765a38323c2988d455fc06 100644 (file)
@@ -311,7 +311,13 @@ namespace bbtk
     template<typename Type>
     inline bool contains()
     {
-      return ( type() == typeid(Type) );
+//EED 2021-12-15 typeid comparation is not working in MacOs for objects declared  in different libraries
+// ex: itk <-> vtk templates convertion
+#if defined(MACOSX)
+             if ( strcmp( type().name()  , typeid(Type).name() ) ==0 ) return true; else return false;
+#else
+             return ( type() == typeid(Type) );
+#endif
     }
 
     /// Returns true iff the contained type is a pointer
@@ -323,7 +329,14 @@ namespace bbtk
     /// Returns true iff the contained type is t
     inline bool contains(TypeInfo t)
     {
-      return ( (bool)((type() == t)!=0) );
+//EED 2021-12-15 typeid comparation is not working in MacOs for objects declared  in different libraries
+// ex: itk <-> vtk templates convertion
+#if defined(MACOSX)
+        bool compTmp = (strcmp( type().name()  , t.name() ) == 0);
+        return ( compTmp!=0 );
+#else
+        return ( (bool)((type() == t)!=0) );
+#endif
      }
 
     /// Returns true iff any of type ValueType can be held 
@@ -344,9 +357,17 @@ namespace bbtk
                         <<"> with content : "
                         <<HumanTypeName(type())<<std::endl);
 
-      if ( type() == typeid(ValueType) )
-       return static_cast< anyholder<ValueType> *>(content)->held;
-
+//EED 2021-12-15 typeid comparation is not working in MacOs for objects declared  in different libraries
+// ex: itk <-> vtk templates convertion
+#if defined(MACOSX)
+    if ( strcmp( type().name()  , typeid(ValueType).name() ) ==0 )
+#else
+    if ( type() == typeid(ValueType) )
+#endif
+        {
+            return static_cast< anyholder<ValueType> *>(content)->held;
+        }
+        
       bbtkError(HumanTypeName<self >()
                <<" get with type <"
                <<bbtk::HumanTypeName<ValueType>()
@@ -357,7 +378,13 @@ namespace bbtk
     template<typename ValueType>
     inline const ValueType* getP() const
     {
+//EED 2021-12-15 typeid comparation is not working in MacOs for objects declared  in different libraries
+// ex: itk <-> vtk templates convertion
+#if defined(MACOSX)
+      if ( strcmp( type().name()  , typeid(ValueType).name() ) ==0 )
+#else
       if ( type() == typeid(ValueType) )
+#endif
        return &static_cast< anyholder<ValueType> *>(content)->held;
  
       bbtkError(HumanTypeName<self >()