Aop
Target
to do some additional task (eg logging) before enter and after exit of specified functions, in a generic way
Analysis
there is a methodology called AOP(Aspect Oriented Programming)
AOP is mature in Java, eg https://www.ifi.uzh.ch/dam/jcr:764702da-842f-49fa-b475-5e1e148c03f2/9_AOP.pdf
however not in C++there is no good techniques or tools to do AOP
Methods
- Pure C++
- traditional C++: Proxy pattern https://lisha.ufsc.br/teaching/sce/aop_with_c++.pdf
- This link implements a several Aspect for a Queue class, eg Locking_Aspect , Counting_Aspect
- C++11 http://vitiy.info/c11-functional-decomposition-easy-way-to-do-aop/
- this post implements several kinds
Aspect
in C++11, eg for the logging aspect
- this post implements several kinds
- traditional C++: Proxy pattern https://lisha.ufsc.br/teaching/sce/aop_with_c++.pdf
-
By Tools: AOP s difficult for C++, As the C++ language itself not support AOP. There is some tools by implementing
preprocessing
in C++ source codes, but they are not actively maintained- AspectC++ http://modularity.info/conference/2005/archive/AspectCpp-talk.pdf
- 上一篇 Aspectc++试用
- 下一篇 Boost编译