Skip to content

Latest commit

 

History

History
53 lines (36 loc) · 1.38 KB

README.md

File metadata and controls

53 lines (36 loc) · 1.38 KB

PubBus

PubBus is a simple, header-only implementation of a MessageBus.

Unit tests are written with the Catch2 test framework.

Note: PubBus requires C++17, the examples and tests use some C++20 features

Example

#include <PubBus/PubBus.hpp>
#include <iostream>

struct DummyMessage : pub::Message
{
    int important_value = 0;
};

int main()
{
    auto bus = pub::MessageBus{};
    const auto message = DummyMessage{ .important_value = 100 };

    bus.subscribe<DummyMessage>(
        [](const DummyMessage& message)
        {
            std::cout << "Important value: " << message.important_value << "\n";
        }
    );

    bus.publish(message);
}

Test Execution

For Visual Studio I recommend installing the Test Adapter for Catch2 and set it up to use the provided catch.runsettings.

For CMake/CTest you can run: ctest <build-dir>/test -S Release

License

This software is available under 2 licenses -- choose whichever you prefer.

  • Public Domain
  • MIT

Credits