Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eXpl0it3r/PubBus
A simple implementation of a MessageBus.
https://github.com/eXpl0it3r/PubBus
cpp hacktoberfest message messagebus publish-subscribe
Last synced: 28 days ago
JSON representation
A simple implementation of a MessageBus.
- Host: GitHub
- URL: https://github.com/eXpl0it3r/PubBus
- Owner: eXpl0it3r
- License: other
- Created: 2016-03-15T17:47:09.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-02-16T07:09:09.000Z (10 months ago)
- Last Synced: 2024-11-04T12:47:03.494Z (about 1 month ago)
- Topics: cpp, hacktoberfest, message, messagebus, publish-subscribe
- Language: C++
- Homepage:
- Size: 300 KB
- Stars: 26
- Watchers: 3
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- AwesomeCppGameDev - PubBus
README
# PubBus
**PubBus** is a simple, header-only implementation of a MessageBus.
Unit tests are written with the [Catch2](https://github.com/catchorg/Catch2) test framework.
**Note:** PubBus requires C++17, the examples and tests use some C++20 features
## Example
```c++
#include
#includestruct DummyMessage : pub::Message
{
int important_value = 0;
};int main()
{
auto bus = pub::MessageBus{};
const auto message = DummyMessage{ .important_value = 100 };bus.subscribe(
[](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](https://github.com/JohnnyHendriks/TestAdapter_Catch2) and set it up to use the provided `catch.runsettings`.
For CMake/CTest you can run: `ctest /test -S Release`
## License
This software is available under 2 licenses -- choose whichever you prefer.
- Public Domain
- MIT## Credits
* [Message Bus (GDD #3)](http://www.optank.org/2013/04/02/game-development-design-3-message-bus/) by Stefan Schindler
* [SW Message Bus](http://www.codeproject.com/Articles/723656/SW-Message-Bus) by Evgeny Zavalkovsky
* [Catch C++ Test Framework](https://github.com/philsquared/Catch) by Phil Nash