Go to main page

Header-only C++ signal/slot Library

This library is part of the libtau library, but from the this site you can download standalone header.

The tau::signal is a robust, type-safe implementation of the Observer pattern, inspired by libsigc++-2.0. It provides a clean and efficient way to decouple components in your application by allowing objects to communicate through signals and slots without direct dependencies.

Key Features and Advantages

  1. Enhanced Safety Model:
    • No Global Disconnect: Unlike many other implementations, this system does not provide signal::disconnect() or signal::clear() methods. Slots can only be disconnected through their associated connection object. This prevents accidental disconnection of internal library slots
    • Emission Safety: The implementation is aware of signal modifications during emission. You can safely add, remove, or even delete the signal itself from within a slot function without causing undefined behavior
  2. Automatic Connection Management:
    • The Observer object is a descender of trackable class, which is not template
    • Copyable Components: Both signal and trackable classes are fully copyable, which is an improvement over libsigc++ where these were not copyable
    • RAII Connection Management: The connection class provides automatic disconnection when it goes out of scope (with autodrop property) or when explicitly dropped
  3. Flexible Connection Control:
    • Blocking: Each connection can be individually blocked/unblocked with a cumulative counter
    • Scoped Connections: Automatic disconnection on destruction with the autodrop property
  4. Multiple Emission Schemes:
    • EACH: For void-return signals, all slots are called unconditionally
    • ANY: For boolean-return signals, emission stops when the first slot returns true
    • ALL: For validation purposes, all slots must return true for the signal to return true
  5. Thread Awareness:
    • Single-threaded Design: The implementation is explicitly designed for single-threaded GUI applications, avoiding the overhead of thread-aware implementations while maintaining maximum performance for its intended use case
  6. The slot emission order is guaranteed

API Reference
Standalone Header