annotate NodeType.py @ 99:7910445b81e3

possible fix
author dmcc
date Sat, 13 Jul 2002 04:36:49 +0000
parents 45b12307c695
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
1 """each node descends from this base class"""
45b12307c695 Initial revision
drewp
parents:
diff changeset
2
45b12307c695 Initial revision
drewp
parents:
diff changeset
3 class NodeType:
45b12307c695 Initial revision
drewp
parents:
diff changeset
4 def __init__(self):
45b12307c695 Initial revision
drewp
parents:
diff changeset
5 """TBD"""
45b12307c695 Initial revision
drewp
parents:
diff changeset
6 self.ops = Ops()
45b12307c695 Initial revision
drewp
parents:
diff changeset
7
45b12307c695 Initial revision
drewp
parents:
diff changeset
8 ''' maybe
45b12307c695 Initial revision
drewp
parents:
diff changeset
9 self.iports = []
45b12307c695 Initial revision
drewp
parents:
diff changeset
10 self.oports = []
45b12307c695 Initial revision
drewp
parents:
diff changeset
11 self.params = []
45b12307c695 Initial revision
drewp
parents:
diff changeset
12 '''
45b12307c695 Initial revision
drewp
parents:
diff changeset
13 def get_state(self, stateaccess):
45b12307c695 Initial revision
drewp
parents:
diff changeset
14 """This is similar to the pickle.__getstate__ method, except
45b12307c695 Initial revision
drewp
parents:
diff changeset
15 we need this alternate version in order to give the node
45b12307c695 Initial revision
drewp
parents:
diff changeset
16 (which holds no state) access to its instance's state.
45b12307c695 Initial revision
drewp
parents:
diff changeset
17
45b12307c695 Initial revision
drewp
parents:
diff changeset
18 If your node keeps some transient items in its state dict
45b12307c695 Initial revision
drewp
parents:
diff changeset
19 (such as a buffer of recently received inputs), it may want to
45b12307c695 Initial revision
drewp
parents:
diff changeset
20 return a copy of the state dict without those items. set_state
45b12307c695 Initial revision
drewp
parents:
diff changeset
21 should restore them properly (if they're missing from the
45b12307c695 Initial revision
drewp
parents:
diff changeset
22 current state, which they might not be).
45b12307c695 Initial revision
drewp
parents:
diff changeset
23
45b12307c695 Initial revision
drewp
parents:
diff changeset
24 get_state might be called at any time, and it's certainly not
45b12307c695 Initial revision
drewp
parents:
diff changeset
25 guaranteed that the node instance is going out of service.
45b12307c695 Initial revision
drewp
parents:
diff changeset
26 get_state might get called to checkpoint the nodes for a
45b12307c695 Initial revision
drewp
parents:
diff changeset
27 backup, for example. set_state might also get called anytime.
45b12307c695 Initial revision
drewp
parents:
diff changeset
28 """
45b12307c695 Initial revision
drewp
parents:
diff changeset
29 return stateaccess
45b12307c695 Initial revision
drewp
parents:
diff changeset
30 def set_state(self, stateaccess, dict):
45b12307c695 Initial revision
drewp
parents:
diff changeset
31 """dict (named after the pickle.__setstate__ argument) is
45b12307c695 Initial revision
drewp
parents:
diff changeset
32 always a value that was previously returned from
45b12307c695 Initial revision
drewp
parents:
diff changeset
33 get_state. Don't adjust the current nodetype's state, of course;
45b12307c695 Initial revision
drewp
parents:
diff changeset
34 use dict to update stateaccess. If there were elements
45b12307c695 Initial revision
drewp
parents:
diff changeset
35 missing from dict (see the note in get_state for why this
45b12307c695 Initial revision
drewp
parents:
diff changeset
36 might be the case), you should restore them here as
45b12307c695 Initial revision
drewp
parents:
diff changeset
37 appropriate.
45b12307c695 Initial revision
drewp
parents:
diff changeset
38 """
45b12307c695 Initial revision
drewp
parents:
diff changeset
39 stateaccess.update(dict)
45b12307c695 Initial revision
drewp
parents:
diff changeset
40 def get_default_params(self):
45b12307c695 Initial revision
drewp
parents:
diff changeset
41 '''Returns dictionary of param names and DataType instances. DataTypes
45b12307c695 Initial revision
drewp
parents:
diff changeset
42 can be given values'''
45b12307c695 Initial revision
drewp
parents:
diff changeset
43 return {}
45b12307c695 Initial revision
drewp
parents:
diff changeset
44 def get_default_ports(self):
45b12307c695 Initial revision
drewp
parents:
diff changeset
45 '''Returns pinless port objects'''
45b12307c695 Initial revision
drewp
parents:
diff changeset
46 return {}