Changing license to MIT.
[PyCIM.git] / CDPSM / Balanced / IEC61970 / Core / Name.py
blobb5d1dc6b0ae7337f47f5bc940a6917d605efaf99
1 # Copyright (C) 2010-2011 Richard Lincoln
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to
5 # deal in the Software without restriction, including without limitation the
6 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 # sell copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19 # IN THE SOFTWARE.
21 from CDPSM.Balanced.Element import Element
23 class Name(Element):
24 """The Name class provides the means to define any number of human readable names for an object. A name is <b>not</b> to be used for defining inter-object relationships. For inter-object relationships instead use the object identification 'mRID'.
25 """
27 def __init__(self, name='', IdentifiedObject=None, NameType=None, *args, **kw_args):
28 """Initialises a new 'Name' instance.
30 @param name: Any free text that name the object.
31 @param IdentifiedObject: Identified object that this name designates.
32 @param NameType: Type of this name.
33 """
34 #: Any free text that name the object.
35 self.name = name
37 self._IdentifiedObject = None
38 self.IdentifiedObject = IdentifiedObject
40 self._NameType = None
41 self.NameType = NameType
43 super(Name, self).__init__(*args, **kw_args)
45 _attrs = ["name"]
46 _attr_types = {"name": str}
47 _defaults = {"name": ''}
48 _enums = {}
49 _refs = ["IdentifiedObject", "NameType"]
50 _many_refs = []
52 def getIdentifiedObject(self):
53 """Identified object that this name designates.
54 """
55 return self._IdentifiedObject
57 def setIdentifiedObject(self, value):
58 if self._IdentifiedObject is not None:
59 filtered = [x for x in self.IdentifiedObject.Names if x != self]
60 self._IdentifiedObject._Names = filtered
62 self._IdentifiedObject = value
63 if self._IdentifiedObject is not None:
64 if self not in self._IdentifiedObject._Names:
65 self._IdentifiedObject._Names.append(self)
67 IdentifiedObject = property(getIdentifiedObject, setIdentifiedObject)
69 def getNameType(self):
70 """Type of this name.
71 """
72 return self._NameType
74 def setNameType(self, value):
75 if self._NameType is not None:
76 filtered = [x for x in self.NameType.Names if x != self]
77 self._NameType._Names = filtered
79 self._NameType = value
80 if self._NameType is not None:
81 if self not in self._NameType._Names:
82 self._NameType._Names.append(self)
84 NameType = property(getNameType, setNameType)