[aspectc-user] Namespace problems

Liu YueChang liuyuechang at gmail.com
Sun Apr 1 12:46:45 CEST 2007


Hello everybody

Could anybody tell me how can I solve this problem? The error message
of this aspect c++ is so confused.

I just try to use aspect c++ to write factory pattern. But I can not
give the correct matching pattern because of the namespace. I think
the namespase is a big problem in Aspect C++. It always give very blur
error message.

If I compile the following sourcecode, it said "error: invalid
declaration near token `:'".

The error just occur at CConcreateFactory1::CConcreateFactory1()

Also, if I give a constructor inside the std::CAbstract, the compiler
will report that the constructor name is invalid. I really confused.

I am using aspect c++ with MinGW

Thanks a lot.

Richard

The following is my source code:


////////////////////////////////////////////////////////////AAbstractFactory.ah
#ifndef __AABSTRACTFACTORY_AH__
#define __AABSTRACTFACTORY_AH__
#include "CConcreateFactory1.h"
#include "CAbstractProductA.h"
#include "CAbstractProductB.h"

aspect AAbstractFactory {
	advice "std::CConcreateFactory%" : slice class : public std::CAbstract {
		public:
		virtual std::CAbstractProductA createProductA() = 0;
		virtual std::CAbstractProductB createProductB() = 0;
	};
};
#endif

////////////////////////////////////////////////////////////CConcreateFactory1.cpp
#include "CConcreateFactory1.h"

namespace std
{

CConcreateFactory1::CConcreateFactory1()
{
	cout << "construction of CConcreateFactory1" << endl;
}

CConcreateFactory1::~CConcreateFactory1()
{
	cout << "destruction of CConcreateFactory1" << endl;
}

CAbstractProductA* CConcreateFactory1::createProductA()
{
    return new CProductA1();
}

CAbstractProductB* CConcreateFactory1::createProductB()
{
    return new CProductB1();
}
}



More information about the aspectc-user mailing list