C++ 中的面向方面编程 - 当前支持的替代方案 [英] Aspect Oriented Programming in C++ - Current supported alternatives

查看:19
本文介绍了C++ 中的面向方面编程 - 当前支持的替代方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我之前在 Java 中使用过 AspectJ,最近我考虑检查 C++ 语言存在哪些可能性.

I have used AspectJ before for Java, and I recently have thought about checking which possibilities exist for the C++ language.

我听说过 AspectC++,但与 AspectJ 不同,AspectC++ 似乎被放弃了,因为最新版本根据他们的网站,日期为 2005 年 12 月 21 日.

I heard about AspectC++, but unlike AspectJ, AspectC++ seems to be abandoned in the sense that the latest release dates from 21.12.2005, according to their website.

我想知道现在是否有任何更新的替代品目前正在使用或开发,并且仍然受到支持并不断更新和演变,以及是否有任何此类替代品碰巧有某种集成插件以便于在内部使用Eclipse IDE.

I wonder if there are any more recent alternatives currently being used or developed nowadays, and which are still supported and having continuous updates and evolution, and also if any of such alternatives happen to have some sort of integration plugin for easier use within the Eclipse IDE.

如果没有,在考虑使用 AspectC++ 之前,是否有一些最有问题的限制是我应该注意的?

In the event that there aren't, are there some most problematic limitations from AspectC++ that I should be aware of before considering to use it?

提前致谢.

推荐答案

AspectC++ 是值得一试的,但大学项目通常不会继续下去,因为产品往往不够健壮,最初的学者失去兴趣,而构建的研究生它继续前进.当我在 2010 年写这个答案时,情况似乎就是这样.令我惊讶的是,在 2017 年,AspectC++ 似乎仍在积极发展.如果您想要只是 C++ 方面,这可能值得一看.

AspectC++ was a worthy try but university projects don't often continue because the products tend not to be robust, the original academics lose interest and the graduate students that build it move on. That appeared to be case when I wrote this answer in 2010. To my surprise in 2017, AspectC++ still seems to have active development. If you want just aspects for C++, this is probably worth a look.

面向方面的编程只是一种特殊的程序转换(找到匹配这个条件的地方('切入点'),然后对那个地方的代码执行此操作").所以,如果你有一个程序转换工具,你可以很容易地模拟 AOP.要在 C++ 上进行转换,您需要强大的 C++ 前端以及转换和重新生成代码的能力.OpenC++ 是一个进行 C++ 转换的项目,其中转换被编码为具有程序性 AST 修改的程序性 AST-walks.一个特定的问题与 OpenC++ 处理哪种 C++ 方言有关;特别是,我不确定 OpenC++ 是否处理了 C+ 的模板或完整的通用方言(GCC、MS);但是我没有直接使用它的经验,只是对此类工具的狂热爱好者.

Aspect-oriented programming is a just a special kind of program transformation ("find places that match this condition ('pointcut') and do this to the code at that place"). So, if you have a program transformation tool, you can emulate AOP pretty easily. To do transformation on C++ you need a strong C++ front end and as well as ability to transform and regenerate code. OpenC++ was a project to do C++ transformations, where the transformations are coded purely as procedural AST-walks with procedural AST modifications. A particular issue had to do with which dialect of C++ was handled by OpenC++; in particular, I'm not sure OpenC++ handled templates or full common dialects (GCC, MS) of C+; however I have no direct experience with it, just a keen aficionado of such tools.

我们的 DMS 软件再造工具包是一个通用的程序转换语言定义.它具有针对 C++ 的 GCC 和 MS 方言的可靠定义.您可以像 OpenC++ 那样在程序上实现程序转换,或者更方便的是,您可以编写源到源模式导向的转换(或者更常见的是,将它们混合以实现复杂的效果).DMS已被用于大规模C++代码的大规模重构(参见 案例研究:通过自动程序转换重新设计 C++ 组件模型).DMS 得到积极维护,但它是商业性的.

Our DMS Software Reengineering Toolkit is a general purpose program transformation parameterized by language definitions. It has robust definitions for GCC and MS dialects of C++. You can implement program transformations procedurally as OpenC++ does, or more conveniently you can write source-to-source pattern-directed transformations (or more usually, mix these to achieve complex effects). DMS has been used to carry out massive restructuring of large scale C++ codes (see Case study: Re-engineering C++ component models via automatic program transformation ). DMS is actively maintained, but it is commercial.

编辑 2015 年 3 月:现在在 GCC 和 MS 方言中使用 C++14.

EDIT March, 2015: Now does C++14 in GCC and MS dialects.

编辑 2017 年 7 月:现在在 GCC 和 MS 方言中使用 C++17.

EDIT July 2017: Now does C++17 in GCC and MS dialects.

这篇关于C++ 中的面向方面编程 - 当前支持的替代方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆