Abstract
The C++ language has only a limited runtime type information system, which doesn’t provide full reflection capabilities. We present a general mechanism to support reflection, exploiting template metaprogramming techniques. Two solutions are presented: a static one where metaclass information is only available at compile time to produce class specific code; and a dynamic one where metaclass objects exist at runtime. As a case study of technique we show how to build an object interface to relational database tables. By just annotating a class definition with meta information, such as storage attributes or index properties of fields, a programmer can define objects that can be stored, fetched or searched in a database table. This approach has been used in building a high-performance, full text search engine.
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
R.G. Gabriel, D.G. Bobrow, J.L. White, CLOS in Context-The Shape of the Design Space. In Object Oriented Programming-The CLOS perspective. The MIT Press, Cambridge, MA, 1993, pp. 29–61.
K. Czarnecki, U.W. Eisenacker, Generative Programming-Methods, Tools, and Applications. Addison Wesley, Reading, MA, 2000.
B. Stroustrup, The Design and Evolution of C++. Addison Wesley, Reading, MA, 1994.
Sleepycat Software, The Berkeley Database, http://www.sleepycat.com.
MySQL, MySQL, http://www.mysql.com.
Microsoft, ActiveX Data Objects, http://msdn.microsoft.com/library/psdk/dasdk/adot9elu.htm.
K.A. Knizhnik, The GigaBASE Object-Relational database system, http://www.ispras.ru/~knizhnik.
Sun Microsystems, Java Database Connectivity, http://java.sun.com/.
Petter Urkedal, Tools for Template Metaprogramming, http://matfys.lth.se/~petter/src/more/metad.
R. Sunderraman, Oracle8™ Programming: a primer, Addison-Wesley, MA, 2000.
P. J. Plauger, A. Stepanov, M. Lee, D. Musser, The Standard Template Library, Prentice-Hall, 2000.
J. Malenfant, M. Jaques, and F.-N. Demers, A tutorial on behavioral reflection and its implementation. Proceedings of the Reflection 96 Conference, Gregor Kiczales, editor, pp. 1–20, San Francisco, California, USA, April 1996.
Tyng-Ruey Chuang and Y. S. Kuo and Chien-Min Wang, Non-Intrusive Object Introspection in C++: Architecture and Application. Proceedings of the 20th Int. Conference on Software Engineering, IEEE Computer Society Press, pp. 312–321, 1998
Peter W. Madany, Nayeem Islam, Panos Kougiouris, and Roy H. Campbell, Reification and reflection in C++: An operating systems perspective. Technical Report UIUCDCS-R-92-1736, Dept. of Computer Science, University of Illinois at Urbana-Champaign, March 1992.
Yutaka Ishikawa, Atsushi Hori, Mitsuhisa Sato, Motohiko Matsuda, J. Nolte, Hiroshi Tezuka, Hiroki Konaka, Munenori Maeda, and Kazuto Kubota, Design and Implementation of metalevel architecture in C++-MPC++ approach. Proceedings of the Reflection 96 Conference, Gregor Kiczales, editor, pages 153–166, San Francisco, California, USA, April 1996.
B. Gowing and V. Cahill, Meta-Object Protocols for C++: The Iguana Approach. Proc. Reflection '96, San Francisco, California, 1996, pp. 137–152.
Shigeru Chiba. A metaobject protocol for C++. Conference Proceedings of Object-Oriented Programming Systems, Languages and Applications, pp. 285–299, ACM Press, 1995.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2001 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Attardi, G., Cisternino, A. (2001). Reflection Support by Means of Template Metaprogramming. In: Bosch, J. (eds) Generative and Component-Based Software Engineering. GCSE 2001. Lecture Notes in Computer Science, vol 2186. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-44800-4_11
Download citation
DOI: https://doi.org/10.1007/3-540-44800-4_11
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-42546-5
Online ISBN: 978-3-540-44800-6
eBook Packages: Springer Book Archive