Skip to main content

Reflection Support by Means of Template Metaprogramming

  • Conference paper
  • First Online:
Generative and Component-Based Software Engineering (GCSE 2001)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 2186))

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 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.

    Google Scholar 

  2. K. Czarnecki, U.W. Eisenacker, Generative Programming-Methods, Tools, and Applications. Addison Wesley, Reading, MA, 2000.

    Google Scholar 

  3. B. Stroustrup, The Design and Evolution of C++. Addison Wesley, Reading, MA, 1994.

    Google Scholar 

  4. Sleepycat Software, The Berkeley Database, http://www.sleepycat.com.

  5. MySQL, MySQL, http://www.mysql.com.

  6. Microsoft, ActiveX Data Objects, http://msdn.microsoft.com/library/psdk/dasdk/adot9elu.htm.

  7. K.A. Knizhnik, The GigaBASE Object-Relational database system, http://www.ispras.ru/~knizhnik.

  8. Sun Microsystems, Java Database Connectivity, http://java.sun.com/.

  9. Petter Urkedal, Tools for Template Metaprogramming, http://matfys.lth.se/~petter/src/more/metad.

  10. R. Sunderraman, Oracle8™ Programming: a primer, Addison-Wesley, MA, 2000.

    Google Scholar 

  11. P. J. Plauger, A. Stepanov, M. Lee, D. Musser, The Standard Template Library, Prentice-Hall, 2000.

    Google Scholar 

  12. 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.

    Google Scholar 

  13. 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

    Google Scholar 

  14. 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.

    Google Scholar 

  15. 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.

    Google Scholar 

  16. B. Gowing and V. Cahill, Meta-Object Protocols for C++: The Iguana Approach. Proc. Reflection '96, San Francisco, California, 1996, pp. 137–152.

    Google Scholar 

  17. Shigeru Chiba. A metaobject protocol for C++. Conference Proceedings of Object-Oriented Programming Systems, Languages and Applications, pp. 285–299, ACM Press, 1995.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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

Publish with us

Policies and ethics