Home
Categories
Dictionary
Glossary
Download
Project Details
Changes Log
What Links Here
FAQ
License

Extending a type



It is possible to extend a StructType or StructType by adding new datas to the existing definition of Service. It can be useful if you want to define several types whith small variations on their fields or members.

Note that:
  • As for all Types, it is not mandatory to use the type
  • You can specify that the type upon which you extend should never be used by specifying that it is abstract
  • It is possible to define a chain of extends
The extension of a type must be a type of the same type (for example you can extend a StructType in a StructType or a StructType in a UnionType.

Declaration

You can declare that a type extends another one by adding the <extends name="<type to extend name>" /> under the type declaration. After this declaration you can declare any number of new fields or members you want (or none at all).

For example:
      <types>
         <simpleType name="int" baseType="int" />
         <simpleType name="float" baseType="float" />
         <structType name="abstractPosition" isAbstract="true">
            <field name="latitude" type="float" />
            <field name="lontitude" type="float" />
         </structType>
         <structType name="Position2Element" >
            <extends name="abstractPosition" />
            <field name="elementID" type="int" />
         </structType>
      </types>

It is possible to specify that the type you extend is abstratc by using the isAbstract attributee. See Abstract types for more information.

Declaration order

Note that you don't need to declare the type which is extended before the type which extend it in the types configuration. For example, this declaration is valid:
      <types>
         <simpleType name="int" baseType="int" />
         <simpleType name="float" baseType="float" />
         <structType name="Position2Element" >
            <extends name="abstractPosition" />
            <field name="elementID" type="int" />
         </structType>
         <structType name="abstractPosition" isAbstract="true">
            <field name="latitude" type="float" />
            <field name="lontitude" type="float" />
         </structType>
      </types>

See also


Categories: concepts

Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence