Portable module

DDS discovery datacentric memory execution serialization platform protocol transport portable system toolchain

Safe DDS’ portable module provides a unique point of access to the complete set of Safe DDS’ depencies. Following this approach, the dependency of Safe DDS on the C++ standard library is both limited and encapsulated. To facilitate customization, it is possible to override the contents of the include/portable folder, allowing for modifications or replacements of any headers found within this directory. This strategy enables the utilization of a custom C++ standard library, or even a tailored implementation to suit specific requirements.

The list of dependencies that can be overwritten or customized in Safe DDS are:

  • portable/Array.hpp

    An array container with the same interface as std::array. By default it is implemented using std::array.

  • portable/BitConstants.hpp

    A set of constants regarding bit operations such as portable::BITS_IN_LONG or portable::BITS_IN_BYTE. By default it is implemented assuming a 32-bit architecture.

  • portable/CLZ.hpp

    An implementation of the a counting leading zeros function. By default it is implemented using __builtin_clz.

  • portable/Endianess.hpp

    Definition of portable::MACHINE_ENDIANESS. By default it is implemented using the __BYTE_ORDER__ compiler definition.

  • portable/IsPOD.hpp

    A type trait to check if a type is a POD type. By default it is implemented using std::is_pod.

  • portable/MD5.hpp

    An implementation of the MD5 hash algorithm. By default it is implemented as defined in portable::MD5. It can be overwritten using the same API with platform specific implementations.

  • portable/New.hpp

    A new function to construct objects using new (buffer) operator. By default it is implemented using new.

  • portable/StdDef.hpp

    Definition of size_t. By default it is implemented using <cstddef>.

  • portable/StdInt.hpp

    Definition of int[N]_t and uint[N]_t types. It also defines INT[N]_MIN, INT[N]_MAX, UINT[N]_MAX and SIZE_MAX. By default it is implemented using <cstdint>.

  • portable/String.hpp

    Definition of C standard library functions: memcmp, memcpy, memset and memmove. By default it is implemented using <cstring>.

Override portable module

Overriding the contents of the include/portable folder is done by providing a custom include directory. To illustrate this process, consider the example of overriding the usage of std::array. This can be accomplished by rewriting the file include/portable/Array.hpp as include_overrides/safedds/portable/Array.hpp and subsequently incorporating it into the toolchain as follows:

# Add the custom include folder to override library headers
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include_overrides)