IBMW Developer Guide
This guide covers the IBMW build system, code structure, and how to develop modules and extensions.
Table of Contents
- Project Structure
- Build System
- Writing a Module
- Writing an Extension
- Type System
- Transport Development
- RPC Development
- Coroutine Support
- Logging
- Red Lines and Multi-Driver Modules
- Testing
Project Structure
ibmw/
CMakeLists.txt # Top-level build configuration
VERSION # Project version
cmake/ # CMake modules
| GetFastDDS.cmake # FastDDS dependency
| GetAsio.cmake # Asio dependency
| DdsIdlGenCode.cmake # IDL code generation
| ...
src/
base/ # Base utilities
| log_util.h # SimpleLogger, SimpleAsyncLogger
| string_util.h # FormatTree, string helpers
| ...
core/ # Core runtime engine
| engine/ # Engine subsystem implementations
| | engine.h/cc # Central orchestrator (lifecycle, hooks)
| | executor/ # ExecutorBus + 5 executor types
| | extension/ # ExtensionBus (dynlib loading)
| | logger/ # LoggingSubsystem + formatter + 2 drivers
| | module/ # ModuleBus, ConfigSubsystem, ParameterStore, MemoryBus
| | service/ # ServiceDispatcher (RPC routing)
| | transport/ # TransportBus (pub/sub routing)
| main/ # ibmw binary entry point
| | main.cpp # CLI parsing, Engine lifecycle
| extension_api/ # Public API for extension development
api/ # Public API for module development
| c/ # C ABI layer
| cpp/ # C++ SDK
| pkg/ # Package entry point macros
| type_support/ # Type support package ABI
extensions/ # Extension implementations
| transport/ # Transport backends
| | dds_ext/ # FastDDS (transport + RPC)
| | net_ext/ # HTTP/TCP/UDP
| | mqtt_ext/ # MQTT
| | ros2_ext/ # ROS2 **(deprecated)**
| | iceoryx_ext/ # Iceoryx (shared memory)
| | shm_ext/ # Self-developed shared memory (selfdev/shm, no RouDi)
| | zenoh_ext/ # Zenoh
| rpc/
| | grpc_ext/ # gRPC
| observability/ # Log Control, Topic Logger, OpenTelemetry
| management/ # Parameter, Time Manipulator, Service Introspection,
| | # Record/Playback
| utility/ # Echo, Proxy
schema/ # Type definitions
| dds_idl/ # DDS IDL + generated code
| ros2/ # ROS2 msg/srv definitions
| extensions/ # Extension-specific types (dds_ext_proto, ros2_ext_proto **(deprecated)**)
samples/cpp/ # example applications and verification samples
tools/ # CLI tools and code generators
Build System
CMake Architecture
The top-level CMakeLists.txt defines all build options and orchestrates
dependency fetching via modules in cmake/.
Key CMake modules:
| Module | Purpose |
|---|---|
GetAsio.cmake |
Fetch Asio (header-only) |
GetFastDDS.cmake |
Fetch/find FastDDS + FastCDR |
GetYamlCpp.cmake |
Fetch yaml-cpp |
GetTbb.cmake |
Fetch Intel TBB |
GetFmt.cmake |
Fetch fmt library |
GetNlohmannJson.cmake |
Fetch nlohmann/json |
GetBoost.cmake |
Fetch Boost (net/grpc extensions) |
DdsIdlGenCode.cmake |
Generate FastCDR code from DDS IDL files |
GetGTest.cmake |
Fetch Google Test |
Adding a New Dependency
- Create
cmake/GetMyDep.cmake:
include(FetchContent)
FetchContent_Declare(
mydep
GIT_REPOSITORY https://github.com/example/mydep.git
GIT_TAG v1.0.0
)
FetchContent_MakeAvailable(mydep)
- Include it from the relevant
CMakeLists.txt:
include(${CMAKE_SOURCE_DIR}/cmake/GetMyDep.cmake)
Build Configuration
# Debug build
cmake -B build -DCMAKE_BUILD_TYPE=Debug
# Release with all extensions (recommended: use CMake presets)
cmake --preset full
cmake --build build -j$(nproc)
# Or manually:
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DIBMW_BUILD_EXAMPLES=ON \
-DIBMW_BUILD_DDS_EXTENSION=ON \
-DIBMW_BUILD_NET_EXTENSION=ON \
-DIBMW_BUILD_GRPC_EXTENSION=ON \
-DIBMW_BUILD_MQTT_EXTENSION=ON \
-DIBMW_BUILD_ECHO_EXTENSION=ON \
-DIBMW_BUILD_PROXY_EXTENSION=ON \
-DIBMW_BUILD_PARAMETER_EXTENSION=ON \
-DIBMW_BUILD_LOG_CONTROL_EXTENSION=ON \
-DIBMW_BUILD_RECORD_PLAYBACK_EXTENSION=ON \
-DIBMW_BUILD_TIME_MANIPULATOR_EXTENSION=ON \
-DIBMW_BUILD_SERVICE_INTROSPECTION_EXTENSION=ON \
-DIBMW_BUILD_TOPIC_LOGGER_EXTENSION=ON
Clearing Build Cache
If directory structures change, clear the CMake cache before rebuilding:
cd build && rm -rf CMakeCache.txt CMakeFiles
Cross-compilation configure support
IBMW has configure-level cross-compilation support for aarch64 Linux through CMake presets, cmake/IbmwCrossCompile.cmake, and cmake/toolchains/aarch64-linux-gnu.cmake. The current model keeps host code generation separate from target package lookup and requires a target ROS 2 prefix for FastDDS, FastCDR and ROS 2 interface packages.
The direct target package list is intentionally small: fastcdr, fastdds / fastrtps, std_msgs, geometry_msgs, optional sensor_msgs, ament_cmake, rosidl_default_generators, and builtin_interfaces. Transitive packages are intentionally not listed because they should come from those packages' exported CMake metadata. rclcpp cross support is deferred and is not claimed by the current configure path.
Use target-prefix validation, a clean configure, target artifact inspection, and an external install consumer for cross-build changes. Board deployment and runtime remain separate validation steps.
See the Cross-compilation guide and Support Matrix.
Writing a Module
Tip: You can skip writing boilerplate by hand. Run
ibmw-gen my_project.ibmw.yaml -o my_projectto generate module scaffolds, CMake rules, and YAML configs from a single definition file. See the ibmw-gen reference.
Module Lifecycle
Every IBMW module is a C++ class that inherits from ibmw::Module and
implements four public lifecycle methods:
#include <ibmw/cpp/core.h>
#include <ibmw/cpp/module_base.h>
class MyModule : public ibmw::Module {
public:
// Return module metadata
ibmw::ModuleDescriptor Info() const override {
return ibmw::ModuleDescriptor{
.module_name = "MyModule",
.major_version = 1, .minor_version = 0,
.patch_version = 0, .build_version = 0,
.author = "My Team",
.description = "Example module",
};
}
// Called after loading -- register types, get handles
bool Setup(ibmw::Runtime runtime) override {
core_ = runtime;
// Get subsystem handles
auto executor_bus = core_.GetExecutor();
auto transport = core_.GetTransport();
auto logger = core_.GetLogger();
auto params = core_.GetParams();
auto configurator = core_.GetConfigurator();
auto service = core_.GetService();
return true;
}
// Called after all modules loaded -- start work
bool Run() override {
MW_INFO("Module started");
return true;
}
// Called during shutdown -- clean up
void Stop() override {
MW_INFO("Module stopping");
}
private:
ibmw::Runtime core_;
};
Module Packaging (Pkg Mode)
To make a module loadable as a shared library by the ibmw runtime, create
a package entry point:
// pkg_main.cpp
#include "ibmw/pkg/pkg_macro.h"
#include "my_module.h"
static const auto kModuleArray = std::array{
std::make_tuple("MyModule",
[]() -> ibmw::Module* { return new MyModule(); }),
};
IBMW_PKG_MAIN(kModuleArray)
Build as a shared library:
add_library(my_module_pkg SHARED
my_module.cpp
pkg_main.cpp
)
target_link_libraries(my_module_pkg PRIVATE ibmw::api::pkg)
For an installed SDK, discover the exported targets before linking:
find_package(ibmw CONFIG REQUIRED)
target_link_libraries(my_module_pkg PRIVATE ibmw::api::pkg)
ibmw::api::pkg is the public package ABI target. Ordinary module packages
must not include private engine headers or link internal implementation
targets.
Module as Standalone App (App Mode)
// main.cpp
#include <chrono>
#include <csignal>
#include <iostream>
#include <thread>
#include <ibmw/cpp/core.h>
#include <ibmw/engine/engine.h>
#include "my_module.h"
volatile std::sig_atomic_t g_stop = 0;
void SignalHandler(int sig) {
if (sig == SIGINT || sig == SIGTERM) {
g_stop = 1;
return;
}
std::raise(sig);
}
int main(int argc, char** argv) {
if (argc < 2) {
std::cerr << "Usage: " << argv[0] << " <config.yaml>\n";
return 1;
}
ibmw::runtime::core::Engine engine;
std::signal(SIGINT, SignalHandler);
std::signal(SIGTERM, SignalHandler);
MyModule module;
engine.GetModuleBus().RegisterModule(module.NativeHandle());
ibmw::runtime::core::Engine::Options options;
options.cfg_file_path = argv[1];
engine.Initialize(options);
auto running = engine.AsyncStart();
while (!g_stop) {
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
engine.Shutdown();
running.wait();
return 0;
}
The standalone boundary is ibmw::runtime::core::Engine plus
RegisterModule(module.NativeHandle()). This example uses AsyncStart() and a
signal-safe stop flag; Shutdown() is called from normal thread context. Do
not call non-signal-safe runtime code directly from a POSIX signal handler.
Accessing Per-Module Configuration
Modules can read their own YAML config section:
# In the YAML config file
MyModule:
sensor_rate: 100
topic_name: /sensor_data
bool Setup(ibmw::Runtime runtime) override {
core_ = runtime;
auto config_path = core_.GetConfigurator().GetConfigFilePath();
// Parse config_path with yaml-cpp or another YAML library
return true;
}
Transport: Publishing Messages
bool Setup(ibmw::Runtime runtime) override {
core_ = runtime;
publisher_ = core_.GetTransport().GetPublisher("my_topic");
ibmw::transport::RegisterSendType<MyMessageType>(publisher_);
return true;
}
bool Run() override {
auto executor = core_.GetExecutor().GetExecutor("work_pool");
executor.Dispatch([this]() {
MyMessageType msg;
msg.data = "Hello";
ibmw::transport::Send(publisher_, msg);
});
return true;
}
Transport: Subscribing to Messages
bool Setup(ibmw::Runtime runtime) override {
core_ = runtime;
auto subscriber = core_.GetTransport().GetSubscriber("my_topic");
ibmw::transport::OnMessage<MyMessageType>(subscriber,
[](const MyMessageType& msg) {
MW_INFO("Received: {}", msg.data);
});
return true;
}
RPC: Registering a Server
bool Setup(ibmw::Runtime runtime) override {
core_ = runtime;
auto service = core_.GetService();
// Register RPC server function
RegisterMyServiceServerFunc(service); // Generated from IDL
// Set handler
MyServiceSyncAccess access(service, "/my_service/Query");
access.RegisterHandler([](const MyRequest& req, MyResponse& rsp) {
rsp.result = process(req.input);
return ibmw::rpc::Status(); // OK
});
return true;
}
RPC: Making a Client Call
// Synchronous
MyServiceSyncAccess access(service, "/my_service/Query");
MyRequest req; req.input = 42;
MyResponse rsp;
auto ctx = ibmw::rpc::Context(IBMW_RPC_CLIENT_CONTEXT);
ctx.SetTimeoutNs(3'000'000'000); // 3 seconds
auto status = access.Invoke(ctx.GetContextRef(), req, rsp);
if (status.OK()) {
MW_INFO("Result: {}", rsp.result);
}
// Coroutine
co::Task<void> MyCoroutine() {
MyServiceCoAccess access(service, "/my_service/Query", executor);
MyRequest req; req.input = 42;
MyResponse rsp;
auto ctx = ibmw::rpc::Context(IBMW_RPC_CLIENT_CONTEXT);
auto status = co_await access.Invoke(ctx.GetContextRef(), req, rsp);
}
Using the High-Level Context API
The Context API provides a builder-pattern interface that manages resource lifetimes automatically:
#include "cpp/context/context.h"
class MyModule : public ibmw::Module {
ibmw::context::Context ctx_;
ibmw::context::res::Publisher<MyMsg> pub_;
ibmw::context::res::Subscriber<MyMsg> sub_;
bool Setup(ibmw::Runtime runtime) override {
ctx_ = ibmw::context::Context(runtime, "work_pool");
// Create publisher
ctx_.Pub<MyMsg>("my_topic").Use(pub_).Build();
// Create subscriber with callback
ctx_.Sub<MyMsg>("my_topic")
.Use(sub_)
.SetCallback([](const MyMsg& msg) {
// Handle message
})
.Build();
return true;
}
bool Run() override {
MyMsg msg;
msg.data = "Hello";
pub_.Publish(msg);
return true;
}
void Stop() override {
ctx_.Shutdown();
}
};
Writing an Extension
Extensions are shared libraries that implement ibmw::ExtensionBase. They
are loaded at runtime and can register transport drivers, RPC drivers,
log backends, and more. ExtensionBase owns the framework lifecycle hooks;
extension code implements OnInit() and OnShutdown().
Extension Structure
// my_extension.h
#include <ibmw/engine/extension/extension_base.h>
class MyExtension : public ibmw::ExtensionBase {
public:
std::string_view Name() const noexcept override {
return "my_extension";
}
bool OnInit(ibmw::runtime::core::Engine* core_ptr) override {
// Access engine subsystems
// Register transport/RPC drivers
// Read extension options from YAML
return true;
}
void OnShutdown() override {
// Clean up resources
}
std::list<std::pair<std::string, std::string>>
GenInitializationReport() const override {
return {{"key", "value"}}; // Shown in startup log
}
};
Extension Entry Points
// my_extension.cpp, at global scope
#include "my_extension.h"
IBMW_EXT_ENTRY(MyExtension)
Extension Logging
Use the extension logger macros for per-extension logging:
// global.h
#include "extension_logger.h"
IBMW_DECLARE_EXTENSION_LOGGER(my_ext)
// global.cpp
IBMW_DEFINE_EXTENSION_LOGGER(my_ext)
Extension CMake
add_library(my_extension SHARED
my_extension.cpp
)
target_link_libraries(my_extension PRIVATE
ibmw::core::extension_api
ibmw::core::engine
)
The extension must be built for the same target architecture and dependency provider as the IBMW runtime. Its shared object is loaded by the runtime; it is not a substitute for the public managed-application API.
Extension YAML Config
Extensions receive their options from the YAML config:
ibmw:
extensions:
items:
- name: my_extension
path: ./lib/libmy_extension.so
options:
my_option: value
The options node is passed to the extension's Initialize() method via
the engine's configuration subsystem.
Type System
IBMW uses DDS IDL as the primary type definition language with FastCDR for serialization. There is no protobuf dependency.
Defining Types with DDS IDL
Create an IDL file:
// my_types.idl
module protocols {
struct SensorData {
uint64 timestamp;
float temperature;
float humidity;
string sensor_id;
};
};
Code Generation
The DdsIdlGenCode.cmake module generates FastCDR serialization code:
include(DdsIdlGenCode)
ibmw_dds_idl_gen(
TARGET my_types
IDL_FILES my_types.idl
)
This generates:
my_types.h-- Type definitionsmy_types_cdr.h/.cpp-- FastCDR serialize/deserialize functionsmy_types_dds_types.h-- DDS TopicDataType adapter
Hand-Written Types (No Code Generation)
Hand-written DDS typesupport is a direct_<transport>_* escape hatch for
transport-specific integrations, validation, or performance experiments. It
is not the normal managed-module type boundary. Ordinary managed modules
must use generated types and the transport-agnostic public API.
Direct DDS code must link ibmw::extensions::dds_types; the installed header
path below is the supported entry for that extension-facing target. Do not add
a source-tree src/extensions/... include directory to an application target.
#include <ibmw/dds_types/util/dds_type_support.h>
struct HelloMsg {
uint64_t id;
std::string message;
int64_t timestamp;
IBMW_DDS_TYPE_NAME("HelloMsg")
void serialize(eprosima::fastcdr::Cdr& cdr) const {
cdr << id << message << timestamp;
}
void deserialize(eprosima::fastcdr::Cdr& cdr) {
cdr >> id >> message >> timestamp;
}
};
// Register FastCDR v1 free functions
template<>
size_t calculate_serialized_size(
eprosima::fastcdr::CdrSizeCalculator& calc,
const HelloMsg& msg, size_t& current_alignment);
template<>
void serialize(eprosima::fastcdr::Cdr& cdr, const HelloMsg& msg);
template<>
void deserialize(eprosima::fastcdr::Cdr& cdr, HelloMsg& msg);
JSON Types
For management/service types, IBMW supports JSON serialization via nlohmann/json:
#include "cpp/util/json_type_support.h"
struct MyConfig {
static constexpr char kTypeName[] = "my_app::MyConfig";
std::string name;
int value;
NLOHMANN_DEFINE_TYPE_INTRUSIVE(MyConfig, name, value)
};
// Get type support
const auto* ts = ibmw::json::GetJsonMessageTypeSupport<MyConfig>();
Type Support Packages
For runtime type discovery (used by Echo, Proxy, Record/Playback extensions), create a type support package:
#include "ibmw_type_support_abi.h"
static const ibmw_type_support_base_t* kTypeSupportArray[] = {
GetSensorDataTypeSupport(),
GetImageTypeSupport(),
};
IBMW_TYPE_SUPPORT_PKG_EXPORT
const ibmw_type_support_package_v1_t* IbmwDynlibGetTypeSupportPackageV1() {
static const ibmw_type_support_package_v1_t kPackage{
.abi_version = IBMW_TYPE_SUPPORT_PACKAGE_ABI_VERSION_V2,
.struct_size = sizeof(ibmw_type_support_package_v1_t),
.entry_count = std::size(kTypeSupportArray),
.entries = kTypeSupportArray,
.schema_support = nullptr,
.reserved = {}};
return &kPackage;
}
Transport Development
Architecture
The transport subsystem uses a driver-based architecture:
TransportBus
|-- TransportDriver (local)
|-- TransportDriver (dds)
|-- TransportDriver (mqtt)
|-- ...
Each driver implements:
- Publisher registration and message sending
- Subscriber registration and message delivery
- Topic-to-driver routing (configured in YAML)
Routing
Transport routing is regex-based. Publishers and subscribers are matched to
drivers via enable_drivers:
messaging:
publishers:
- topic: "/sensor/.*"
enable_drivers: [dds]
- topic: "/internal/.*"
enable_drivers: [local]
subscribers:
- topic: ".*"
enable_drivers: [local, dds]
Filters
Transport filters intercept messages before/after sending or receiving.
Configured via enable_filters in the routing rules.
RPC Development
Architecture
The RPC subsystem mirrors the transport architecture:
ServiceDispatcher
|-- RpcDriver (local) -- In-process, no network
|-- RpcDriver (dds) -- Pure-DDS, ROS2 wire-compatible
|-- RpcDriver (grpc) -- gRPC remote
|-- RpcDriver (http) -- HTTP remote
|-- ...
The dds driver is registered by the DDS extension. It uses native .srv
mode: business request/response types are directly serialized/deserialized by
FastDDS via the TypeSupport obtained from gencode
(info.req_type_support_ref.CustomTypeSupportPtr()). There are no envelope
wrapper types. For a matching, validated ROS2 release, FastDDS/Fast-CDR profile,
generated type, QoS, and request/reply correlation contract, the CDR payload is
designed to match ROS2 services. This is not a universal cross-version/vendor
compatibility guarantee; each service product still requires typed bidirectional
acceptance evidence.
The driver implements the ROS2 Service wire protocol (WriteParams/SampleInfo
correlation, rq//rr/ topic naming, dds_:: type name infixes) using only
the FastDDS public API -- no rcl/rclcpp dependency. When ros2_compatible: true,
IBMW services are discoverable and callable by standard ROS2 nodes
(ros2 service call, ros2 service list).
Key implementation details:
- TypeSupport is injected by gencode, not hardcoded in the driver
- DDS type names follow the ROS2 convention:
<pkg>::srv::dds_::<Name>_Request_ dds_rpc_types.h(envelope wrappers) has been removed- The
srv:field in ibmw-gen auto-derivesreq_dds_type_name,rsp_dds_type_name, andros2_service_namefrom the.srvpackage path
Four Calling Patterns
| Pattern | Access Class | Blocking | Return |
|---|---|---|---|
| Synchronous | SyncAccessBase<Req, Rsp> |
Yes | rpc::Status |
| Async callback | AsyncAccessBase<Req, Rsp> |
No | via callback |
| Future | FutureAccessBase<Req, Rsp> |
No | std::future<rpc::Status> |
| Coroutine | CoAccessBase<Req, Rsp> |
No | co::Task<rpc::Status> |
The async and future patterns pass req and rsp to the provider by address.
With the reference overloads, the caller must keep both alive until the
callback runs or the future is ready. Generated AsyncAccess and
FutureAccess classes also take std::shared_ptr<const Req> and
std::shared_ptr<Rsp>; those overloads keep both objects alive until the call
completes. A null req or rsp completes with IBMW_RPC_STATUS_CLI_UNKNOWN.
RPC Filters
Coroutine-based RPC filters intercept calls for cross-cutting concerns:
class TimingFilter : public ibmw::CoRpcFilter {
co::Task<rpc::Status> Handle(CoRpcHandle& handle,
CoFilterBus& next) override {
auto start = std::chrono::steady_clock::now();
auto status = co_await next.Next(handle);
auto elapsed = std::chrono::steady_clock::now() - start;
MW_INFO("RPC took {}us",
std::chrono::duration_cast<std::chrono::microseconds>(elapsed).count());
co_return status;
}
};
Register filters on server operations:
ctx_.Srv<Req, Rsp>("/my_service/Query")
.Use(srv_)
.SetCallback(handler)
.AddFilter(std::make_shared<TimingFilter>())
.Build();
Coroutine Support
IBMW provides C++20 coroutine utilities via the ibmw::co namespace:
Scheduling
// Schedule work on an executor
co_await co::Schedule(executor);
// Schedule after a delay
co_await co::ScheduleAfter(executor, std::chrono::seconds(1));
// Schedule at a specific time
co_await co::ScheduleAt(executor, time_point);
Task
co::Task<int> ComputeAsync() {
co_await co::Schedule(executor);
co_return 42;
}
AsyncScope (Structured Concurrency)
co::AsyncScope scope;
// Spawn multiple concurrent tasks
scope.spawn(co::On(scheduler, Task1()));
scope.spawn(co::On(scheduler, Task2()));
// Wait for all tasks
co_await scope.join();
SyncWait (Blocking)
auto result = co::SyncWait(ComputeAsync());
Logging
Log Macros
MW_TRACE("Trace message: {}", value);
MW_DEBUG("Debug message: {}", value);
MW_INFO("Info message: {}", value);
MW_WARN("Warning: {}", value);
MW_ERROR("Error: {}", value);
MW_FATAL("Fatal: {}", value);
Log Levels
| Level | Value | Description |
|---|---|---|
| Trace | 0 | Detailed tracing |
| Debug | 1 | Debug information |
| Info | 2 | General information (default) |
| Warn | 3 | Warnings |
| Error | 4 | Errors |
| Fatal | 5 | Fatal errors |
| Off | 6 | Logging disabled |
Log Format Pattern
The default pattern is: %l %c.%f [%n] %v (%G:%R)
| Specifier | Description |
|---|---|
%l |
Log level |
%c |
Date and time |
%f |
Microseconds |
%n |
Module name |
%v |
Log message |
%G |
Short filename |
%R |
Line number |
%g |
Full file path |
%F |
Function name |
%t |
Thread ID |
Red Lines and Multi-Driver Modules
IBMW enforces a set of code-quality red-line invariants around transport
decoupling. They are checked by scripts/check_red_lines.sh and documented
for contributors in skills/transport_decoupling.md.
Run the checker from the repository root. --report inventories existing
findings without failing; --strict fails on every finding and is appropriate
for a clean scope; --baseline <file> fails only on newly introduced findings:
bash scripts/check_red_lines.sh --report
bash scripts/check_red_lines.sh --baseline scripts/baseline_red_lines.txt
This grep-based checker is an aid, not proof of compliance. Its configured scan paths may not cover every sample or custom directory, so code review must still verify dependency direction and public-header usage.
Direct-driver escape hatches
IBMW_USE_DRIVER and IBMW_USE_DRIVERS are direct-driver escape hatches for
direct_<transport>_* code only. They intentionally couple code to concrete
transport implementations and are forbidden in ordinary managed modules;
managed modules must use SenderAccess<T>, ReceiverAccess<T>,
LoanedSample<T>, LoanedSubscriber<T>, or the corresponding high-level
context APIs. The macros expand to a Module::SetDriverSlot(slot_id, driver_ptr) override that the Engine invokes during Start().
Single-driver module:
class MyModule : public ibmw::Module {
private:
ibmw::extensions::dds_extension::DdsTransportDriver* dds_drv_ = nullptr;
IBMW_USE_DRIVER(ibmw::extensions::dds_extension::DdsTransportDriver, dds_drv_)
};
Multi-driver module:
class MyModule : public ibmw::Module {
private:
ibmw::extensions::dds_extension::DdsTransportDriver* dds_drv_ = nullptr;
ibmw::extensions::iceoryx_extension::IceoryxTransportDriver* iox_drv_ = nullptr;
IBMW_USE_DRIVERS(
IBMW_DRIVER_ENTRY(ibmw::extensions::dds_extension::DdsTransportDriver, dds_drv_),
IBMW_DRIVER_ENTRY(ibmw::extensions::iceoryx_extension::IceoryxTransportDriver, iox_drv_))
};
IBMW_DRIVER_ENTRY matches the broadcast slot_id against
DriverT::kStableDriverId (a stable identifier injected by
IBMW_DECLARE_DRIVER_SLOT in the driver header) and, on match, performs
a static_cast<DriverT*> assignment. Any typo in a driver type name
fails at compile time.
These examples are intentionally transport-coupled escape hatches, not a pattern for ordinary managed modules. Full sample:
src/samples/cpp/multi_driver_demo/. Macro definitions:src/api/cpp/module_base.h. Slot-id entry point:src/api/c/driver_slot.h.
Testing
Running Tests
cmake -B build -DIBMW_BUILD_TESTS=ON
cmake --build build -j$(nproc)
cd build && ctest --output-on-failure
Testing Demos
Most demos do not self-terminate. Use timeout for automated testing:
# Normal demos (respond to SIGINT)
timeout -s INT 5 ./bin/ibmw run ./cfg/my_config.yaml
# DDS demos (may need SIGKILL due to slow shutdown)
timeout -s KILL 10 ./dds_native_app ./cfg/dds_native_cfg.yaml
Exit codes: 0/124/130 = success (124=timeout, 130=SIGINT).
Writing Unit Tests
#include <gtest/gtest.h>
#include "my_module.h"
TEST(MyModuleTest, BasicTest) {
// Test module logic without the IBMW runtime
MyModule module;
// ...
}