Gunni:
What I suggested the other day will work, but what I did not think would work, actually will, with a little massaging. This will allow you to store a "pointer" to a member method (virtual or non-virtual is OK, static or function is not) in VI_ATTR_USER_DATA. I say "pointer" because it is a pointer when used in the correct context; it is not a direct address like a normal C function pointer. Here is some sample code. Let me say right now that this is pretty advanced C++ stuff. Well, at least it's not common.
All of your handler methods must be in the same class or derived from the same base class, and must be of the same signature. You must typedef your pointer like this. This example takes no arguments and returns a VISA st
atus value, but of course you can change that as you wish.
typedef ViStatus (CMyVisaAppClass::* mymemberptr)();
In your code where you want to specify the member function, this is the ugliest part. You do a "special" cast to pass it by value since there is not a direct version of SetAttribute that matches this exact type:
mymemberptr foo = myRealHandler;
vi.SetAttribute(VI_ATTR_USER_DATA,*(void**)&foo);
Like I said, that part is ugly but it does work. The last part is the prettiest, though. In your handler, just get the user data as a pointer and invoke it!
CNiVisaSession& rvi = event.GetSession();
mymemberptr foo;
rvi.GetAttribute(VI_ATTR_USER_DATA,&foo);
ViStatus stat = (pmyclass->*foo)();
Recall that since the initial handler callback is in a _cdecl (ie, non-member) function, you must have a pointer to your actual class in order to correctly resolve the member pointer value. That is what the "pmyclass" is about. I assume you will have already figured out how to
do that with your current solution.
Again, this is pretty advanced, and it may be more confusing than what you are already coding. But it can be done!
Dan Mondrik