Example Interface#

Note

Interface s are typically located in C++ header files that only contain Interface s and each header file includes only Interface s that are relevant for the same context, since they are needed by both the developer for the implementation of the interface and the developer that uses the interface in other components. See also Interface Set.

To create am Interface an IDL file is required. The ‘sdv_idl_compiler.exe’ takes this file an creates the interface header file.

#include <interfaces/core.idl>

interface ISayHello
{
    void SayHello() const;
};
interface ISayHello                  ///< interface example ISayHello 
{
    virtual void SayHello() = 0;     ///< function og the interface
    static constexpr ::sdv::interface_id _id = 0xA012345678900100; ///< Interface Id
};
interface ISayHello                  ///< interface example ISayHello 
{
    virtual void SayHello() = 0;     ///< function og the interface
    static constexpr ::sdv::interface_id _id = 0xA012345678900100; ///< Interface Id
};

The keyword interface is an alias to the C++ keyword struct.

interface ISayHello                  ///< interface example ISayHello 
{
    virtual void SayHello() = 0;     ///< function og the interface
    static constexpr ::sdv::interface_id _id = 0xA012345678900100; ///< Interface Id
};

Within an Interface any number of pure virtual functions may be declared to represent the functionality of the interface, but nothing else.

interface ISayHello                  ///< interface example ISayHello 
{
    virtual void SayHello() = 0;     ///< function og the interface
    static constexpr ::sdv::interface_id _id = 0xA012345678900100; ///< Interface Id
};

Unique Interface ID created and added by the IDL compiler, do not change!

To get help about the sdv_idl_compiler.exe command line commands type sdv_idl_compiler.exe --help.

../../../_images/sdv_idl_compiler.png

See the OMG specification page for the IDL description.

The OMG specification for the IDL description can be found here: https://www.omg.org/spec/UML/2.5.1/About-UML/#:~:text=A%20specification%20defining%20a%20graphical%20language%20for%20visualizing%2C,and%20documenting%20the%20artifacts%20of%20distributed%20object%20systems/

Following data types are not supported by the ‘sdv_idl_compiler.exe’ yet:

  • any data type

  • map data type

  • fixed-point data type

A example how the IDL is compiled in the cmake build script can be seen here: /sdv_services/CMakeLists.txt