Skip to content

Lightweight Signals & Slots Library -- C++17 -- Single Header

License

Notifications You must be signed in to change notification settings

a-n-t-h-o-n-y/signals-light

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Signals Light 🪶

This is a Signals and Slots library. The Signal class is an observer type, it can have Slots(functions) registered to it, and when the Signal is emitted, all registered Slots are invoked. It is written in C++17 and is header only.

Slots can track the lifetime of particular objects and they will disable themselves when one of the tracked objects is destroyed. This is useful if the function you are registering with the Signal holds a reference to an object that might be destroyed before the Signal is destroyed.

This library is 'light' in terms of the boost::Signal2 library, which is thread safe, has ordered connections, and in general is more feature-heavy.

#include <signals_light/signal.hpp>

{
    auto signal = sl::Signal<void(int)>{};
    signal.connect([](int i){ std::cout << i << '\n'; });
    signal.connect([](int i){ std::cout << i * 2 << '\n'; });

    signal(4);  // prints "4\n8\n" to standard output.
}

Getting Started

The CMakeLists.txt file will give you a signals-light library target to link against in your own project.

  • #include <signals_light/signal.hpp>
  • namespace sl.

About

Lightweight Signals & Slots Library -- C++17 -- Single Header

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published