[aspectc-user] slice-class
Panu Bloigu
panu.bloigu at gmail.com
Wed Jun 18 16:11:44 CEST 2008
Hello.
I'm not sure if this helps, but check out the include guards in your
aspect headers; both aspects are protected by the same include guards
(#ifndef __TEST_AH__). The aspect header Test2.ah should probably have
something like #ifndef __TEST2_AH__.
Anyway, I tried your code with proper include guards and weaving
resulted in both classes containing both of the methods: print() and
print2().
-- Panu.
J. Liebig wrote:
> Hi,
>
> I've a question concerning advices with slice-classes.
> Conside the following example:
>
> class FOO_A {
> public:
> const char * _st;
> FOO_A() :
> _st("foo - a") {
> }
> };
>
> class FOO_B {
> public:
> const char * _st;
> FOO_B() :
> _st("foo - b") {
> }
> };
>
>
> I'm using the following aspect to weave a static
> introduction into both classes.
>
> #ifndef __TEST_AH__
> #define __TEST_AH__
> #
> #include <iostream>
> using namespace std;
>
> aspect Bar1 {
> pointcut iprint() = "FOO_A" || "FOO_B";
>
> advice iprint() : slice class {
> public:
> void print() {
> cout << _st << endl;
> return;
> }
> };
> };
> #endif // __TEST_AH__
>
>
> If I want to add a second aspect called Test2.ah
> to it, this ones doesn't appear in the resultcode:
> #ifndef __TEST_AH__
> #define __TEST_AH__
> #
> #include <iostream>
> using namespace std;
>
> aspect Bar2 {
> pointcut iprint2() = "FOO_A" || "FOO_B";
>
> advice iprint2() : slice class {
> public:
> void print2() {
> cout << "in bar2" << endl;
> return;
> }
> };
> };
> #endif // __TEST_AH__
>
>
> According to the output of the ac++ compiler the file
> Test2.ah is also used. But now code is inserted into
> class FOO_A or class FOO_B. I found out that the order
> of weaving aspects depends on the alphanumeric order
> of the files holding the aspects.
> How can I fix the problem above?
>
> best regards,
> jl
>
>
> _______________________________________________
> 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