AspectC++ – An AOP Extension for C++

Olaf Spinczyk, Daniel Lohmann, Matthias Urban · 2005

More and more software developers get in touch with aspect-oriented programming (AOP). By providing means to modularize the implementation of crosscutting concerns, it stands for more reusability, less coupling between modules, and better separation of concerns in general. Today, solid tool support for AOP is available, for instance, by JBoss (JBoss AOP), BEA (AspectWerkz), and IBM (AspectJ and the AJDT for Eclipse). However, all these products are based on the Java language. For C and C++ developers none of the key players offers AOP support, yet. This article introduces AspectC++, which is an aspectoriented language extension for C++. A compiler for AspectC++, which transforms the source code into ordinary C++ code, is developed as an open source project. The AspectC++ project began with a research prototype in 2001 that has gained maturity over the years. Today, the AspectC++ language and weaver has been successfully applied in a number of real-world projects in industry and academia and IDE integration into Eclipse and Microsoft VisualStudio.NET makes the first steps a child’s play. Our AspectC++ introduction will start with an example that can be considered the “Hello World” of AOP. It will illustrate the basic language elements like aspects, pointcuts, and advice, which some readers might already know from the AspectJ language. We will then quickly step beyond these AspectJ-like language elements by looking into an AspectC++ version of the well-known observer pattern and into “Generic Advice”. This unique AspectC++ feature combines the power of aspects with generic and generative programming in C++.

Read the paper · More papers on PaperTik