C++ Boost Signals connecting two functions from two different classes in template -


i'm trying make connection between function in 1 class can call in class. answers i've found either specific or maybe i'm missing because cannot life of me figure out i'm doing wrong. also, i'm bit new boost library please excuse dumb questions may ask.

the setup workflow this...

class myclass : public baseclass {    void setup();   void myfunc(datatype);    otherclass myotherclass;  }  void setup() {    othernamespace::addlistener(this, myotherclass); }  namespace othernamespace {  class otherclass {    signals::signal<void (datatype)> myconnection;  }  template<class a, class b> void addlistener(a * app, b & connection) {    connection.myconnection.connect( 'i don't know here' ); } } 

basically, addlistener function won't make connection between signal , function. know don't know i'm doing wrong can't figure out wrong. i'm making helper function can pass functions 1 class call them when they're attached. i'm trying create domino event websocket connection , missing important. appreciated.

i'm on xcode , boost , macbook pro.

you should connect signal matching slot, callable having appropriate signature. best solution leave slot creation caller of addlistener function (the following code, in sscce form):

#include <boost/signals2.hpp>  typedef int datatype; class baseclass {};  namespace othernamespace  {   class otherclass    {   public:     boost::signals2::signal<void (datatype)> myconnection;   };    template<class a, class b>   void addlistener(a app, b & connection)   {      connection.myconnection.connect(app);   } }  class myclass : public baseclass  { public:    void setup();   void myfunc(datatype)   {}    othernamespace::otherclass myotherclass;  };  void myclass::setup() {    // let caller decide how make slot    othernamespace::addlistener(boost::bind(&myclass::myfunc, this, _1), myotherclass); } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -