Using C++ Functors with Legacy C Libraries
The use of functors or function objects in the object oriented programming paradigm has proven to be useful in the design of scientific applications that need to tie functions and their execution context. However, a recurrent problem when using functors is their interaction with the callback mechanism of legacy C libraries. We review some of the solutions to this problem and present the design of a generic adapter that associates a C function pointer with function objects. This makes it possible to use an object-oriented style of programming and still interface with C libraries in a straightforward manner.
KeywordsObject Instance Argument Type Call Operator Functor Object Member Function
Unable to display preview. Download preview PDF.
- 1.Stroustrup, B.: The C++ programming language. Addison-Wesley, Reading (1997)Google Scholar
- 2.Barton, J., Nackman, L.: Scientific and engineering C++. Addison-Wesley, Reading (1994)Google Scholar
- 3.Hickey, R.: Callbacks in C++ Using Template Functors. C++ Report 7(2), 42–50 (1995)Google Scholar
- 4.Jakubic, P.: Callback Implementations in C++. In: 23rd Technology of Object- Oriented Languages (TOOLS23), Santa Barbara, CA, July 28-August 1, pp. 377–406. IEEE Computer Society Press, Los Alamitos (1997)Google Scholar
- 5.Ellis, M., Stroustrup, B.: The Annotated C++ Reference. Addison-Wesley, Reading (1990)Google Scholar
- 6.Haendel, L.: The function pointer tutorials, http://www.function-pointer.org
- 7.Mensonides, P.: The Boost preprocessor library, http://www.boost.org/libs/
- 9.Alexandrescu, A.: Modern C++ Design. Addison-Wesley, Reading (2001)Google Scholar
- 10.Vandevoorde, D., Josuttis, N.: C++ templates. Pearson Education, London (2003)Google Scholar
- 11.Interop Systems Windows Services for UNIX, http://www.interix.com