Changing license to MIT.
[PyCIM.git] / CDPSM / Connectivity / IEC61970 / Core / IdentifiedObject.py
blob680bec0bb3d586f439a8216cea5a8e4ebc9d05c3
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.Connectivity.Element import Element
23 class IdentifiedObject(Element):
24 """This is a root class to provide common identification for all classes needing identification and naming attributes
25 """
27 def __init__(self, name='', aliasName='', Names=None, *args, **kw_args):
28 """Initialises a new 'IdentifiedObject' instance.
30 @param name: The name is any free human readable and possibly non unique text naming the object.
31 @param aliasName: The aliasName is free text human readable name of the object alternative to IdentifiedObject.name. It may be non unique and may not correlate to a naming hierarchy. The attribute aliasName is put back because of backwards compatibility between CIM relases. It is however recommended to replace aliasName with the Name class as aliasName is planned for retirement at a future time. This was decided at a joint WG13/14 meeting in Minneapolis 2010-10-06.
32 @param Names: All names of this identified object.
33 """
34 #: The name is any free human readable and possibly non unique text naming the object.
35 self.name = name
37 #: The aliasName is free text human readable name of the object alternative to IdentifiedObject.name. It may be non unique and may not correlate to a naming hierarchy. The attribute aliasName is put back because of backwards compatibility between CIM relases. It is however recommended to replace aliasName with the Name class as aliasName is planned for retirement at a future time. This was decided at a joint WG13/14 meeting in Minneapolis 2010-10-06.
38 self.aliasName = aliasName
40 self._Names = []
41 self.Names = [] if Names is None else Names
43 super(IdentifiedObject, self).__init__(*args, **kw_args)
45 _attrs = ["name", "aliasName"]
46 _attr_types = {"name": str, "aliasName": str}
47 _defaults = {"name": '', "aliasName": ''}
48 _enums = {}
49 _refs = ["Names"]
50 _many_refs = ["Names"]
52 def getNames(self):
53 """All names of this identified object.
54 """
55 return self._Names
57 def setNames(self, value):
58 for x in self._Names:
59 x.IdentifiedObject = None
60 for y in value:
61 y._IdentifiedObject = self
62 self._Names = value
64 Names = property(getNames, setNames)
66 def addNames(self, *Names):
67 for obj in Names:
68 obj.IdentifiedObject = self
70 def removeNames(self, *Names):
71 for obj in Names:
72 obj.IdentifiedObject = None