Re: [Linux1394-devel] Announce: SDPAVC
Brought to you by:
aeb,
bencollins
From: Manfred W. <e95...@st...> - 2000-04-06 00:33:27
|
"Timothy M. Shead" wrote: > You didn't notice that sdpAvcSubUnit::FCPHandler is a static member > function, meaning that it does not have an implicit "this" pointer, and thus > *does* have the correct prototype for use with raw1394_set_fcp_handler(). Ok. You are right. > [...discussion about ways to an object-oriented apporach...] > [...] So, would this require changes to just > libraw1394, or to the kernel code itself? I think: yes. In my opinion, the easiest way would be to store that private data in the raw-handle. For that purpose we would only have to adopt raw1394_private.h: struct raw1394_handle { int fd; unsigned int generation; nodeid_t local_id; int num_of_nodes; bus_reset_handler_t bus_reset_handler; tag_handler_t tag_handler; fcp_handler_t fcp_handler; iso_handler_t iso_handler[64]; struct raw1394_request req; quadlet_t buffer[2048]; void *private_data; // new private data to store pointer to object }; I think, that's all (I did not try it yet). Then after getting the handle via raw1394_get_handle (), we have to store our pointer in the handle. The rest would be - in your example: class sdpAvcSubUnit { // other stuff ... // ... this is the global callback function accessible by "C" ... static int RawFCPHandler(raw1394handle_t handle, nodeid_t nodeid, int response, size_t length, unsigned char *data); // This is the actual per-object callback method ... called from RawFCPHandler() ... unnecessary arguments eliminated int FCPHandler(nodeid_t nodeid, int response, size_t length, unsigned char *data); // other stuff ... }; int RawFCPHandler(raw1394handle_t handle, nodeid_t nodeid, int response, size_t length, unsigned char *data) { return ((sdpAvcSubUnit*) handle->private_data)->FCPHandler(nodeid, response, length, data); } int FCPHandler(nodeid_t nodeid, int response, size_t,length, unsigned char *data) { // Do whatever, access member data, etc. } Of course, it would also be possible to change the handler to get that user data as 6th argument; but my version requires less change of libraw1394. Manfred Weihs |