Mercurial > code > home > repos > light9
diff attic/NodeType.py @ 299:6931479b657a
Make attic, move a bunch of old files to it
author | David McClosky <dmcc@bigasterisk.com> |
---|---|
date | Mon, 20 Jun 2005 18:52:21 +0000 |
parents | NodeType.py@45b12307c695 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/attic/NodeType.py Mon Jun 20 18:52:21 2005 +0000 @@ -0,0 +1,46 @@ +"""each node descends from this base class""" + +class NodeType: + def __init__(self): + """TBD""" + self.ops = Ops() + + ''' maybe + self.iports = [] + self.oports = [] + self.params = [] + ''' + def get_state(self, stateaccess): + """This is similar to the pickle.__getstate__ method, except + we need this alternate version in order to give the node + (which holds no state) access to its instance's state. + + If your node keeps some transient items in its state dict + (such as a buffer of recently received inputs), it may want to + return a copy of the state dict without those items. set_state + should restore them properly (if they're missing from the + current state, which they might not be). + + get_state might be called at any time, and it's certainly not + guaranteed that the node instance is going out of service. + get_state might get called to checkpoint the nodes for a + backup, for example. set_state might also get called anytime. + """ + return stateaccess + def set_state(self, stateaccess, dict): + """dict (named after the pickle.__setstate__ argument) is + always a value that was previously returned from + get_state. Don't adjust the current nodetype's state, of course; + use dict to update stateaccess. If there were elements + missing from dict (see the note in get_state for why this + might be the case), you should restore them here as + appropriate. + """ + stateaccess.update(dict) + def get_default_params(self): + '''Returns dictionary of param names and DataType instances. DataTypes + can be given values''' + return {} + def get_default_ports(self): + '''Returns pinless port objects''' + return {}