1 // Copyright (C) 2007-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 namespace INTERP_KERNEL
26 Exception(const char* what);
27 ~Exception() throw ();
28 const char *what() const throw ();
31 std::string __str__() const
33 return std::string(self->what());
40 * ABN: Install default exception handler: this catches all INTERP_KERNEL::Exception (even when no
41 * except declaration was added to the function declaration) and propagates it to the Python level.
47 catch (INTERP_KERNEL::Exception& _e) {
48 // Reraise with SWIG_Python_Raise
49 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);
59 void declareAsNew() const;
60 virtual void updateTime() const;
61 unsigned int getTimeOfThis() const;
69 enum class DeallocType
75 const char *MEDCouplingVersionStr();
76 int MEDCouplingVersion();
77 int MEDCouplingSizeOfVoidStar();
78 int MEDCouplingSizeOfIDs();
79 bool MEDCouplingByteOrder();
80 const char *MEDCouplingByteOrderStr();
81 bool IsCXX11Compiled();
86 std::size_t getHeapMemorySize() const;
87 std::string getHeapMemorySizeStr() const;
88 bool isObjectInTheProgeny(const BigMemoryObject *obj) const;
89 virtual std::size_t getHeapMemorySizeWithoutChildren() const;
90 virtual ~BigMemoryObject();
93 virtual PyObject *getDirectChildren() const
95 std::vector<const BigMemoryObject *> c(self->getDirectChildren());
96 PyObject *ret(PyList_New(c.size()));
97 for(std::size_t i=0;i<c.size();i++)
98 PyList_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(c[i]),SWIGTYPE_p_MEDCoupling__BigMemoryObject, 0 | 0 ));
102 PyObject *getAllTheProgeny() const
104 std::vector<const BigMemoryObject *> c(self->getAllTheProgeny());
105 PyObject *ret(PyList_New(c.size()));
106 for(std::size_t i=0;i<c.size();i++)
107 PyList_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(c[i]),SWIGTYPE_p_MEDCoupling__BigMemoryObject, 0 | 0 ));
111 static std::size_t GetHeapMemorySizeOfObjs(PyObject *objs)
113 std::vector<const BigMemoryObject *> cppObjs;
114 convertFromPyObjVectorOfObj<const MEDCoupling::BigMemoryObject *>(objs,SWIGTYPE_p_MEDCoupling__BigMemoryObject,"BigMemoryObject",cppObjs);
115 return BigMemoryObject::GetHeapMemorySizeOfObjs(cppObjs);
120 class RefCountObjectOnly
123 bool decrRef() const;
124 void incrRef() const;
125 int getRCValue() const;
127 ~RefCountObjectOnly();
130 class RefCountObject : public RefCountObjectOnly, public BigMemoryObject
139 static GlobalDict *GetInstance();
140 bool hasKey(const std::string& key) const;
141 std::string value(const std::string& key) const;
142 std::vector<std::string> keys() const;
143 void erase(const std::string& key);
145 void setKeyValue(const std::string& key, const std::string& value);
146 void setKeyValueForce(const std::string& key, const std::string& value);
152 std::string __str__() const
154 return self->printSelf();
162 PyObject *MEDCouplingVersionMajMinRel()
164 int tmp0=0,tmp1=0,tmp2=0;
165 MEDCouplingVersionMajMinRel(tmp0,tmp1,tmp2);
166 PyObject *res = PyList_New(3);
167 PyList_SetItem(res,0,SWIG_From_int(tmp0));
168 PyList_SetItem(res,1,SWIG_From_int(tmp1));
169 PyList_SetItem(res,2,SWIG_From_int(tmp2));
173 bool MEDCouplingHasNumPyBindings()
182 bool MEDCouplingHasSciPyBindings()
191 bool MEDCouplingUse64BitIDs()
193 #ifndef MEDCOUPLING_USE_64BIT_IDS
200 std::string MEDCouplingCompletionScript()
202 static const char script[]="import rlcompleter,readline\nreadline.parse_and_bind('tab:complete')";
203 std::ostringstream oss; oss << "MEDCouplingCompletionScript : error when trying to activate completion ! readline not present ?\nScript is :\n" << script;
204 if(PyRun_SimpleString(script)!=0)
205 throw INTERP_KERNEL::Exception(oss.str().c_str());
206 return std::string(script);
211 def INTERPKERNELExceptionReduceFunct(a,b):
212 ret=InterpKernelException.__new__(a)
215 def INTERPKERNELExceptionReduce(self):
216 return INTERPKERNELExceptionReduceFunct,(InterpKernelException,(self.what(),))