473,396 Members | 1,923 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

encapsulate C callback function into a C++ class

Hi,

I have developped an MFC program that uses a fingerprint scanner.
To control the Bio scanner I use a library with the following function

these functions are used to get the status message from the scanner

T__STATUS SM_BSP_SetFingerStatus(T__STATUS i_nStatus, T__UCHAR *i_pImage,
T__ULONG i_nRow, T__ULONG i_nCol, T__BOOL *o_pContinue)
{
}
T__STATUS SM_BSP_SetMsgInfos(T__INT i_nMsgId, T__BOOL *o_pContinue)
{
}

T__STATUS SM_BSP_SetBSPStatus(T__UCHAR i_nStatusId, T__BOOL *o_pContinue)
{
}

l_GUICallbackFunctions.SM_BSP_SetFingerStatus=(PSM _BSP_SET_FINGER_STATUS)
&SM_BSP_SetFingerStatus;
l_GUICallbackFunctions.SM_BSP_SetMsgInfos = (PSM_BSP_SET_MSG_INFOS)
&SM_BSP_SetMsgInfos;
l_GUICallbackFunctions.SM_BSP_SetBSPStatus = (PSM_BSP_SET_BSP_STATUS)
&SM_BSP_SetBSPStatus;
ret = SM_BSP_SetGUICallback(l_GUICallbackFunctions);

SM_BSP_Capture(); //Capture fingerprint
SM_BSP_Process(); // Process fingerprint
My problem is I would like to create a C++ class like this

// CBio.hpp
class CBio
{
public:

CBio(); // constructor
~CBio(); // destructor
int InitBio();
int Capture();
private:
static T__STATUS SM_BSP_SetFingerStatus();
void EventDelay(DWORD dwMilliSec);
int m_nRet;
SM_BSP_GUI_CALLBACK l_GUICallbackFunctions;

};
//CBio.cpp
int CBio::InitBio()
{
// register CallBacks
l_GUICallbackFunctions.SM_BSP_SetFingerStatus=(PSM _BSP_SET_FINGER_STATUS)
&SM_BSP_SetFingerStatus;
}

return m_nRet;
}

T__STATUS CBio::SM_BSP_SetFingerStatus()
{

return 0;
}

The problem is
l_GUICallbackFunctions.SM_BSP_SetFingerStatus=(PSM _BSP_SET_FINGER_STATUS)
&SM_BSP_SetFingerStatus; doesn't
compile. I need to pass to the SM_BSP_SetFingerStatus function the adress of
another function. It works in C but not in C++.
How can I do this ?


Jul 19 '05 #1
1 6149

mosfet <tr******@wanadoo.fr> wrote in message
news:be**********@news-reader4.wanadoo.fr...
Hi,

I have developped an MFC program that uses a fingerprint scanner.
To control the Bio scanner I use a library with the following function

these functions are used to get the status message from the scanner

T__STATUS SM_BSP_SetFingerStatus(T__STATUS i_nStatus, T__UCHAR *i_pImage,
T__ULONG i_nRow, T__ULONG i_nCol, T__BOOL *o_pContinue)
{
}
T__STATUS SM_BSP_SetMsgInfos(T__INT i_nMsgId, T__BOOL *o_pContinue)
{
}

T__STATUS SM_BSP_SetBSPStatus(T__UCHAR i_nStatusId, T__BOOL *o_pContinue)
{
}

l_GUICallbackFunctions.SM_BSP_SetFingerStatus=(PSM _BSP_SET_FINGER_STATUS)
&SM_BSP_SetFingerStatus;
l_GUICallbackFunctions.SM_BSP_SetMsgInfos = (PSM_BSP_SET_MSG_INFOS)
&SM_BSP_SetMsgInfos;
l_GUICallbackFunctions.SM_BSP_SetBSPStatus = (PSM_BSP_SET_BSP_STATUS)
&SM_BSP_SetBSPStatus;
ret = SM_BSP_SetGUICallback(l_GUICallbackFunctions);

SM_BSP_Capture(); file://Capture fingerprint
SM_BSP_Process(); // Process fingerprint
My problem is I would like to create a C++ class like this

// CBio.hpp
class CBio
{
public:

CBio(); // constructor
~CBio(); // destructor
int InitBio();
int Capture();
private:
static T__STATUS SM_BSP_SetFingerStatus();
void EventDelay(DWORD dwMilliSec);
int m_nRet;
SM_BSP_GUI_CALLBACK l_GUICallbackFunctions;

};
file://CBio.cpp
int CBio::InitBio()
{
// register CallBacks
l_GUICallbackFunctions.SM_BSP_SetFingerStatus=(PSM _BSP_SET_FINGER_STATUS) &SM_BSP_SetFingerStatus;
}

return m_nRet;
}

T__STATUS CBio::SM_BSP_SetFingerStatus()
{

return 0;
}

The problem is
l_GUICallbackFunctions.SM_BSP_SetFingerStatus=(PSM _BSP_SET_FINGER_STATUS)
&SM_BSP_SetFingerStatus; doesn't
compile. I need to pass to the SM_BSP_SetFingerStatus function the adress of another function. It works in C but not in C++.
How can I do this ?


http://www.parashift.com/c++-faq-lit....html#faq-33.2

Also see item 33.1

-Mike

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: ajay.sonawane | last post by:
Hello ther I read somewhere that callback function should be global or static member function. 1: I could use static member functions but how could I access members of class which ar not static....
4
by: ma740988 | last post by:
// file sltest.h #ifndef SLTEST_H #define SLTEST_H class CallbackBase // herb shutters gotW source .. { public: virtual void operator()() const { }; virtual ~CallbackBase() = 0; };
2
by: MR | last post by:
help! I have an unmanaged DLL that I do not have the source code, so i can't recompile or make changes. the DLL requires a callback function. I would like to implement the callback method in a...
4
by: Kyku | last post by:
Hello all, I'm in a process of writing a small Linux C++ program for discovering repeaded files over a filesystem. One part of this task is traversing a directory structure. This is done by the...
3
by: ryan.mitchley | last post by:
Hi all I have a class (cPort) that is designed to receive objects and, depending on the type, call a handler (callback) in any descendant of a cProcessBlock class. Callback functions take a...
6
by: JDT | last post by:
Hi, Can we pass a member function in a class as a callback function? Someone instucted me that I can only use a static functon or a global function as a callback. Your help is appreciated. JD
6
by: smmk25 | last post by:
Before I state the problem, I just want to let the readers know, I am knew to C++\CLI and interop so please forgive any newbie questions. I have a huge C library which I want to be able to use in...
2
by: Evan Burkitt | last post by:
Hi, all. I have a Windows DLL that exports a number of functions. These functions expect to receive a pointer to a callback function and an opaque void* parameter. The callback functions are...
10
by: SQACPP | last post by:
Hi, I try to figure out how to use Callback procedure in a C++ form project The following code *work* perfectly on a console project #include "Windows.h" BOOL CALLBACK...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.