Note that there are some explanatory texts on larger screens.

plurals
  1. POPass unmanaged member function pointer to be used by wrapper to connect it to the signal in c++/cli
    text
    copied!<p>I have implemented the Event Handling with Boost::Signal and Boost::Bind in my managed C++ file. Refered the Link:<a href="http://www.radmangames.com/programming/how-to-use-boost-bind" rel="nofollow">Boost::bind</a></p> <p>Also I have created the function pointer in my native C++ file which is passed to my boost::Signal.Connect() as EventHandler in managed code. The code for function which is passed as function pointer in my Native C++</p> <pre><code>std::string NativeCplus::AddFunctionPointer( std::string message ) { return message; } </code></pre> <p>and above function passed as boost::function object in another function NameChangeEvent() as below:</p> <pre><code>void NativeCplus::NameChangeEvent() { UnmanagedNameEvent* unmanagedNameEvent=new UnmanagedNameEvent(); boost::function&lt;std::string (std::string)&gt; f; f=std::bind1st(std::mem_fun(&amp;AlgebraAPI::AddFunctionPointer),this);//FunctionPointer std::string name="abcd"; unmanagedNameEvent-&gt;AddEvent(f,name); } </code></pre> <p>In the above code ,I have taken the boost::function and the function pointer is converted to that boost::function (f).(AM I RIGHT IN SAYING THIS?).Then the line unmanagedNameEvent->AddEvent(f,name) where <strong>boost::function(f)</strong> is passed to <strong>AddEvent(f,name)</strong> and this <strong>AddEvent(f,name)</strong> is implemented in my managed C++ code file. Below is my managed C++ Code which is being referred in the native c++ project:</p> <p>//In my c++/CLI Wrapper.cpp</p> <pre><code> declspec(dllexport) void UnmanagedNameEvent::AddEvent(boost::function&lt;std::string (std::string)&gt; f,std::string name) { UnmanagedNameEvent* unmanagedNameEvent=new UnmanagedNameEvent(); unmanagedNameEvent-&gt;signalEventMessage.connect(f); //which should be like this.. unmanagedNameEvent-&gt;signalEventMessage.connect(bind(NativeCplus::f)); } </code></pre> <p>PROBLEM is I can't use the NativeCplus class to refer to its unmanaged function (i.e.f)as that will create a round dependency of dll file.Any workaround for this?All ears for any shorter solution!!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload