import { XMLElem, type IToXML } from "@/util/XmlElem"; import { type UABaseNodeOptions } from "./UABaseNode"; import type { NamespaceTable } from "./NameSpaceTable"; import type { IAddressSpace } from "./IAddressSpace"; import { UAType } from "./UAType"; import { Definition } from "./Definition"; export class UADataType extends UAType implements IToXML { public definition?:Definition; constructor(options: UATypeOptions) { super(options); Object.assign(this, options); this.nodeClass="UADataType"; this.definition=options.definition; } toXML(lnst:NamespaceTable, gnst:NamespaceTable): XMLElem { const elem=super.toXML(lnst, gnst); elem.name=this.nodeClass; elem.attr("Purpose", this.purpose); elem.attr('IsAbstract', this.isAbstract); elem.elem("Definition", this.definition?.toXML(lnst,gnst)); return elem; } static fromXML(xmlObject: any, addressSpace: IAddressSpace): UADataType{ const bn=super.fromXML(xmlObject, addressSpace) as UADataType; if(xmlObject['Definition']) bn.definition = Definition.fromXML(xmlObject['Definition'], addressSpace); return new UADataType(bn as UATypeOptions); } } export interface UATypeOptions extends UABaseNodeOptions{ definition?:Definition; }