[aspectc-user] Re: Error "1><anonymous unit>(1): error: invalid declaration near token `:'"
Luigi 'Comio' Mantellini
luigi.mantellini at gmail.com
Fri Jan 12 00:53:52 CET 2007
I have deleted the baseclass injection... now the code is ok... in any
case I haven't understood the problem...
ciao
luigi
2007/1/12, Luigi 'Comio' Mantellini <luigi.mantellini at gmail.com>:
> Dear all,
>
> I'm trying to write a AspectC++ version of Proxy Pattern, but I have
> the following error:
>
> 1><anonymous unit>(1): error: invalid declaration near token `:'
>
> I don't know where I have made the mistake... can you help me to
> understand the error?
> (I'm using the trial version of AspectC++ plugin for VC).
>
> Thanks in advance
>
> luigi
>
> (the code...)
>
> [code]
> # aabstractproxy.ah
> #ifndef __AABSTRACTPROXY_H__
> #define __AABSTRACTPROXY_H__
>
> #pragma once;
>
> aspect AAbstractProxy {
>
> protected:
> pointcut virtual callers() = "%"; // Chiamanti che devono
> attraversare il proxy
> pointcut virtual requests() = 0; // Metodi da monitorare
> pointcut virtual realsubjects() = 0; // Classi che effettuano
>
> private:
> advice realsubjects(): slice class: public Subject {};
>
> //
> public:
> advice requests() /*&& target(callers()) && that(realsubjects()) */ :
> around() {
> if (! isProxyProtected(/*tjp*/) ) {
> tjp->proceed();
> } else {
> handleProxyProtection(/*tjp*/);
> }
> };
>
> protected:
> virtual bool isProxyProtected(/*JoinPoint *tjp*/) = 0;
> virtual void handleProxyProtection(/*JoinPoint *tjp*/) {
> return;
> };
> };
>
> #endif
> [/code]
>
> [code]
> // arequestblocking.h
>
> #ifndef __AREQUESTBLOCKING_H__
> #define __AREQUESTBLOCKING_H__
>
> #pragma once
>
> #include <iostream>
>
> #include "aabstractproxy.ah"
>
> using namespace std;
>
> aspect ARequestBlocking: public AAbstractProxy {
>
> protected:
> pointcut virtual realsubjects() = "OutputImplementation";
> pointcut virtual requests() = call("% unsafeRequest(...)");
> pointcut virtual callers() = "ProxyTestClass";
>
> bool isProxyProtected(/*JoinPoint *tjp*/) {
> cout << "[RequestBlocking] intercepting unsafe " << endl;
> return true;
> };
> };
>
> #endif
> [/code]
>
> [code]
> #ifndef __TESTPROXY_H__
> #define __TESTPROXY_H__
>
> #pragma once
>
> #include <iostream>
> #include "aabstractproxy.ah"
> #include "requestblocking.ah"
>
> using namespace std;
>
> class OutputImplementation {
>
> public:
> void safeRequest(char *s) {
> cout << "[OutputImplementation.safeRequest()]: " << s << endl;
> }
>
> void regularRequest(char *s) {
> cout << "[OutputImplementation.regularRequest()]: " << s << endl;
> }
>
> void unsafeRequest(char *s) {
> cout << "[OutputImplementation.unsafeRequest()]: " << s << endl;
> }
> };
>
>
> class ProxyTestMain {
>
> public: starttest() {
>
> OutputImplementation *real = new OutputImplementation();
>
> cout << "\n===> Issuing SAFE request..." << endl;
> real->safeRequest("Safe Reqeust");
> cout << "\n===> Issuing REGULAR request..." << endl;
> real->regularRequest("Normal Request");
> cout << "\n===> Issuing UNSAFE request..." << endl;
> real->unsafeRequest ("Unsafe Request");
> cout << "\n===> Issuing SAFE request..." << endl;
> real->safeRequest("Safe Reqeust");
> cout << "\n===> Issuing REGULAR request..." << endl;
> real->regularRequest("Normal Request");
> cout << "\n===> Issuing UNSAFE request..." << endl;
> real->unsafeRequest ("Unsafe Request");
> }
> };
>
> void testProxy() {
> ProxyTestMain *m=new ProxyTestMain();
> m->starttest();
> cout << "Start Proxt Pattern testing..." << endl;
> }
>
> #endif
> [/code]
>
>
>
> --
> Luigi 'Comio' Mantellini
>
> The three laws of users:
>
> 1. A user may not injure a sysadmin, or through inaction,
> allow a sysadmin to come to harm.
> 2. A user must obey the orders given it by sysadmins except
> where such orders would conflict with the First Law.
> 3. A user must protect its own existence as long as such
> protection does not conflict with the First or Second Law.
>
--
Luigi 'Comio' Mantellini
The three laws of users:
1. A user may not injure a sysadmin, or through inaction,
allow a sysadmin to come to harm.
2. A user must obey the orders given it by sysadmins except
where such orders would conflict with the First Law.
3. A user must protect its own existence as long as such
protection does not conflict with the First or Second Law.
More information about the aspectc-user
mailing list