Can i encapsulate this function __cdecl DataHandler?

Post Reply
prap19
Posts: 5
Joined: Wed Nov 24, 2010 9:17 am

Can i encapsulate this function __cdecl DataHandler?

Post by prap19 »

In the Sample code provided in the SDK, the function __cdecl DataHandler is responsible for receiving data from server? Am I right?
My application is fully object oriented so I will need to encapsulate this function.
Eg: void myClass::__cdecl DataHandler(sFrameOfMocapData* data, void* pUserData)

How can I do it? Or is there any other way that i can obtain data from the server.
Looking forward for your answers.
morgan
NaturalPoint Employee
NaturalPoint Employee
Posts: 199
Joined: Tue Jun 24, 2008 2:01 pm
Location: Corvallis, OR, USA
Contact:

Re: Can i encapsulate this function __cdecl DataHandler?

Post by morgan »

Yes you can do this by declaring the member function static:

static void DataHandler(sFrameOfMocapData* data, void* pUserData);

If you need access to the class instance during the callback, you can pass an instance of the class to SetDataCallback. Something like:

theClient->SetDataCallback( pMyObject->DataHandler, pMyObject );

hope this helps,

Morgan
Post Reply