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 an interface, an IDL file is required. The sdv_idl_compiler.exe takes this file and 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!
Interface ISayHello#
To get help about the sdv_idl_compiler.exe command line commands type sdv_idl_compiler.exe --help.
See the OMG specification page for the IDL description.
The OMG specification for IDL can also be found here: https://www.omg.org/spec/IDL
Following data types are not supported by the sdv_idl_compiler.exe yet:
any data type
map data type
fixed-point data type
An example of how the IDL is compiled in the CMake build script can be seen here: /sdv_services/CMakeLists.txt