Questions tagged [boost-signals2]

The Boost.Signals2 library is a thread-safe C++ implementation of a managed signals and slots system.

The Boost.Signals2 library is a thread-safe C++ implementation of a managed signals and slots system. Signals represent callbacks with multiple targets, and are also called publishers or events in similar systems. Signals are connected to some set of slots, which are callback receivers (also called event targets or subscribers), which are called when the signal is "emitted."

Signals and slots are managed, in that signals and slots (or, more properly, objects that occur as part of the slots) can track connections and are capable of automatically disconnecting signal/slot connections when either is destroyed. This enables the user to make signal/slot connections without expending a great effort to manage the lifetimes of those connections with regard to the lifetimes of all objects involved.

When signals are connected to multiple slots, there is a question regarding the relationship between the return values of the slots and the return value of the signals. Boost.Signals2 allows the user to specify the manner in which multiple return values are combined.

109 questions
1
vote
0 answers

How to combine signals in Boost Signals2?

How would I combine two signals of the same type? Let's say I have two signals with one connection each, foo and bar. boost::signals2::signal foo; foo.connect([]{ std::cout << "Hello from foo!" <<…
1
vote
1 answer

Problems compiling boost signal2

Why does this simple example not compile, and how can I get around the problem? #include #include struct HelloWorld { HelloWorld() { i = 0; } void operator()() { std::cout << "I…
Allan
  • 4,562
  • 8
  • 38
  • 59
1
vote
0 answers

boost packages generate compiler notes in vs2015

All, I'm trying to track down the cause, and any answer that will get these compiler notes from mucking up my build. I'm using VS2015, warning level 3. Since these are 'notes', i'm not sure what i can do to hide them. As soon as i even include the …
Jason
  • 2,147
  • 6
  • 32
  • 40
1
vote
1 answer

C++ Boost signals and slots connection

I am trying to connect a gui to my logic thread using boosts signals and slots, the logic class has a neat method to connect functions to the signal. Here is a simplified replica of the locig class: #include #include…
1
vote
2 answers

What do parentheses mean within angle brackets for a Boost signal?

In my basic c++ book, there is no class declaration like below. the strange code for me is ... boost::signals2::signal >…
kwontwitch
  • 11
  • 1
1
vote
1 answer

C++ shared_ptr std::bind and std::function

I have the following: class B listens to a boost::signal2 of class C and when triggered will execute a callback given by class A and that executes a method in class A A, B and C, D are all std::shared_ptr. The problem is that when class D releases…
Ben D
  • 465
  • 1
  • 6
  • 20
1
vote
0 answers

interaction problem with boost.signals2?

I'm trying to call a signal after an booost::asio::async_read from inside a function called by boost::asio::io_service. The run function runs in a thread, and the observers are connected in a different thread. This is causing errors. It's my program…
Germán Diago
  • 7,473
  • 1
  • 36
  • 59
1
vote
2 answers

boost::signals2::signal gives wrong output?

I'm new to boost library, while practicing an example on bind, i wrote the following code. But, it seems like the 'res' is computed properly but, the correct result is not transmitted back to the signal. Kindly help, what is wrong in the following…
1
vote
2 answers

How to update the Qt GUI from a Boost signal that is raised in another thread?

I have a plain C++ object that runs a data acquisition routine in a separate thread and notify process with a Boost signal named acquisitionStageChangedEvent with the following signature: boost::signal2::signal. How can I…
Darien Pardinas
  • 5,910
  • 1
  • 41
  • 48
1
vote
2 answers

How to implement a class member pointer in C++ using std::function or Boost?

I want to implement an object-oriented function pointer in C++ (comparable to delegates in C#). I wrote an example code which uses "MagicFunctionPainter" as a placeholder for the final class: class A { public: MagicFunctionPointer p; void…
user3684240
  • 1,420
  • 2
  • 12
  • 18
1
vote
1 answer

How can you bind a variadic member function to a functor?

I am attempting to bind the first parameter of a variadic function using std::bind and then pass the returned functor to the connect() function of a boost::signals2::signal. The process works fine as long as the variadic function is not a member…
maaronking
  • 65
  • 7
1
vote
1 answer

boost signals auto disconnect lambda slot

I'm trying to do this: boost::signals::connection c = somesignal.connect( [c]()->void{ // Do something c.disconnect(); }) Will this cause problems? The connection c is assigned only after connect. lambda needs to be initialized before…
Min Lin
  • 3,177
  • 2
  • 19
  • 32
1
vote
0 answers

generic interface to connect modules with boost::signals2 and unknown signatures of signals and slots

i want to connect some modules with boost::signals2 to each other. Each module is an object of some class and has its own signal for example: boost::signals2::signal outputSignal; The signatures of the signals and the slots…
gerrit
  • 21
  • 2
1
vote
1 answer

Signals2 connect() usage with templates

I am trying to create template classes for some repetitive functions that will be required for sending data around, of different types. However, my issue (I think) is really with InterfacePublisher::addSubscription() function that is utilizing…
user142650
1
vote
2 answers

Can a C++ signals2 slot callback contain Objective-C/C++ Class/Selector (Method) information?

This must be so obvious to some of you, but I cannot find an example of this: I need for a boost::signals2 signal to connect a slot callback that is a C++ class member function or functor, so I can make model callbacks into Objective-C/C++…