[aspectc-user] cout insertion -- AOP-able?
Craig E. Tull
cetull at lbl.gov
Thu May 6 02:36:46 CEST 2004
We are trying to intercept and override the illegal use of cout in a
large, high energy physics framework. We would like to use this as an
illustration of the power of AOP.
We believe that aspectc's inability to handle templates is the reason
that the following does not work. Are we doing something wrong? If
not...
...Are there any workarounds? What are the prospects of this trivial
example working in a future release?
- Craig
/////////////////////////////////////////////// main.cc
#include <iostream>
int main();
int main()
{
std::cout << "Hello world" << std::endl;
std::cout.operator<<(33);
std::cout.operator<<(std::endl);
return 0;
}
/////////////////////////////////////////////// Cnot.ah
#ifndef __Cnot_h__
#define __Cnot_h__
#include <iostream>
aspect Cnot
{
pointcut inserter() = "% std::cout::operator<<(...)";
public:
advice execution(inserter ()) : void around ()
{
std::cerr << "Sorry, no output allowed!!!" << std::endl;
}
};
#endif // __Cnot_h__
--
-----------------------------------------------------
Craig E. Tull, Ph.D.
National Energy Research Scientific Computing Center
E.O. Lawrence Berkeley National Laboratory
EMail: cetull at lbl.gov WWW: http://iago.lbl.gov/
Phone: (510)486-7253 FAX: (510)486-4004
eFAX: (509)694-8759 Assist: (510)486-6586
More information about the aspectc-user
mailing list