Fixing one-to-many bidirectional references.
[PyCIM.git] / CIM14 / Dynamics / BlockInputReference.py
blob77cab78e10edf67245aa5f9ff20ade000a8e42e0
1 # Copyright (C) 2010 Richard Lincoln
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, USA
17 from CIM14.IEC61970.Core.IdentifiedObject import IdentifiedObject
19 class BlockInputReference(IdentifiedObject):
20 """Used at the meta dynamics level. This is how the internal definiton of a block references the input of another block.
21 """
23 def __init__(self, metaBlockReference0=None, metaBlockInput0=None, BlockConnectable=None, *args, **kw_args):
24 """Initialises a new 'BlockInputReference' instance.
26 @param metaBlockReference0:
27 @param metaBlockInput0: References the idenfiied input for the block reference.
28 @param BlockConnectable: Each block reference input is usually tied to one (sometimes zero for optional inputs) external block inputs or internal block reference outputs.
29 """
30 self._metaBlockReference0 = None
31 self.metaBlockReference0 = metaBlockReference0
33 self._metaBlockInput0 = None
34 self.metaBlockInput0 = metaBlockInput0
36 self._BlockConnectable = None
37 self.BlockConnectable = BlockConnectable
39 super(BlockInputReference, self).__init__(*args, **kw_args)
41 _attrs = []
42 _attr_types = {}
43 _defaults = {}
44 _enums = {}
45 _refs = ["metaBlockReference0", "metaBlockInput0", "BlockConnectable"]
46 _many_refs = []
48 def getmetaBlockReference0(self):
50 return self._metaBlockReference0
52 def setmetaBlockReference0(self, value):
53 if self._metaBlockReference0 is not None:
54 filtered = [x for x in self.metaBlockReference0.blockInputReference0 if x != self]
55 self._metaBlockReference0._blockInputReference0 = filtered
57 self._metaBlockReference0 = value
58 if self._metaBlockReference0 is not None:
59 if self not in self._metaBlockReference0._blockInputReference0:
60 self._metaBlockReference0._blockInputReference0.append(self)
62 metaBlockReference0 = property(getmetaBlockReference0, setmetaBlockReference0)
64 def getmetaBlockInput0(self):
65 """References the idenfiied input for the block reference.
66 """
67 return self._metaBlockInput0
69 def setmetaBlockInput0(self, value):
70 if self._metaBlockInput0 is not None:
71 filtered = [x for x in self.metaBlockInput0.blockInputReference0 if x != self]
72 self._metaBlockInput0._blockInputReference0 = filtered
74 self._metaBlockInput0 = value
75 if self._metaBlockInput0 is not None:
76 if self not in self._metaBlockInput0._blockInputReference0:
77 self._metaBlockInput0._blockInputReference0.append(self)
79 metaBlockInput0 = property(getmetaBlockInput0, setmetaBlockInput0)
81 def getBlockConnectable(self):
82 """Each block reference input is usually tied to one (sometimes zero for optional inputs) external block inputs or internal block reference outputs.
83 """
84 return self._BlockConnectable
86 def setBlockConnectable(self, value):
87 if self._BlockConnectable is not None:
88 filtered = [x for x in self.BlockConnectable.BlockInputReference if x != self]
89 self._BlockConnectable._BlockInputReference = filtered
91 self._BlockConnectable = value
92 if self._BlockConnectable is not None:
93 if self not in self._BlockConnectable._BlockInputReference:
94 self._BlockConnectable._BlockInputReference.append(self)
96 BlockConnectable = property(getBlockConnectable, setBlockConnectable)