Abstract
In C++, a caller must know the type of the object whose methods it is calling. The objects called are typically implemented previously, e.g., in object libraries, and therefore their types are known. However, in some cases, a library object or any other previously implemented object needs to call back a user whose type is not known. We should therefore not make restrictive assumptions about the types of the objects that are called back. This is not a trivial problem in C++.
This paper presents a simple framework for implementation of object libraries. It illustrates a type-safe solution, a design pattern if you will, for an object which will be used by another object of any unknown type to call its user back. The solution is called an abstract partner, which is an abstract class that declares requirements for the user object. The compiler checks that these requirements are met, which makes the solution safe.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
J.Rumbaugh, M.Blaha, W.Premerlani, F.Eddy, W.Lorensen. Objectoriented Modeling and Design. Prentice-Hall, 1991.
J-M. Aalto and A. Jaaksi. Object-Oriented Development of Interactive Systems with OMT++. In R. Ege, M. Singh, B. Meyer, editors, TOOLS 14, Technology of Object-Oriented Languages & Systems, 205–218. Prentice Hall, 1994.
A. Jaaksi. Implementing Interactive Applications in C++, in Software Practice & Experience. Volume 25, No. 3. 271–289. John Wiley & Sons. March 1995.
M.A.Ellis and B.Stroustrup. The Annotated C++ Reference Manual. Addison-Wesley Publishing Company, 1990.
V.Punkka. Intelligent Reusable User Interface Components, in The X Resource, Issue 13. 201–215. O’Reilly & Assoc. Inc. 1995.
J.Gettys and R.W.Scheifler. Xlib - C Language X Interface, MIT X Consortium Standard. Massachusetts Institute of Technology and Digital Corporation, 1991.
D.A.Young. Object-Oriented Programming with C++ and OSF/Motif. Prentice Hall, 1992.
A.Benson and G.Aitken. OI Programmer’s Guide. Prentice Hall, 1992.
R. Hickey. Callbacks in C++ Using Template Functors, in C++ Report, Vol. 7/No 2. 42–50. SIGS. February 1995.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 1997 Springer-Verlag London Limited
About this paper
Cite this paper
Jaaksi, A. (1997). Type-safe Callbacks with Abstract Partners. In: Patel, D., Sun, Y., Patel, S. (eds) OOIS’96. Springer, London. https://doi.org/10.1007/978-1-4471-0973-0_7
Download citation
DOI: https://doi.org/10.1007/978-1-4471-0973-0_7
Publisher Name: Springer, London
Print ISBN: 978-3-540-76132-7
Online ISBN: 978-1-4471-0973-0
eBook Packages: Springer Book Archive