[aspectc-user] Multiple inheritance of aspects.

Panu Bloigu panu.bloigu at mbnet.fi
Mon Nov 27 13:52:52 CET 2006


Hello.

Olaf, accept my apologies for making you to get this message twice. I
realized that I didn't cc to the list while replying your to post. Won't
happen again.

> base aspects have to be "abstract", i.e. they have to have at least one
> pure virtual pointcut or function.

This might be a silly question, but do inherited pure virtual methods and/or
pcs count here? In regular C++, if you have a class that inherits an
abstract class without defining all of the inherited pure virtual methods,
is an abstact class in it self and cannot be instantiated.

See, I have an abstract aspect A which has some pure virtual pcs and pure
virtual methods. Then I have aspects B and C, both of which inherit A and
define some (different) members of A. Finally, I have aspect D, which
ihnerits both B and C (and, indirectly, A) and defines any pcs and methods
that were inherited from A but left undefined in B and C. However, I can not
make it to work. The make system does not give any error, but still the
aspects (or should I say the combination of apects A, B, C, and D) don't get
applied. I'm totally at loss here and it would be great if you could give me
some hint about what is going on here. The aspects I have are the following:

===========
File: A.ah
===========
#ifndef A_AH_
#define A_AH_
aspect A
{
        pointcut virtual pc() = 0;
        pointcut virtual act() = 0;

public:
        virtual void on_enter() = 0;
        virtual void on_exit() = 0;
        virtual void commit() = 0;

        advice act() : around()
        {
                on_enter();
                commit();
                on_exit();
        }
};
#endif /*A_AH_*/

===========
File B.ah
===========
#ifndef B_AH_
#define B_AH_
#include "A.ah"
aspect B : public A
{
        pointcut act() = execution(pc());
};
#endif /*B_AH_*/

===========
File C.ah
===========
#ifndef C_AH_
#define C_AH_
#include <iostream>
#include "A.ah"
aspect C : public A
{
public:
        void on_enter()
        {
                std::cout<<"on enter.\n";
        }
        void on_exit()
        {
                std::cout<<"on exit.\n";
        }
        void commit(){}
};
#endif /*C_AH_*/

===========
File D.ah
===========
#ifndef D_AH_
#define D_AH_
#include "B.ah"
#include "C.ah"
aspect D : public B, public C
{
        pointcut pc() = "% ...::%(...)";
};
#endif /*D_AH_*/

Like I said, the make process goes along just fine without any errors, but
the aspects are not applied. I've also tried declaring A as a virtual base
(i.e. "aspect B : public virtual A {/*...*/};") for B and C but it doesn't
change the outcome. Any and all help would be greatly appreciated here.

Panu.





More information about the aspectc-user mailing list