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

Extending a service



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

Note that:
  • There are no links to the service and its extension, extending a service is just a way to define a new service without having to define another time all the datas
  • As for all Services, it is not mandatory to use the service
  • You can specify that the service 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 Service must be a service of the same type.

Declaration

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

For example:
      <publish name="2DPosition" >
         <data name="latitude" type="float" />
         <data name="longitude" type="float" />
      </publish>
      <publish name="3DPosition" >
         <extends name="2DPosition" />
         <data name="altitude" type="float" />
      </publish>
Note that you don't need to declare the service which is extended before the service which extend it in the services configuration. For example, this declaration is valid:
      <publish name="3DPosition" >
         <extends name="2DPosition" />
         <data name="altitude" type="float" />
      </publish>
      <publish name="2DPosition" >
         <data name="latitude" type="float" />
         <data name="longitude" type="float" />
      </publish>

You can use this to make another service which has exactly the samer definition as another, if you don't add any other data. For example:
      <publish name="2DPosition" >
         <data name="latitude" type="float" />
         <data name="longitude" type="float" />
      </publish>
      <publish name="3DPosition" >
         <extends name="2DPosition" />
         <data name="altitude" type="float" />
      </publish>


Examples

Extending a Publish service

Here, we want to extend a publish Service which publish a 2D position to publish a 3D position:
      <publish name="position" >
         <data name="latitude" type="float" />
         <data name="longitude" type="float" />
      </publish>
      <publish name="position2" >
         <extends name="position" />
      </publish>
Here the definition is equivalent to:
      <publish name="2DPosition" >
         <data name="latitude" type="float" />
         <data name="longitude" type="float" />
      </publish>
      <publish name="3DPosition" >
         <data name="latitude" type="float" />
         <data name="longitude" type="float" />
         <data name="altitude" type="float" />
      </publish>

Extending a RequestResponse service

Here, we want to extend a Request-response Service which answers to a request to get a Flightplan to add a validity boolean to the response:
      <services>
         <requestResponse name="computeFlightPlan" >
            <request>
               <data name="waypointList" type="arrayOfInt" />
            </request>
            <response>
               <data name="flightPlan" type="arrayOfPosition" />
            </response>
         </requestResponse>
      </services>
      <services>
         <requestResponse name="computeAndValidateFlightPlan" >
            <extends name="computeFlightPlan" />
            <response>
               <data name="valid" type="boolean" />
            </response>
         </requestResponse>
      </services>
Here the definition is equivalent to:
      <services>
         <requestResponse name="computeFlightPlan" >
            <request>
               <data name="waypointList" type="arrayOfInt" />
            </request>
            <response>
               <data name="flightPlan" type="arrayOfPosition" />
            </response>
         </requestResponse>
      </services>
      <services>
         <requestResponse name="computeAndValidateFlightPlan" >
            <request>
               <data name="waypointList" type="arrayOfInt" />
            </request>
            <response>
            <data name="flightPlan" type="arrayOfPosition" />
               <data name="valid" type="boolean" />
            </response>
         </requestResponse>
      </services>

Chaining extends

Here, we define a chain of extends:
  • The 3DPosition service extends the 2DPosition service to publish a 3D position
  • The positionAndTime service extends the 3DPosition service to add a time to the 3D position
      <publish name="2DPosition" >
         <data name="latitude" type="float" />
         <data name="longitude" type="float" />
      </publish>
      <publish name="3DPosition" >
         <extends name="2DPosition" />
         <data name="altitude" type="float" />
      </publish>
      <publish name="positionAndTime" >
         <extends name="3DPosition" />
         <data name="time" type="long" />
      </publish>
Here the definition is equivalent to:
      <publish name="2DPosition" >
         <data name="latitude" type="float" />
         <data name="longitude" type="float" />
      </publish>
      <publish name="3DPosition" >
         <data name="latitude" type="float" />
         <data name="longitude" type="float" />
         <data name="altitude" type="float" />
      </publish>
      <publish name="positionAndTime" >
         <data name="latitude" type="float" />
         <data name="longitude" type="float" />
         <data name="altitude" type="float" />
         <data name="time" type="long" />
      </publish>

See also


Categories: concepts

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