1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # Author : Anthony Geay
22 # dict,list,tuple,int,float,str
27 def __init__(self,varPtr,isTemporaryVar=False):
28 assert(isinstance(varPtr,SALOME._objref_StringDataServer))
30 if not isTemporaryVar:
31 self._var_ptr.Register()
32 self._is_temp=isTemporaryVar
36 self._var_ptr.UnRegister()
40 st=pickle.dumps(elt,pickle.HIGHEST_PROTOCOL)
41 self._var_ptr.setSerializedContent(st)
44 def __getitem__(self,*args):
45 ret=Caller(self._var_ptr,"__getitem__")
48 def __setitem__(self,*args):
49 ret=Caller(self._var_ptr,"__setitem__")
52 def append(self,*args):
53 ret=Caller(self._var_ptr,"append")
57 return self.local_copy().__str__()
60 return self.local_copy().__repr__()
63 return pickle.loads(self._var_ptr.fetchSerializedContent())
66 return (list,(self.local_copy(),))
71 def __init__(self,varPtr,isTemporaryVar=False):
72 assert(isinstance(varPtr,SALOME._objref_StringDataServer))
74 if not isTemporaryVar:
75 self._var_ptr.Register()
76 self._is_temp=isTemporaryVar
80 self._var_ptr.UnRegister()
84 st=pickle.dumps(elt,pickle.HIGHEST_PROTOCOL)
85 self._var_ptr.setSerializedContent(st)
88 def __getitem__(self,*args):
89 ret=Caller(self._var_ptr,"__getitem__")
92 def __setitem__(self,*args):
93 ret=Caller(self._var_ptr,"__setitem__")
97 return self.local_copy().__str__()
100 return self.local_copy().__repr__()
102 def local_copy(self):
103 return pickle.loads(self._var_ptr.fetchSerializedContent())
105 def __reduce__(self):
106 return (tuple,(self.local_copy(),))
112 def __init__(self,varPtr,isTemporaryVar=False):
113 assert(isinstance(varPtr,SALOME._objref_StringDataServer))
115 if not isTemporaryVar:
116 self._var_ptr.Register()
117 self._is_temp=isTemporaryVar
121 self._var_ptr.UnRegister()
124 def __iadd__(self,*args):
125 ret=Caller(self._var_ptr,"__add__")
128 def __isub__(self,*args):
129 ret=Caller(self._var_ptr,"__sub__")
132 def assign(self,elt):
133 st=pickle.dumps(elt,pickle.HIGHEST_PROTOCOL)
134 self._var_ptr.setSerializedContent(st)
138 return self.local_copy().__str__()
141 return self.local_copy().__repr__()
143 def local_copy(self):
144 return pickle.loads(self._var_ptr.fetchSerializedContent())
146 def __reduce__(self):
147 return (int,(self.local_copy(),))
152 def __init__(self,varPtr,isTemporaryVar=False):
153 assert(isinstance(varPtr,SALOME._objref_StringDataServer))
155 if not isTemporaryVar:
156 self._var_ptr.Register()
157 self._is_temp=isTemporaryVar
161 self._var_ptr.UnRegister()
164 def assign(self,elt):
165 st=pickle.dumps(elt,pickle.HIGHEST_PROTOCOL)
166 self._var_ptr.setSerializedContent(st)
169 def __getitem__(self,*args):
170 ret=Caller(self._var_ptr,"__getitem__")
173 def __setitem__(self,*args):
174 ret=Caller(self._var_ptr,"__setitem__")
178 return len(self.local_copy())
181 return self.local_copy().__str__()
184 return self.local_copy().__repr__()
186 def local_copy(self):
187 return pickle.loads(self._var_ptr.fetchSerializedContent())
189 def __reduce__(self):
190 return (dict,(self.local_copy(),))
195 def __init__(self,varPtr,meth):
196 assert(isinstance(varPtr,SALOME._objref_StringDataServer))
201 def __call__(self,*args):
202 ret=self._var_ptr.invokePythonMethodOn(self._meth,pickle.dumps(args,pickle.HIGHEST_PROTOCOL))
203 return GetHandlerFromRef(ret,True)
206 PyHandlerTypeMap={int:Int,list:List,tuple:Tuple,dict:Dict}
208 def GetHandlerFromRef(objCorba,isTempVar=False):
209 v=pickle.loads(objCorba.fetchSerializedContent())
212 return PyHandlerTypeMap[v.__class__](objCorba,isTempVar)