Abstract
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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Stroustrup, B.: The C++ programming language. Addison-Wesley, Reading (1997)
Barton, J., Nackman, L.: Scientific and engineering C++. Addison-Wesley, Reading (1994)
Hickey, R.: Callbacks in C++ Using Template Functors. C++ Report 7(2), 42–50 (1995)
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)
Ellis, M., Stroustrup, B.: The Annotated C++ Reference. Addison-Wesley, Reading (1990)
Haendel, L.: The function pointer tutorials, http://www.function-pointer.org
Mensonides, P.: The Boost preprocessor library, http://www.boost.org/libs/
Meyers, N.: Traits: A New and Useful Template Technique. C++ Report 7(5), 32–35 (1995)
Alexandrescu, A.: Modern C++ Design. Addison-Wesley, Reading (2001)
Vandevoorde, D., Josuttis, N.: C++ templates. Pearson Education, London (2003)
Interop Systems Windows Services for UNIX, http://www.interix.com
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2004 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Broeckhove, J., Vanmechelen, K. (2004). Using C++ Functors with Legacy C Libraries. In: Laganá, A., Gavrilova, M.L., Kumar, V., Mun, Y., Tan, C.J.K., Gervasi, O. (eds) Computational Science and Its Applications – ICCSA 2004. ICCSA 2004. Lecture Notes in Computer Science, vol 3046. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-24768-5_55
Download citation
DOI: https://doi.org/10.1007/978-3-540-24768-5_55
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-22060-2
Online ISBN: 978-3-540-24768-5
eBook Packages: Springer Book Archive