|
Download src/3rdParty/FastSignals/docs/simple-examples.md from AbdulElahGwaith/FreeCAD: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/AbdulElahGwaith/FreeCAD/resolve/main/src/3rdParty/FastSignals/docs/simple-examples.md
- Command line
-
hf download hf://AbdulElahGwaith/FreeCAD/src/3rdParty/FastSignals/docs/simple-examples.md
-
curl -L -o simple-examples.md https://huggingface.co/AbdulElahGwaith/FreeCAD/resolve/main/src/3rdParty/FastSignals/docs/simple-examples.md
1.27 kB
Simple Examples
If you are not familar with Boost.Signals2, please read Boost.Signals2: Connections
Example with signal<> and connection
// Creates signal and connects 1 slot, calls 2 times, disconnects, calls again.
// Outputs:
// 13
// 17
#include "libfastsignals/signal.h"
using namespace fastsignals;
int main()
{
signal<void(int)> valueChanged;
connection conn;
conn = valueChanged.connect([](int value) {
cout << value << endl;
});
valueChanged(13);
valueChanged(17);
conn.disconnect();
valueChanged(42);
}
Example with scoped_connection
// Creates signal and connects 1 slot, calls 2 times, calls again after scoped_connection destroyed.
// - note: scoped_connection closes connection in destructor
// Outputs:
// 13
// 17
#include "libfastsignals/signal.h"
using namespace fastsignals;
int main()
{
signal<void(int)> valueChanged;
{
scoped_connection conn;
conn = valueChanged.connect([](int value) {
cout << value << endl;
});
valueChanged(13);
valueChanged(17);
}
valueChanged(42);
}