1 // Copyright (C) 2007-2016 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());
44 void declareAsNew() const;
45 virtual void updateTime() const;
46 unsigned int getTimeOfThis() const;
54 enum class DeallocType
60 const char *MEDCouplingVersionStr();
61 int MEDCouplingVersion();
62 int MEDCouplingSizeOfVoidStar();
63 int MEDCouplingSizeOfIDs();
64 bool MEDCouplingByteOrder();
65 const char *MEDCouplingByteOrderStr();
66 bool IsCXX11Compiled();
71 std::size_t getHeapMemorySize() const throw(INTERP_KERNEL::Exception);
72 std::string getHeapMemorySizeStr() const throw(INTERP_KERNEL::Exception);
73 bool isObjectInTheProgeny(const BigMemoryObject *obj) const throw(INTERP_KERNEL::Exception);
74 virtual std::size_t getHeapMemorySizeWithoutChildren() const throw(INTERP_KERNEL::Exception);
75 virtual ~BigMemoryObject();
78 virtual PyObject *getDirectChildren() const throw(INTERP_KERNEL::Exception)
80 std::vector<const BigMemoryObject *> c(self->getDirectChildren());
81 PyObject *ret(PyList_New(c.size()));
82 for(std::size_t i=0;i<c.size();i++)
83 PyList_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(c[i]),SWIGTYPE_p_MEDCoupling__BigMemoryObject, 0 | 0 ));
87 PyObject *getAllTheProgeny() const throw(INTERP_KERNEL::Exception)
89 std::vector<const BigMemoryObject *> c(self->getAllTheProgeny());
90 PyObject *ret(PyList_New(c.size()));
91 for(std::size_t i=0;i<c.size();i++)
92 PyList_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(c[i]),SWIGTYPE_p_MEDCoupling__BigMemoryObject, 0 | 0 ));
96 static std::size_t GetHeapMemorySizeOfObjs(PyObject *objs) throw(INTERP_KERNEL::Exception)
98 std::vector<const BigMemoryObject *> cppObjs;
99 convertFromPyObjVectorOfObj<const MEDCoupling::BigMemoryObject *>(objs,SWIGTYPE_p_MEDCoupling__BigMemoryObject,"BigMemoryObject",cppObjs);
100 return BigMemoryObject::GetHeapMemorySizeOfObjs(cppObjs);
105 class RefCountObjectOnly
108 bool decrRef() const;
109 void incrRef() const;
110 int getRCValue() const;
112 ~RefCountObjectOnly();
115 class RefCountObject : public RefCountObjectOnly, public BigMemoryObject
124 static GlobalDict *GetInstance() throw(INTERP_KERNEL::Exception);
125 bool hasKey(const std::string& key) const throw(INTERP_KERNEL::Exception);
126 std::string value(const std::string& key) const throw(INTERP_KERNEL::Exception);
127 std::vector<std::string> keys() const throw(INTERP_KERNEL::Exception);
128 void erase(const std::string& key) throw(INTERP_KERNEL::Exception);
129 void clear() throw(INTERP_KERNEL::Exception);
130 void setKeyValue(const std::string& key, const std::string& value) throw(INTERP_KERNEL::Exception);
131 void setKeyValueForce(const std::string& key, const std::string& value) throw(INTERP_KERNEL::Exception);
137 std::string __str__() const
139 return self->printSelf();
147 PyObject *MEDCouplingVersionMajMinRel()
149 int tmp0=0,tmp1=0,tmp2=0;
150 MEDCouplingVersionMajMinRel(tmp0,tmp1,tmp2);
151 PyObject *res = PyList_New(3);
152 PyList_SetItem(res,0,SWIG_From_int(tmp0));
153 PyList_SetItem(res,1,SWIG_From_int(tmp1));
154 PyList_SetItem(res,2,SWIG_From_int(tmp2));
158 bool MEDCouplingHasNumPyBindings()
167 bool MEDCouplingHasSciPyBindings()
176 std::string MEDCouplingCompletionScript() throw(INTERP_KERNEL::Exception)
178 static const char script[]="import rlcompleter,readline\nreadline.parse_and_bind('tab:complete')";
179 std::ostringstream oss; oss << "MEDCouplingCompletionScript : error when trying to activate completion ! readline not present ?\nScript is :\n" << script;
180 if(PyRun_SimpleString(script)!=0)
181 throw INTERP_KERNEL::Exception(oss.str().c_str());
182 return std::string(script);
187 def INTERPKERNELExceptionReduceFunct(a,b):
188 ret=InterpKernelException.__new__(a)
191 def INTERPKERNELExceptionReduce(self):
192 return INTERPKERNELExceptionReduceFunct,(InterpKernelException,(self.what(),))