Event bus facility to help decouple communication between modules,class,etc.
Since is header only,just include EventBus.hpp your project.
struct DataReceivedEvent{/*Add context here*/};
struct DataTransmittedEvent{/*Add context here*/};
void CommIf::onReceived(DataReceivedEvent ev){/*Process event here*/}
void CommIf::onTransmitted(DataTransmittedEvent ev){/*Process event here*/}
auto& bus = event_bus::EventBus::getInstance();
CommIf comm{/* */};
bus.registerEvent<DataReceivedEvent>(std::bind(&CommIf::onReceived, &comm std::placeholders::_1));
bus.registerEvent<DataTransmittedEvent>(std::bind(&CommIf::onTransmitted, &comm std::placeholders::_1));
auto& bus = event_bus::EventBus::getInstance();
bus.fireEvent(DataReceivedEvent{/**/});
bus.fireEvent(DataTransmittedEvent{/**/});
No dependecy.
mkdir build
cd build
cmake ..
make
make install
GoogleTest is required to run tests.
mkdir build
cd build
cmake .. -DBUILD_TEST=ON
make
./build/tests/run_tests
mkdir build
cd build
cmake .. --DBUILD_EXAMPLE=ON
make
./build/tests/run_tests
- Ali ihsan Cengiz - Software Engineer - aliihsancengiz