Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

michaelcowan/ass

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

41 Commits

Repository files navigation

Another Signal Slot

Signal/Slot implementation with a focus on automatic connection handling

Try online GitHub Github Releases Build Status Coverage Status

Features

  • Automatic connection handling
    • when a Signal or Slot goes out of scope, the connection is severed
    • no need to implement an interface or inherit a base class
  • Type-safe
  • Header only

Limitations

  • Not thread-safe
  • Not reentrant-safe

Usage Examples

Observer Pattern Example

Slot<std::string> observer([](std::string s) {
 std::cout << s << std::endl;
});
Signal<std::string> subject;
subject.connect(observer);
subject.emit("Hello World");

Class Decoupling Example

class Button {
public:
 Signal<> pressed;
private:
 void onMouseButtonDownInsideButtonArea() {
 pressed.emit();
 }
};
class Popup {
public:
 const Slot<> show = Slot<>(this, &Popup::render);
private:
 void render() { }
};
Button button;
Popup popup;
button.pressed.connect(popup.show);

About

Another Signal/Slot with a focus on automatic connection handling

Topics

Resources

License

Stars

Watchers

Forks

Packages

Contributors

AltStyle によって変換されたページ (->オリジナル) /