Skip to main content

A System for Runtime Type Introspection in C++

  • Conference paper
Programming Languages

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 7554))

Abstract

Many object-oriented languages support some kind of runtime introspection that allows programmers to navigate through meta-data describing the available classes, their attributes and methods. In general, the meta-data can be used to instantiate new objects, manipulate their attributes and call their methods. The meta-programming enabled by this kind of reflection has proven itself useful in a variety of applications such as object-relational mappings and inversion-of-control containers and test automation

Motivated by the need of programmatic support for composition and configuration of software components at runtime, in this work we show how to implement a runtime reflection support for C++11, using the available runtime type information, template metaprogramming and source code analysis. We will show the capabilities of the reflection API and the memory footprint for different kinds of meta-data. The API relies on a few features introduced by C++11, the new ISO standard for C++. Our reflection system is not invasive as it requires no modifications whatsoever of the application code.

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 54.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 72.00
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. Fowler, M.: Inversion of control containers and the dependency injection pattern, http://martinfowler.com/articles/injection.html

  2. dos Reis, V.Q., Cerqueira, R.: Controlling processing usage at user level: a way to make resource sharing more flexible. Concurr. Comput.: Pract. Exper. 22(3), 278–294 (2010)

    Google Scholar 

  3. Roiser, S., Mato, P.: The seal c++ reflection system. In: Proceedings of CHEP 2004, Interlaken, Switzerland, September 24-October 1, CERN-2005-02, vol. 1, p. 437. International Standard; Programming Languages - C++; ISO/IEC 14882:2003(E); 2nd edn. (October 15, 2003); ISO, CH-1211 Geneva 20 (2004)

    Google Scholar 

  4. Devadithya, T., Chiu, K., Lu, W.: C++ reflection for high performance problem solving environments. In: Proceedings of the 2007 Spring Simulation Multiconference - SpringSim 2007, vol. 2, pp. 435–440. Society for Computer Simulation International, San Diego (2007)

    Google Scholar 

  5. Veldhuizen, T.: Using template metaprograms. C++ Report 7, 26–31 (1995)

    Google Scholar 

  6. Czarnecki, K.: Generative Programming. Phd. thesis, Technical University of Ilmenau (1998)

    Google Scholar 

  7. Alexandrescu, A.: Modern C++ Desing. Addison-Wesley (2001)

    Google Scholar 

  8. Alexandrescu, A.: Discriminated unions. C/C++ Users Journal (April 2002)

    Google Scholar 

  9. Becker, T.: On the tension between object-oriented and generic programming in C++ and what type erasure can do about it, http://www.artima.com/cppsource/type_erasure2.html

  10. Henney, K.: Valued conversions. C++ Report (July-August 2000)

    Google Scholar 

  11. Boost C++ libraries, http://www.boost.org/

  12. Qt library, http://doc.qt.nokia.com/4.7/

  13. Preney, P.: Applying std::tuple to functors efficiently, http://preney.ca/paul/archives/486

  14. Clang C language family frontend for LLVM, http://clang.llvm.org/

  15. Clugston, D.: Member function pointers and the fastest possible C++ delegates, http://clang.llvm.org/

  16. Pococapsule/C++ ioc, http://www.pocomatic.com/prod-docs.html

  17. Knizhnik, K.: Reflection for C++, http://www.garret.ru/cppreflection/docs/reflect.html

  18. MSDN: Reflection in C++, http://msdn.microsoft.com/en-us/library/y0114hz2(v=vs.80).aspx

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2012 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

de Bayser, M., Cerqueira, R. (2012). A System for Runtime Type Introspection in C++. In: de Carvalho Junior, F.H., Barbosa, L.S. (eds) Programming Languages. Lecture Notes in Computer Science, vol 7554. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-33182-4_9

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-33182-4_9

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-33181-7

  • Online ISBN: 978-3-642-33182-4

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics