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.
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
Fowler, M.: Inversion of control containers and the dependency injection pattern, http://martinfowler.com/articles/injection.html
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)
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)
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)
Veldhuizen, T.: Using template metaprograms. C++ Report 7, 26–31 (1995)
Czarnecki, K.: Generative Programming. Phd. thesis, Technical University of Ilmenau (1998)
Alexandrescu, A.: Modern C++ Desing. Addison-Wesley (2001)
Alexandrescu, A.: Discriminated unions. C/C++ Users Journal (April 2002)
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
Henney, K.: Valued conversions. C++ Report (July-August 2000)
Boost C++ libraries, http://www.boost.org/
Qt library, http://doc.qt.nokia.com/4.7/
Preney, P.: Applying std::tuple to functors efficiently, http://preney.ca/paul/archives/486
Clang C language family frontend for LLVM, http://clang.llvm.org/
Clugston, D.: Member function pointers and the fastest possible C++ delegates, http://clang.llvm.org/
Pococapsule/C++ ioc, http://www.pocomatic.com/prod-docs.html
Knizhnik, K.: Reflection for C++, http://www.garret.ru/cppreflection/docs/reflect.html
MSDN: Reflection in C++, http://msdn.microsoft.com/en-us/library/y0114hz2(v=vs.80).aspx
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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)