[aspectc-user] Using aspects on template classes
Frederic Saunier
frederic.saunier at silicomp.com
Fri Mar 10 09:41:28 CET 2006
Hi,
When trying using aspects on template classes, I got troubles:
- to match the methods of template class as pointcuts.
Do I need to specific a wildcard or anything else to match the template
parameters ? Can I eventually do it ?
- to match constructor of template class: "ac++ -v 9 --real-instances"
identifies the constrcutor as a joint point but ends up with a segment
violation
Here is a short sample that reproduces the behavior. Any hints ?
Best regards,
-- Frederic
---- Aspect.ah ----
#ifndef __SIMPLE_ASPECT__
#define __SIMPLE_ASPECT__
#include <iostream>
aspect Tracer {
pointcut methods() = execution("% ...::container(...)");
pointcut instances() = construction("container") || destruction("container");
advice methods() : before() {
std::cout << "Entering> " << JoinPoint::signature() << std::endl;
}
advice methods() : after() {
std::cout << "<Exitting " << JoinPoint::signature() << std::endl;
}
advice instances() : before() {
std::cout << "CTOR" << std::endl;
}
advice instances() : after() {
std::cout << "DTOR" << std::endl;
}
};
#endif // __SIMPLE_ASPECT__
// EOF
---- sample.cpp ----
#include <iostream>
template <typename INDEX, typename DATA>
class container {
public:
container(unsigned int size);
~container();
void put(INDEX at, DATA value);
DATA get(INDEX at);
};
template <typename INDEX, typename DATA>
container<INDEX,DATA>::container(unsigned int size) {
std::cout << "In Constructor" << std::endl;
}
template <typename INDEX, typename DATA>
container<INDEX,DATA>::~container() {
std::cout << "In Destructor" << std::endl;
}
template <typename INDEX, typename DATA>
DATA
container<INDEX,DATA>::get(INDEX at) {
std::cout << "In Get" << std::endl;
}
template <typename INDEX, typename DATA>
void
container<INDEX,DATA>::put(INDEX at, DATA value) {
std::cout << "In Put" << std::endl;
}
int main(int argc, char *argv[]) {
container<unsigned int,int> container_instance(0x1000);
container<unsigned int,int> * aux_container_prt = new container<unsigned
int,int> (0x100);
}
// EOF
--
Open WebMail Project (http://openwebmail.org)
More information about the aspectc-user
mailing list