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