def __init__(self, parameters = None): """ This is the constructor. The parameter "parameters" specifies the parameter for the sprcific module. These can be used to setup the module correctly. This class contains a CConnectionDatabase instance as the _d_conenctions attribute. Please use it to manage your conenctions! Else if you don't want to use it or if you can't please override the is_busy() method also! This method returns True if there are connections to the specific module. """ CObject.__init__(self) if None == parameters: parameters = {} self._d_module_lock = threading.Lock() self._d_module_parameters = parameters self._d_connections = CConnectionDatabase() self._d_logger = logging.getLogger("PPLT.core")
def __init__(self, parent, child = None): """ This method gets two parameters the parameter parent have to be a instance derived from CModule class and specifies the parent of the connection (the underlaying module). The optional parameter child specifies the child of the connection. This should be an instance of a class implementing the IDisposable interface. This parameter specifies the child of the connection (the module/symbol/what_ever) laying above the parent). A connection instance should allway be created in the connect() method of a module. @param parent: This is the parent (destination) of the connection. @type parent: Any instance of a class that inherit from CModule. @param child: This may be an instance that will be notified by the connection about new data. @type child: Any instance iherit from IDisposable.""" CObject.__init__(self) if not isinstance(parent, CModule): raise CorruptInterface("Parentmodule have to inherence CModule!") self._d_parent_module = parent self._d_autolock = False self._d_events_enabled = True self._d_event_status = True if child != None: self._d_child_module = weakref.proxy(child) else: self._d_child_module = None self._d_logger = logging.getLogger("PPLT.core") if(None == child): self._d_events_enabled = False elif not isinstance(child, IDisposable): raise CorruptInterface("Child have to inherence IDisposable!")
def __del__(self): if self.is_busy(): self._d_logger.warning("Destruction of module %s but is_busy() == True"%_fmtid(self.identifier())) CObject.__del__(self)
def __del__(self): if isinstance(self._d_parent_module, CModule): self._d_parent_module.disconnect(self.identifier()) CObject.__del__(self)