]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Imp
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 19 Nov 2014 13:39:00 +0000 (14:39 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 19 Nov 2014 13:39:00 +0000 (14:39 +0100)
src/SALOMESDS/CMakeLists.txt
src/SALOMESDS/SalomeSDSClt.py

index 3b0edeca3fe34f4d21411c03e8947409d1fa107a..421c27f60849c9baf82a8d780b0b0a012a855a58 100644 (file)
@@ -50,6 +50,7 @@ INSTALL(TARGETS SalomeSDS EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME
 ADD_EXECUTABLE(SALOME_DataScopeServer SALOME_DataScopeServer.cxx)
 TARGET_LINK_LIBRARIES(SALOME_DataScopeServer SalomeSDS)
 INSTALL(TARGETS SALOME_DataScopeServer DESTINATION ${SALOME_INSTALL_BINS})
+INSTALL(FILES SalomeSDSClt.py DESTINATION ${SALOME_INSTALL_BINS})
 
 FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
 INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
index 333bb29255584c6dd09f16fac9238dc9e4736126..5a12f11b9f799b2a3dfb32faf250d52436ec257f 100644 (file)
 #
 # Author : Anthony Geay
 
-# dict,list,tuple,int,float,str
 import SALOME
 import cPickle
 
-class List(object):
+class WrappedType(object):
     def __init__(self,varPtr,isTemporaryVar=False):
         assert(isinstance(varPtr,SALOME._objref_StringDataServer))
         self._var_ptr=varPtr
@@ -32,15 +31,34 @@ class List(object):
         self._is_temp=isTemporaryVar
         pass
 
-    def __del__(self):
-        self._var_ptr.UnRegister()
-        pass
+    def local_copy(self):
+        return cPickle.loads(self._var_ptr.fetchSerializedContent())
+
+    def __str__(self):
+        return self.local_copy().__str__()
+
+    def __repr__(self):
+        return self.local_copy().__repr__()
+
+    def __reduce__(self):
+        return (self._wrapped_type,(self.local_copy(),))
 
     def assign(self,elt):
         st=cPickle.dumps(elt,cPickle.HIGHEST_PROTOCOL)
         self._var_ptr.setSerializedContent(st)
         pass
 
+    def __del__(self):
+        self._var_ptr.UnRegister()
+        pass
+    pass
+
+class List(WrappedType):
+    def __init__(self,varPtr,isTemporaryVar=False):
+        WrappedType.__init__(self,varPtr,isTemporaryVar)
+        self._wrapped_type=list
+        pass
+
     def __getitem__(self,*args):
         ret=Caller(self._var_ptr,"__getitem__")
         return ret(*args)
@@ -51,33 +69,16 @@ class List(object):
 
     def append(self,*args):
         ret=Caller(self._var_ptr,"append")
-        return ret(*args)
-
-    def __str__(self):
-        return self.local_copy().__str__()
-
-    def __repr__(self):
-        return self.local_copy().__repr__()
-
-    def local_copy(self):
-        return cPickle.loads(self._var_ptr.fetchSerializedContent())
-
-    def __reduce__(self):
-        return (list,(self.local_copy(),))
+        return ret(*args) 
 
+    def __len__(self):
+        return len(self.local_copy())
     pass
 
-class Tuple(object):
+class Tuple(WrappedType):
     def __init__(self,varPtr,isTemporaryVar=False):
-        assert(isinstance(varPtr,SALOME._objref_StringDataServer))
-        self._var_ptr=varPtr
-        if not isTemporaryVar:
-            self._var_ptr.Register()
-        self._is_temp=isTemporaryVar
-        pass
-
-    def __del__(self):
-        self._var_ptr.UnRegister()
+        WrappedType.__init__(self,varPtr,isTemporaryVar)
+        self._wrapped_type=tuple
         pass
 
     def assign(self,elt):
@@ -92,33 +93,35 @@ class Tuple(object):
     def __setitem__(self,*args):
         ret=Caller(self._var_ptr,"__setitem__")
         return ret(*args)
+    
+    def __len__(self):
+        return len(self.local_copy())
 
-    def __str__(self):
-        return self.local_copy().__str__()
+    pass
 
-    def __repr__(self):
-        return self.local_copy().__repr__()
+class Dict(WrappedType):
+    def __init__(self,varPtr,isTemporaryVar=False):
+        WrappedType.__init__(self,varPtr,isTemporaryVar)
+        self._wrapped_type=dict
+        pass
 
-    def local_copy(self):
-        return cPickle.loads(self._var_ptr.fetchSerializedContent())
+    def __getitem__(self,*args):
+        ret=Caller(self._var_ptr,"__getitem__")
+        return ret(*args)
 
-    def __reduce__(self):
-        return (tuple,(self.local_copy(),))
+    def __setitem__(self,*args):
+        ret=Caller(self._var_ptr,"__setitem__")
+        return ret(*args)
+
+    def __len__(self):
+        return len(self.local_copy())
 
     pass
-        
 
-class Int(object):
+class Float(WrappedType):
     def __init__(self,varPtr,isTemporaryVar=False):
-        assert(isinstance(varPtr,SALOME._objref_StringDataServer))
-        self._var_ptr=varPtr
-        if not isTemporaryVar:
-            self._var_ptr.Register()
-        self._is_temp=isTemporaryVar
-        pass
-
-    def __del__(self):
-        self._var_ptr.UnRegister()
+        WrappedType.__init__(self,varPtr,isTemporaryVar)
+        self._wrapped_type=float
         pass
 
     def __iadd__(self,*args):
@@ -128,67 +131,52 @@ class Int(object):
     def __isub__(self,*args):
         ret=Caller(self._var_ptr,"__sub__")
         return ret(*args)
-
-    def assign(self,elt):
-        st=cPickle.dumps(elt,cPickle.HIGHEST_PROTOCOL)
-        self._var_ptr.setSerializedContent(st)
-        pass
-
-    def __str__(self):
-        return self.local_copy().__str__()
-
-    def __repr__(self):
-        return self.local_copy().__repr__()
-
-    def local_copy(self):
-        return cPickle.loads(self._var_ptr.fetchSerializedContent())
-
-    def __reduce__(self):
-        return (int,(self.local_copy(),))
-
     pass
 
-class Dict(object):
+class Int(WrappedType):
     def __init__(self,varPtr,isTemporaryVar=False):
-        assert(isinstance(varPtr,SALOME._objref_StringDataServer))
-        self._var_ptr=varPtr
-        if not isTemporaryVar:
-            self._var_ptr.Register()
-        self._is_temp=isTemporaryVar
-        pass
-
-    def __del__(self):
-        self._var_ptr.UnRegister()
+        WrappedType.__init__(self,varPtr,isTemporaryVar)
+        self._wrapped_type=int
         pass
 
-    def assign(self,elt):
-        st=cPickle.dumps(elt,cPickle.HIGHEST_PROTOCOL)
-        self._var_ptr.setSerializedContent(st)
-        pass
+    def __iadd__(self,*args):
+        ret=Caller(self._var_ptr,"__add__")
+        return ret(*args)
 
-    def __getitem__(self,*args):
-        ret=Caller(self._var_ptr,"__getitem__")
+    def __isub__(self,*args):
+        ret=Caller(self._var_ptr,"__sub__")
         return ret(*args)
 
-    def __setitem__(self,*args):
-        ret=Caller(self._var_ptr,"__setitem__")
+    def __imul__(self,*args):
+        ret=Caller(self._var_ptr,"__mul__")
         return ret(*args)
 
-    def __len__(self):
-        return len(self.local_copy())
+    def __idiv__(self,*args):
+        ret=Caller(self._var_ptr,"__div__")
+        return ret(*args)
 
-    def __str__(self):
-        return self.local_copy().__str__()
+    def __add__(self,*args):
+        ret=Caller(self._var_ptr,"__add__")
+        return ret(*args)
 
-    def __repr__(self):
-        return self.local_copy().__repr__()
+    def __sub__(self,*args):
+        ret=Caller(self._var_ptr,"__sub__")
+        return ret(*args)
 
-    def local_copy(self):
-        return cPickle.loads(self._var_ptr.fetchSerializedContent())
+    def __mul__(self,*args):
+        ret=Caller(self._var_ptr,"__mul__")
+        return ret(*args)
 
-    def __reduce__(self):
-        return (dict,(self.local_copy(),))
+    def __div__(self,*args):
+        ret=Caller(self._var_ptr,"__div__")
+        return ret(*args)
+    pass
 
+class String(WrappedType):
+    def __init__(self,varPtr,isTemporaryVar=False):
+        WrappedType.__init__(self,varPtr,isTemporaryVar)
+        self._wrapped_type=int
+        pass
     pass
 
 class Caller:
@@ -203,11 +191,12 @@ class Caller:
         return GetHandlerFromRef(ret,True)
     pass
 
-PyHandlerTypeMap={int:Int,list:List,tuple:Tuple,dict:Dict}
+PyHandlerTypeMap={int:Int,float:Float,str:String,list:List,tuple:Tuple,dict:Dict}
 
 def GetHandlerFromRef(objCorba,isTempVar=False):
     """ Returns a client that allows to handle a remote corba ref of a global var easily.
     """
+    assert(isinstance(objCorba,SALOME._objref_StringDataServer))
     v=cPickle.loads(objCorba.fetchSerializedContent())
     if v is None:
         return None