[aspectc-user] Vocabulary question
Olaf Spinczyk
os at aspectc.org
Sat Jun 13 20:35:37 CEST 2009
Hi David,
have a look at the glossary at aosd.net:
http://www.aosd.net/wiki/index.php?title=Glossary. It explains various
AOP-related terms.
Your interpretation of the example does not completely comply to the way
we use AOP vocabulary:
According to aosd.net "Join points are those elements of the programming
language semantics which the aspects coordinate with". This means that
if there is no aspect there is no join point. You could only talk of
*potential* join points. Also note that AspectC++ "code join points" are
defined as events in the control flow of the running program. This means
that a function call or the execution of a function are join points (if
there is some advice for it). In your example the means that the call to
foo() and its execution are distinct (potential) join points. If your
code contained 10 calls of foo() in a loop, there were 10 distinct join
points.
A pointcut is a predicate that is used to match join points. In
AspectC++ match expressions are the building blocks used to construct
pointcuts. For code join points (events in the dynamic control) one
could imagine the pointcut evaluation as a runtime activity. Whenever an
event occurs, e.g. a function call, the pointcut (=predicate) is
evaluated. If it yields 'true', the attached advice is executed. Of
course, as much as possible of the pointcut evaluation is implemented at
compile in order to optimize the code. However, for some pointcut
functions this is not always possible, e.g. that, target, and cflow.
Besides "code join points" AspectC++ also supports "name join points".
These join points are named program entities and defined in a completely
static manner. Class names are an example of name join points. They can
be affected by static advice, i.e. introductions. In the future we might
see also other kinds of static advice.
I hope that this answers your question. The documentation is probably
not precise enough.
Cheers,
Olaf
David Come schrieb:
> Hi all.
> I've a simple and dummy question about vocabulary.
>
> There is a simple code:
>
> //a.h
> aspect Trace
> {
> advice execution("% foo(...)"): before()
> {
> std::cout<<"Before foo"<<std::endl;
> }
> };
> //=========================
>
> //a.cpp
> #include <iostream>
>
> void foo(int i){std::cout<<"foo/int: "<<i<<std::endl;}
> void foo(const std::string& s){std::cout<<"foo/string: "<<s<<std::endl;}
>
> int main()
> {
> foo(4);
> foo("Hi World");
> return 0;
> }
>
> In this exemple , we have:
>
> 2 joins points: void foo(int){} and void foo(const std::string& s){}
> 1 pointcut: (call("% foo(...)") composed by 1 pointcut expression
> (call("% foo(...)"))
>
> If the advice had been advice call("% ...::foo(...)") && within("A"):
> before(), we would have had:
> The same joints points
> 1 poincut composed by 2 poincut expression call("% ...::foo") and
> within("A") which are bind by &&.
>
> Am I right ?
>
> Thanks.
> David Côme.
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> aspectc-user mailing list
> aspectc-user at aspectc.org
> http://www.aspectc.org/mailman/listinfo/aspectc-user
>
More information about the aspectc-user
mailing list