Module EDSlot
[hide private]
[frames] | no frames]

Source Code for Module EDSlot

 1  # 
 2  #    Project: The EDNA Kernel 
 3  #             http://www.edna-site.org 
 4  # 
 5  #    File: "$Id$" 
 6  # 
 7  #    Copyright (C) 2008-2009 European Synchrotron Radiation Facility 
 8  #                            Grenoble, France 
 9  # 
10  #    Principal authors: Olof Svensson (svensson@esrf.fr)  
11  # 
12  #    This program is free software: you can redistribute it and/or modify 
13  #    it under the terms of the GNU Lesser General Public License as published 
14  #    by the Free Software Foundation, either version 3 of the License, or 
15  #    (at your option) any later version. 
16  # 
17  #    This program is distributed in the hope that it will be useful, 
18  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
19  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
20  #    GNU Lesser General Public License for more details. 
21  # 
22  #    You should have received a copy of the GNU General Public License 
23  #    and the GNU Lesser General Public License  along with this program.   
24  #    If not, see <http://www.gnu.org/licenses/>. 
25  # 
26   
27  # 
28  # This class has been inspired by the corresponding AALib class  
29  # (20090518-PyAALib-JyAALib-111) and modified according to the needs  
30  # for the EDNA project. 
31  # 
32   
33  """ 
34  This class is used for connecting one instance of a class to another. 
35  """ 
36   
37   
38  __author__ = "Olof Svensson" 
39  __contact__ = "svensson@esrf.fr" 
40  __license__ = "LGPLv3+" 
41  __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" 
42   
43   
44  from EDObject import EDObject 
45  from EDVerbose import EDVerbose 
46   
47 -class EDSlot(EDObject):
48 """ 49 This class is used for connecting one instance of a class to another. 50 """ 51
52 - def __init__(self):
53 """ 54 """ 55 EDObject.__init__(self) 56 self.__listMethod = []
57 58
59 - def connect(self, _pyClassMethod):
60 """ 61 Connects a signal between an object and a method in an other object. 62 """ 63 if (_pyClassMethod == None): 64 EDVerbose.error("EDSlot.connect: None class method") 65 return 66 self.synchronizeOn() # Block the thread 67 self.__listMethod.append(_pyClassMethod) 68 self.synchronizeOff() # Release the thread
69 70
71 - def call(self, _tupleArguments=None):
72 """ 73 Calls a slot with a list of arguments. 74 @param _tupleArguments: arguments to be passed to the slot method 75 @type _tupleArguments: tuple 76 """ 77 self.synchronizeOn() # Block the thread 78 for pyMethod in self.__listMethod: 79 if (pyMethod is not None): 80 self.executeMethod(pyMethod, _tupleArguments) 81 self.synchronizeOff() # Release the thread
82 83
84 - def executeMethod(self, _pyMethod, _tupleArguments=None):
85 if (_tupleArguments is None): 86 _pyMethod() 87 else: 88 _pyMethod(_tupleArguments)
89 90
91 - def getListMethod(self):
92 return self.__listMethod
93 94
95 - def emptyListMethod(self):
96 self.__listMethod = []
97