Salome HOME
Fix: getCellsContainingPoints() in case of polyhedron with a face containing colinear...
[tools/medcoupling.git] / src / MEDCoupling_Swig / MEDCouplingRefCountObject.i
index 75881f9a4d1de34c4ed68550fe72c514e2ab8782..a258f4e313290205456549a36be5dc6d9f1f7468 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2024  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -29,14 +29,33 @@ namespace INTERP_KERNEL
     %extend
     {
       std::string __str__() const
-        {
-          return std::string(self->what());
-        }
+      {
+        return std::string(self->what());
+      }
     }
   };
 }
 
-namespace ParaMEDMEM
+/*
+ * ABN: Install default exception handler: this catches all INTERP_KERNEL::Exception (even when no
+ * except declaration was added to the function declaration) and propagates it to the Python level.
+ */
+%exception {
+  try {
+    $action
+  }
+  catch (INTERP_KERNEL::Exception& _e) {
+    // Reraise with SWIG_Python_Raise
+    SWIG_Python_Raise(SWIG_NewPointerObj((new INTERP_KERNEL::Exception(static_cast< const INTERP_KERNEL::Exception& >(_e))),SWIGTYPE_p_INTERP_KERNEL__Exception,SWIG_POINTER_OWN), "INTERP_KERNEL::Exception", SWIGTYPE_p_INTERP_KERNEL__Exception);
+#ifdef MEDCOUPLING_SWIG4_COMPAT
+    return nullptr;
+#else
+    SWIG_fail;
+#endif
+  }
+}
+
+namespace MEDCoupling
 {
   class TimeLabel
   {
@@ -49,52 +68,56 @@ namespace ParaMEDMEM
   };
 }
 
-namespace ParaMEDMEM
+namespace MEDCoupling
 {
-  typedef enum
+  enum class DeallocType
     {
       C_DEALLOC = 2,
       CPP_DEALLOC = 3
-    } DeallocType;
+    };
 
   const char *MEDCouplingVersionStr();
   int MEDCouplingVersion();
   int MEDCouplingSizeOfVoidStar();
+  int MEDCouplingSizeOfIDs();
   bool MEDCouplingByteOrder();
   const char *MEDCouplingByteOrderStr();
-
+  bool IsCXX11Compiled();
+  
   class BigMemoryObject
   {
   public:
-    std::size_t getHeapMemorySize() const throw(INTERP_KERNEL::Exception);
-    std::string getHeapMemorySizeStr() const throw(INTERP_KERNEL::Exception);
-    bool isObjectInTheProgeny(const BigMemoryObject *obj) const throw(INTERP_KERNEL::Exception);
-    virtual std::size_t getHeapMemorySizeWithoutChildren() const throw(INTERP_KERNEL::Exception);
+    std::size_t getHeapMemorySize() const;
+    std::string getHeapMemorySizeStr() const;
+    bool isObjectInTheProgeny(const BigMemoryObject *obj) const;
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::string debugHeapMemorySize() const;
+    std::string getClassName() const;
     virtual ~BigMemoryObject();
     %extend
     {
-      virtual PyObject *getDirectChildren() const throw(INTERP_KERNEL::Exception)
+      virtual PyObject *getDirectChildren() const
       {
         std::vector<const BigMemoryObject *> c(self->getDirectChildren());
         PyObject *ret(PyList_New(c.size()));
         for(std::size_t i=0;i<c.size();i++)
-          PyList_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(c[i]),SWIGTYPE_p_ParaMEDMEM__BigMemoryObject, 0 | 0 ));
+          PyList_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(c[i]),SWIGTYPE_p_MEDCoupling__BigMemoryObject, 0 | 0 ));
         return ret;
       }
 
-      PyObject *getAllTheProgeny() const throw(INTERP_KERNEL::Exception)
+      PyObject *getAllTheProgeny() const
       {
         std::vector<const BigMemoryObject *> c(self->getAllTheProgeny());
         PyObject *ret(PyList_New(c.size()));
         for(std::size_t i=0;i<c.size();i++)
-          PyList_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(c[i]),SWIGTYPE_p_ParaMEDMEM__BigMemoryObject, 0 | 0 ));
+          PyList_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(c[i]),SWIGTYPE_p_MEDCoupling__BigMemoryObject, 0 | 0 ));
         return ret;
       }
 
-      static std::size_t GetHeapMemorySizeOfObjs(PyObject *objs) throw(INTERP_KERNEL::Exception)
+      static std::size_t GetHeapMemorySizeOfObjs(PyObject *objs)
       {
         std::vector<const BigMemoryObject *> cppObjs;
-        convertFromPyObjVectorOfObj<const ParaMEDMEM::BigMemoryObject *>(objs,SWIGTYPE_p_ParaMEDMEM__BigMemoryObject,"BigMemoryObject",cppObjs);
+        convertFromPyObjVectorOfObj<const MEDCoupling::BigMemoryObject *>(objs,SWIGTYPE_p_MEDCoupling__BigMemoryObject,"BigMemoryObject",cppObjs);
         return BigMemoryObject::GetHeapMemorySizeOfObjs(cppObjs);
       }
     }
@@ -115,6 +138,29 @@ namespace ParaMEDMEM
   protected:
     ~RefCountObject();
   };
+
+  class GlobalDict
+  {
+  public:
+    static GlobalDict *GetInstance();
+    bool hasKey(const std::string& key) const;
+    std::string value(const std::string& key) const;
+    std::vector<std::string> keys() const;
+    void erase(const std::string& key);
+    void clear();
+    void setKeyValue(const std::string& key, const std::string& value);
+    void setKeyValueForce(const std::string& key, const std::string& value);
+  private:
+    GlobalDict();
+  public:
+    %extend
+    {
+      std::string __str__() const
+      {
+        return self->printSelf();
+      }
+    }
+  };
 }
 
 %inline
@@ -147,8 +193,17 @@ namespace ParaMEDMEM
     return false;
 #endif
   }
+  
+  bool MEDCouplingUse64BitIDs()
+  {
+#ifndef MEDCOUPLING_USE_64BIT_IDS
+    return false;
+#else
+    return true;
+#endif
+  }
 
-  std::string MEDCouplingCompletionScript() throw(INTERP_KERNEL::Exception)
+  std::string MEDCouplingCompletionScript()
   {
     static const char script[]="import rlcompleter,readline\nreadline.parse_and_bind('tab:complete')";
     std::ostringstream oss; oss << "MEDCouplingCompletionScript : error when trying to activate completion ! readline not present ?\nScript is :\n" << script;
@@ -157,3 +212,12 @@ namespace ParaMEDMEM
     return std::string(script);
   }
 }
+
+%pythoncode %{
+def INTERPKERNELExceptionReduceFunct(a,b):
+    ret=InterpKernelException.__new__(a)
+    ret.__init__(*b)
+    return ret
+def INTERPKERNELExceptionReduce(self):
+    return INTERPKERNELExceptionReduceFunct,(InterpKernelException,(self.what(),))
+%}