Ejemplo n.º 1
0
Poco::CppParser::Function* XSDGenerator::createGetFct(const Poco::CppParser::Parameter* pParam, Poco::CppParser::Struct* pStruct)
{
	std::string methodName("get");
	methodName.append(pParam->name());
	methodName[3] = (char)std::toupper(methodName[3]);

	// we return either by value or by const &
	std::string decl(createParameterTypeDecl(pParam->declType()));
	decl.append(" ");
	decl.append(methodName);
	Poco::CppParser::Function* pFct = new Poco::CppParser::Function(decl, pStruct);
	pFct->makeConst();
	pFct->makeInline();

	return pFct;
}
void RemoteObjectGenerator::methodStart(const Poco::CppParser::Function* pFuncOld, const CodeGenerator::Properties& properties)
{
	if (_functions.find(pFuncOld->name()) != _functions.end())
		return;
	_functions.insert(pFuncOld->name());
	Poco::CppParser::Function* pFunc = methodClone(pFuncOld, properties);
	pFunc->makeInline(); // impl is just one single line
	Poco::CodeGeneration::CodeGenerator::Properties::const_iterator itSync = properties.find(Poco::CodeGeneration::Utility::SYNCHRONIZED);
	if (itSync != properties.end() && (itSync->second == Utility::VAL_TRUE || itSync->second.empty() || itSync->second == "all" || itSync->second == "remote"))
	{
		_codeInjectors.insert(std::make_pair(pFunc->name(), &RemoteObjectGenerator::syncFwdCodeGen));
	}
	else
	{
		_codeInjectors.insert(std::make_pair(pFunc->name(), &RemoteObjectGenerator::fwdCodeGen));
	}
}
Ejemplo n.º 3
0
Poco::CppParser::Function* XSDGenerator::createSetFct(const Poco::CppParser::Parameter* pParam, Poco::CppParser::Struct* pStruct)
{
	std::string methodName("set");
	methodName.append(pParam->name());
	methodName[3] = (char)std::toupper(methodName[3]);

	// we return either by value or by const &
	std::string decl("void ");
	decl.append(methodName);
	Poco::CppParser::Function* pFct = new Poco::CppParser::Function(decl, pStruct);
	pFct->makeInline();
	// add the one parameter
	Poco::CppParser::Parameter* pParam2 = createParameter(pParam, pFct);
	pFct->addParameter(pParam2);

	return pFct;
}
void RemoteObjectGenerator::checkForEventMembersImpl(const Poco::CppParser::Struct* pStruct)
{
	Poco::CppParser::NameSpace::SymbolTable tbl;
	pStruct->variables(tbl);
	Poco::CppParser::NameSpace::SymbolTable::const_iterator it = tbl.begin();
	Poco::CppParser::NameSpace::SymbolTable::const_iterator itEnd = tbl.end();
	for (; it != itEnd; ++it)
	{
		Poco::CppParser::Variable* pVar = static_cast<Poco::CppParser::Variable*>(it->second);
		const std::string& varType = pVar->declType();
		if (pVar->getAccess() == Poco::CppParser::Variable::ACC_PUBLIC && !(pVar->flags() & Poco::CppParser::Variable::VAR_STATIC))
		{
			if (varType.find("Poco::BasicEvent") == 0 || varType.find("Poco::FIFOEvent") == 0)
			{
				_hasEvents = true;
				_events.push_back(pVar->name());
				_cppGen.addSrcIncludeFile("Poco/RemotingNG/ORB.h");
				_cppGen.addSrcIncludeFile("Poco/Delegate.h");
				// generate a serializer method for that member too
				// call methodStart(const Poco::CppParser::Function* pFuncOld, const CodeGenerator::Properties& methodProperties)
				// convert the basicevent to a private function
				std::string funcDecl("void ");
				std::string fctName = generateEventFunctionName(pVar->name());
				funcDecl.append(fctName);
				std::vector<std::string> templTypes = GenUtility::getResolvedInnerTemplateTypes(pStruct, varType);
				if (templTypes.size() != 1)
					throw Poco::InvalidArgumentException("Illegal remote event param: " + pVar->fullName());
				std::string paramDecl = templTypes[0];
				if (paramDecl != "void")
				{
					paramDecl.append("& data");
				}
				Poco::CppParser::Function* pFunc = new Poco::CppParser::Function(funcDecl, _pStruct);
				pFunc->setAccess(Poco::CppParser::Symbol::ACC_PROTECTED);
				if (paramDecl != "void")
				{
					Poco::CppParser::Parameter* pParam = new Poco::CppParser::Parameter(paramDecl, 0);
					pFunc->addParameter(pParam);
				}
			}
		}
	}
}
void ClientHelperGenerator::structStart(const Poco::CppParser::Struct* pStruct, const CodeGenerator::Properties& properties)
{
	AbstractGenerator::structStart(pStruct, properties);
	// add constructor/destructor
	Poco::CppParser::Function* pConstr = new Poco::CppParser::Function(_pStruct->name(), _pStruct);
	pConstr->setAccess(Poco::CppParser::Symbol::ACC_PUBLIC);
	pConstr->addDocumentation(	" Creates a " + _pStruct->name() + ".");

	Poco::CppParser::Function* pDestr = new Poco::CppParser::Function(std::string("~")+_pStruct->name(), _pStruct);
	pDestr->setAccess(Poco::CppParser::Symbol::ACC_PUBLIC);
	pDestr->addDocumentation(	" Destroys the " + _pStruct->name() + ".");

	// add a method TestProject::IMyClass::Ptr find(const std::string& uri)
	std::string iName (InterfaceGenerator::generateClassName(pStruct));
	Poco::CppParser::Function* pFind = new Poco::CppParser::Function("static " + iName + "::Ptr find", _pStruct);
	pFind->makeInline();
	pFind->addDocumentation(" Return an interface for the service object identified by the given URI.");
	pFind->addDocumentation("");
	pFind->addDocumentation(" Depending on whether the service object has been registered on the same ORB, or not,");
	pFind->addDocumentation(" the ORB will either return a RemoteObject (with forwards calls locally, without the");
	pFind->addDocumentation(" need for serialization/deserialization), or a Proxy.");
	pFind->addDocumentation("");
	pFind->addDocumentation(" The URI must have the following format: <scheme>://<authority>/<protocol>/<typeId>/<objectId>");
	Poco::CppParser::Parameter* pParam1= new Poco::CppParser::Parameter("const std::string& uri", 0);
	pFind->addParameter(pParam1);

	pFind = new Poco::CppParser::Function(iName + "::Ptr findImpl", _pStruct);
	pFind->setAccess(Poco::CppParser::Symbol::ACC_PRIVATE);
	pParam1= new Poco::CppParser::Parameter("const std::string& uri", 0);
	pFind->addParameter(pParam1);

	pFind = new Poco::CppParser::Function("static " + iName + "::Ptr find", _pStruct);
	pFind->makeInline();
	pFind->addDocumentation(" Return a Proxy for the service object identified by the given URI.");
	pFind->addDocumentation("");
	pFind->addDocumentation(" The given protocol name is used to determine the Transport used by");
	pFind->addDocumentation(" the Proxy. This is used for objects identified by URIs that do not");
	pFind->addDocumentation(" follow the standard Remoting URI structure.");
	pParam1= new Poco::CppParser::Parameter("const std::string& uri", 0);
	Poco::CppParser::Parameter* pParam2= new Poco::CppParser::Parameter("const std::string& protocol", 0);
	pFind->addParameter(pParam1);
	pFind->addParameter(pParam2);

	pFind = new Poco::CppParser::Function(iName + "::Ptr findImpl", _pStruct);
	pFind->setAccess(Poco::CppParser::Symbol::ACC_PRIVATE);
	pParam1= new Poco::CppParser::Parameter("const std::string& uri", 0);
	pParam2= new Poco::CppParser::Parameter("const std::string& protocol", 0);
	pFind->addParameter(pParam1);
	pFind->addParameter(pParam2);

	_cppGen.addIncludeFile("Poco/RemotingNG/Identifiable.h");
	_cppGen.addIncludeFile("Poco/RemotingNG/ORB.h");
	Poco::CppParser::Variable* pVar = new Poco::CppParser::Variable("Poco::RemotingNG::ORB* _pORB", _pStruct);
	pVar->setAccess(Poco::CppParser::Symbol::ACC_PRIVATE);

	// the src file will need most includes: for generated RemoteObject+ ProxyFactory, + "Net/DNS.h"
	std::string proxyFactName = ProxyFactoryGenerator::generateQualifiedClassName(nameSpace(), pStruct);
	std::string iFullName (InterfaceGenerator::generateQualifiedClassName(nameSpace(), pStruct));
	Poco::CppParser::NameSpace* pRoot = Poco::CppParser::NameSpace::root();
	const Poco::CppParser::Struct* pPF = dynamic_cast <const Poco::CppParser::Struct*>(pRoot->lookup(proxyFactName));
	const Poco::CppParser::Struct* pI = dynamic_cast <const Poco::CppParser::Struct*>(pRoot->lookup(iFullName));
	poco_check_ptr (pPF);
	poco_check_ptr (pI);

	Poco::CodeGeneration::Utility::handleInclude(pI, _cppGen);
	Poco::CodeGeneration::Utility::handleSrcInclude(pPF, _cppGen);
	_cppGen.addSrcIncludeFile("Poco/SingletonHolder.h");

	// add a method static ClassNameHelper& instance();
	Poco::CppParser::Function* pInstance = new Poco::CppParser::Function("static "+_pStruct->name()+"& instance", _pStruct);
	pInstance->setAccess(Poco::CppParser::Symbol::ACC_PRIVATE);
}
void RemoteObjectGenerator::structStart(const Poco::CppParser::Struct* pStruct, const CodeGenerator::Properties& properties)
{
	AbstractGenerator::structStart(pStruct, properties);
	_codeInjectors.clear();
	// add constructor/destructor
	Poco::CppParser::Function* pConstr = new Poco::CppParser::Function(_pStruct->name(), _pStruct);
	//const Identifiable::ObjectId& oid
	Poco::CppParser::Parameter* pParam1 = new Poco::CppParser::Parameter("const Poco::RemotingNG::Identifiable::ObjectId& oid", pConstr);
	Poco::CppParser::Parameter* pParam2 = new Poco::CppParser::Parameter("Poco::SharedPtr<" + pStruct->fullName() + "> pServiceObject", pConstr);
	pConstr->addParameter(pParam1);
	pConstr->addParameter(pParam2);

	pConstr->addDocumentation(	" Creates a " + _pStruct->name() + ".");

	Poco::CppParser::Function* pDestr = new Poco::CppParser::Function(std::string("virtual ~")+_pStruct->name(), _pStruct);
	pDestr->addDocumentation(	" Destroys the " + _pStruct->name() + ".");

	Poco::CppParser::TypeDef* pTypeDef = new Poco::CppParser::TypeDef("typedef Poco::AutoPtr<" + generateClassName(pStruct) + "> Ptr", _pStruct);
	poco_check_ptr (pTypeDef); // just avoid unused variable warning

	// adds the member var
	_cppGen.addIncludeFile("Poco/SharedPtr.h");
	_cppGen.addIncludeFile("Poco/RemotingNG/RemoteObject.h");
	_cppGen.addIncludeFile("Poco/RemotingNG/Identifiable.h");
	Poco::CppParser::Variable* pVar = new Poco::CppParser::Variable("Poco::SharedPtr<" + pStruct->fullName() + "> _pServiceObject", _pStruct);
	pVar->setAccess(Poco::CppParser::Symbol::ACC_PRIVATE);
	// add a method virtual const Poco::RemotingNG::Identifiable::TypeId& remoting__typeId() const
	Poco::CppParser::Function* pTypeId = new Poco::CppParser::Function("virtual const Poco::RemotingNG::Identifiable::TypeId& remoting__typeId", _pStruct);
	pTypeId->makeConst();
	pTypeId->makeInline();

	if (GenUtility::hasEvents(pStruct))
	{
		Poco::CppParser::Function* pEvents = new Poco::CppParser::Function("virtual std::string remoting__enableEvents", _pStruct);
		Poco::CppParser::Parameter* pParam = new Poco::CppParser::Parameter("Poco::RemotingNG::Listener::Ptr pListener", 0);
		pEvents->addParameter(pParam);
		pParam = new Poco::CppParser::Parameter("bool enable = true", 0);
		pEvents->addParameter(pParam);

		Poco::CppParser::Function* pHasEvents = new Poco::CppParser::Function("virtual bool remoting__hasEvents", _pStruct);
		pHasEvents->makeConst();

		Poco::CppParser::Function* pRemoteEvents = new Poco::CppParser::Function("virtual void remoting__enableRemoteEvents", _pStruct);
		pParam = new Poco::CppParser::Parameter("const std::string& protocol", 0);
		pRemoteEvents->addParameter(pParam);

		std::string inc = Utility::createInclude(_pStruct, _cppGen.usePocoIncludeStyle());
		Poco::replaceInPlace(inc, "RemoteObject", "EventDispatcher");
		_cppGen.addSrcIncludeFile(inc);
	}

	handleParentFunctions(_pStructIn);
	checkForEventMembers(pStruct);
}
void BundleActivatorGenerator::structStart(const Poco::CppParser::Struct* pStruct, const CodeGenerator::Properties& properties)
{
	// we don't care about pStruct, we only care about our service members!
	_pStruct = structClone(pStruct, _className, newBaseClasses(pStruct));
	// member variables
	
	Poco::CppParser::Variable* pVar = new Poco::CppParser::Variable("std::vector<Poco::OSP::ServiceRef::Ptr> _services", _pStruct);
	pVar->setAccess(Poco::CppParser::Symbol::ACC_PRIVATE);
	Poco::CppParser::Variable* pVar2 = new Poco::CppParser::Variable("std::set<std::string> _uris", _pStruct);
	pVar2->setAccess(Poco::CppParser::Symbol::ACC_PRIVATE);
	Poco::CppParser::Variable* pVar3 = new Poco::CppParser::Variable("Poco::RemotingNG::ORB* _pORB", _pStruct);
	pVar3->setAccess(Poco::CppParser::Symbol::ACC_PRIVATE);
	Poco::CppParser::Variable* pVar4 = new Poco::CppParser::Variable("std::set<std::string> _listeners", _pStruct);
	pVar4->setAccess(Poco::CppParser::Symbol::ACC_PRIVATE);
	
	// methods
	// constructor
	{
		Poco::CppParser::Function* pConstr = new Poco::CppParser::Function(_pStruct->name(), _pStruct);
		pConstr->setAccess(Poco::CppParser::Symbol::ACC_PUBLIC);
		pConstr->addDocumentation(" Creates a " + _pStruct->name() + ". Initializes the bundle.");
	}
	//destructor
	{
		Poco::CppParser::Function* pDestr = new Poco::CppParser::Function(std::string("~")+_pStruct->name(), _pStruct);
		pDestr->setAccess(Poco::CppParser::Symbol::ACC_PUBLIC);
		pDestr->addDocumentation(" Destroys the " + _pStruct->name() + ".");
	}

	// void start(BundleContext::Ptr pContext)
	{
		Poco::CppParser::Function* pStart = new Poco::CppParser::Function("void start", _pStruct);
		pStart->addDocumentation(" Starts the services inside the bundle.");
		Poco::CppParser::Parameter* pParam1= new Poco::CppParser::Parameter("Poco::OSP::BundleContext::Ptr pContext", 0);
		pStart->addParameter(pParam1);
	}

	// void stop(BundleContext::Ptr pContext)
	{
		Poco::CppParser::Function* pStop = new Poco::CppParser::Function("void stop", _pStruct);
		pStop->addDocumentation(" Stops the services inside the bundle.");
		Poco::CppParser::Parameter* pParam1= new Poco::CppParser::Parameter("Poco::OSP::BundleContext::Ptr pContext", 0);
		pStop->addParameter(pParam1);
	}
	
	// Poco::RemotingNG::ORB& orb()
	{
		Poco::CppParser::Function* pORB = new Poco::CppParser::Function("Poco::RemotingNG::ORB& orb", _pStruct);
		pORB->addDocumentation(" Returns a reference to the Remoting ORB.");
	}

	//protected:
	//server methods: add always
	{
		// std::pair<std::string, Poco::OSP::ServiceRef::Ptr> 
		// registerRemoteService(BundleContext::Ptr pContext, Poco::OSP::Service::Ptr pService, const std::string& listener, const std::string& serviceName, Poco::OSP::Properties props = Poco::OSP::Properties())
		{
			Poco::CppParser::Function* pReg = new Poco::CppParser::Function("std::pair<std::string, Poco::OSP::ServiceRef::Ptr> registerRemoteService", _pStruct);
			pReg->setAccess(Poco::CppParser::Symbol::ACC_PROTECTED);
			pReg->addDocumentation(" Registers the service with the ORB and at the ServiceRegistry the bundle. Returns the Remoting URI and the serviceRef.");
			Poco::CppParser::Parameter* pParam0= new Poco::CppParser::Parameter("Poco::OSP::BundleContext::Ptr pContext", 0);
			Poco::CppParser::Parameter* pParam1= new Poco::CppParser::Parameter("Poco::OSP::Service::Ptr pService", 0);
			Poco::CppParser::Parameter* pParam2= new Poco::CppParser::Parameter("const std::string& listener", 0);
			Poco::CppParser::Parameter* pParam3= new Poco::CppParser::Parameter("const std::string& serviceName", 0);
			Poco::CppParser::Parameter* pParam4= new Poco::CppParser::Parameter("Poco::OSP::Properties props = Poco::OSP::Properties()", 0);

			pReg->addParameter(pParam0);
			pReg->addParameter(pParam1);
			pReg->addParameter(pParam2);
			pReg->addParameter(pParam3);
			pReg->addParameter(pParam4);
		}

		// std::string registerRemoteObject(Poco::RemotingNG::RemoteObject::Ptr pObj, const std::string& listener)
		{
			Poco::CppParser::Function* pReg = new Poco::CppParser::Function("std::string registerRemoteObject", _pStruct);
			pReg->setAccess(Poco::CppParser::Symbol::ACC_PROTECTED);
			pReg->addDocumentation(" Registers the service with the ORB only. Returns the Remoting URI for the remote object.");
			Poco::CppParser::Parameter* pParam1= new Poco::CppParser::Parameter("Poco::RemotingNG::RemoteObject::Ptr pObj", 0);
			Poco::CppParser::Parameter* pParam2= new Poco::CppParser::Parameter("const std::string& listener", 0);
	
			pReg->addParameter(pParam1);
			pReg->addParameter(pParam2);
		}

		// std::string registerListener(Listener::Ptr pListener)
		{
			Poco::CppParser::Function* pReg = new Poco::CppParser::Function("std::string registerListener", _pStruct);
			pReg->setAccess(Poco::CppParser::Symbol::ACC_PROTECTED);
			pReg->addDocumentation(" Registers the listener at the ORB. Returns the id of the endpoint. listener will be automatically unregistered with bundle stop");
			Poco::CppParser::Parameter* pParam1 = new Poco::CppParser::Parameter("Poco::RemotingNG::Listener::Ptr pListener", 0);
			pReg->addParameter(pParam1);
		}

		// Poco::OSP::ServiceRef::Ptr registerService(Poco::OSP::BundleContext::Ptr pContext, const std::string& serviceName, Poco::OSP::Service::Ptr pService, Poco::OSP::Properties props = Poco::OSP::Properties())
		{
			Poco::CppParser::Function* pReg = new Poco::CppParser::Function("Poco::OSP::ServiceRef::Ptr registerService", _pStruct);
			pReg->setAccess(Poco::CppParser::Symbol::ACC_PROTECTED);
			pReg->addDocumentation(" Registers the service at the serviceRegistry only. Stores the serviceRef for auto unregister");

			Poco::CppParser::Parameter* pParam0= new Poco::CppParser::Parameter("Poco::OSP::BundleContext::Ptr pContext", 0);
			Poco::CppParser::Parameter* pParam1= new Poco::CppParser::Parameter("const std::string& serviceName", 0);
			Poco::CppParser::Parameter* pParam2= new Poco::CppParser::Parameter("Poco::OSP::Service::Ptr pService", 0);
			Poco::CppParser::Parameter* pParam3= new Poco::CppParser::Parameter("Poco::OSP::Properties props = Poco::OSP::Properties()", 0);

			pReg->addParameter(pParam0);
			pReg->addParameter(pParam1);
			pReg->addParameter(pParam2);
			pReg->addParameter(pParam3);
		}

		// void unregisterRemoteService(Poco::OSP::BundleContext::Ptr pContext, const std::string& uri, Poco::OSP::ServiceRef::Ptr pService)
		{
			Poco::CppParser::Function* pReg = new Poco::CppParser::Function("void unregisterRemoteService", _pStruct);
			pReg->setAccess(Poco::CppParser::Symbol::ACC_PROTECTED);
			pReg->addDocumentation(" Unregisters the service at the ORB and at the ServiceRegistry.");

			Poco::CppParser::Parameter* pParam0= new Poco::CppParser::Parameter("Poco::OSP::BundleContext::Ptr pContext", 0);
			Poco::CppParser::Parameter* pParam1= new Poco::CppParser::Parameter("const std::string& uri", 0);
			Poco::CppParser::Parameter* pParam2= new Poco::CppParser::Parameter("Poco::OSP::ServiceRef::Ptr pService", 0);

			pReg->addParameter(pParam0);
			pReg->addParameter(pParam1);
			pReg->addParameter(pParam2);
		}

		// void unregisterRemoteObject(const std::string& uri)
		{
			Poco::CppParser::Function* pReg = new Poco::CppParser::Function("void unregisterRemoteObject", _pStruct);
			pReg->setAccess(Poco::CppParser::Symbol::ACC_PROTECTED);
			pReg->addDocumentation(" Unregisters the service at the ORB only.");

			Poco::CppParser::Parameter* pParam1= new Poco::CppParser::Parameter("const std::string& uri", 0);

			pReg->addParameter(pParam1);
		}

		// void unregisterService(Poco::OSP::BundleContext::Ptr pContext, Poco::OSP::ServiceRef::Ptr pService)
		{
			Poco::CppParser::Function* pReg = new Poco::CppParser::Function("void unregisterService", _pStruct);
			pReg->setAccess(Poco::CppParser::Symbol::ACC_PROTECTED);
			pReg->addDocumentation(" Unregisters the service at the serviceRegistry only.");

			Poco::CppParser::Parameter* pParam0= new Poco::CppParser::Parameter("Poco::OSP::BundleContext::Ptr pContext", 0);
			Poco::CppParser::Parameter* pParam1= new Poco::CppParser::Parameter("Poco::OSP::ServiceRef::Ptr pService", 0);

			pReg->addParameter(pParam0);
			pReg->addParameter(pParam1);
		}

		// void unregisterListener(const std::string& listener)
		{
			Poco::CppParser::Function* pReg = new Poco::CppParser::Function("void unregisterListener", _pStruct);
			pReg->setAccess(Poco::CppParser::Symbol::ACC_PROTECTED);
			pReg->addDocumentation(" Unregisters the listener at the ORB.");
			Poco::CppParser::Parameter* pParam1 = new Poco::CppParser::Parameter("const std::string& listener", 0);
			pReg->addParameter(pParam1);
		}

		// void unregisterAll(BundleContext::Ptr pContext)
		{
			Poco::CppParser::Function* pReg = new Poco::CppParser::Function("void unregisterAll", _pStruct);
			pReg->setAccess(Poco::CppParser::Symbol::ACC_PROTECTED);
			pReg->addDocumentation(" Unregisters all services and remoteobjects. Automatically called by stop method.");
			Poco::CppParser::Parameter* pParam1= new Poco::CppParser::Parameter("Poco::OSP::BundleContext::Ptr pContext", 0);
			pReg->addParameter(pParam1);
		}

		//void setupRemotingOSP()
		{
			Poco::CppParser::Function* pReg = new Poco::CppParser::Function("void setupRemotingOSP", _pStruct);
			pReg->setAccess(Poco::CppParser::Symbol::ACC_PROTECTED);
			pReg->addDocumentation(" Initializes skeletons, proxyfactories and servicefactories.");
			Poco::CppParser::Parameter* pParam0= new Poco::CppParser::Parameter("Poco::OSP::BundleContext::Ptr pContext", 0);
			pReg->addParameter(pParam0);
		}

		//void shutdownRemotingOSP()
		{
			Poco::CppParser::Function* pReg = new Poco::CppParser::Function("void shutdownRemotingOSP", _pStruct);
			pReg->setAccess(Poco::CppParser::Symbol::ACC_PROTECTED);
			pReg->addDocumentation(" Deinitializes skeletons, proxyfactories and servicefactories for this bundle.");
			Poco::CppParser::Parameter* pParam0= new Poco::CppParser::Parameter("Poco::OSP::BundleContext::Ptr pContext", 0);
			pReg->addParameter(pParam0);
		}

		// includes
		_cppGen.addIncludeFile("Poco/OSP/ServiceRef.h");
		_cppGen.addIncludeFile("Poco/RemotingNG/ORB.h");
		_cppGen.addSystemIncludeFile("vector");
		_cppGen.addSystemIncludeFile("set");
		_cppGen.addSystemIncludeFile("algorithm");
	} // _serverMode


	// includes
	_cppGen.addIncludeFile("Poco/OSP/BundleActivator.h");
	_cppGen.addIncludeFile("Poco/OSP/ServiceRef.h");
	
	_cppGen.addIncludeFile("Poco/RemotingNG/Identifiable.h");

	// src includes
	
	// we need to register the proxyfactories for all structs
	std::vector<BundleService>::const_iterator it = _services.begin();
	Poco::CppParser::NameSpace* pRoot = Poco::CppParser::NameSpace::root();
	for (; it != _services.end(); ++it)
	{
		if (it->clientCode)
		{
			std::string fullName = ProxyFactoryGenerator::generateQualifiedClassName(nameSpace(), it->pStruct);
			const Poco::CppParser::Struct* pF = dynamic_cast <const Poco::CppParser::Struct*>(pRoot->lookup(fullName));
			if (!pF)
				throw Poco::NotFoundException("didn't find proxyfactory for class " + it->pStruct->fullName());
			Poco::CodeGeneration::Utility::handleSrcInclude(pF, _cppGen);
		}
		if (it->serverCode)
		{
			std::string fullName = SkeletonGenerator::generateQualifiedClassName(nameSpace(), it->pStruct);
			const Poco::CppParser::Struct* pF = dynamic_cast <const Poco::CppParser::Struct*>(pRoot->lookup(fullName));
			if (!pF)
				throw Poco::NotFoundException("didn't find skeleton for class " + it->pStruct->fullName());
			Poco::CodeGeneration::Utility::handleSrcInclude(pF, _cppGen);
		}
	}
	
	_cppGen.addSrcIncludeFile("Poco/RemotingNG/URIUtility.h");
	_cppGen.addSrcIncludeFile("Poco/RemotingNG/RemoteObject.h");
	_cppGen.addSrcIncludeFile("Poco/OSP/OSPException.h");
	_cppGen.addSrcIncludeFile("Poco/OSP/ServiceRegistry.h");
	_cppGen.addSrcIncludeFile("Poco/ClassLibrary.h");
}
Ejemplo n.º 8
0
void XSDGenerator::deepCopyMembers(const Poco::CppParser::Struct* pIn, Poco::CppParser::Struct* pOut)
{
	// deep copy all variables and functions, exluding constructor/destructor
	Poco::CppParser::Struct::BaseIterator itB = pIn->baseBegin();
	Poco::CppParser::Struct::BaseIterator itBEnd = pIn->baseEnd();
	for (; itB!= itBEnd; ++itB)
	{
		if (itB->pClass)
			deepCopyMembers(itB->pClass, pOut);
	}
	// handle members
	Poco::CppParser::NameSpace::SymbolTable members;
	pIn->variables(members);
	Poco::CppParser::NameSpace::SymbolTable::const_iterator it = members.begin();
	Poco::CppParser::NameSpace::SymbolTable::const_iterator itEnd = members.end();
	for (; it != itEnd; ++it)
	{
		Poco::CppParser::Variable* pVar = static_cast<Poco::CppParser::Variable*>(it->second);
		Poco::CppParser::Variable* pCpyVar = new Poco::CppParser::Variable(pVar->declaration(), pOut);
		pCpyVar->setAccess(pVar->getAccess());
		pCpyVar->setAttributes(pVar->getAttributes());
	}
	// handle methods
	members.clear();
	Poco::CppParser::Struct::Functions fcts;
	pIn->methods(Poco::CppParser::Symbol::ACC_PUBLIC, fcts);
	Poco::CppParser::Struct::Functions::const_iterator itt = fcts.begin();
	Poco::CppParser::Struct::Functions::const_iterator ittEnd = fcts.end();
	for (; itt != ittEnd; ++itt)
	{
		Poco::CppParser::Function* pFct = static_cast<Poco::CppParser::Function*>(*itt);
		if (!pFct->isConstructor() && ! pFct->isDestructor())
		{
			Poco::CppParser::Function* pCpyFct = new Poco::CppParser::Function(pFct->declaration(), pOut);
			pCpyFct->setAccess (pFct->getAccess());
			addDocumentation(pFct, pCpyFct);
			pCpyFct->setAttributes(pFct->getAttributes());
			if (pFct->isConst())
				pCpyFct->makeConst();

			Poco::CppParser::Function::Iterator itF = pFct->begin();
			Poco::CppParser::Function::Iterator itFEnd = pFct->end();

			for (; itF != itFEnd; ++itF)
			{
				std::string decl = Poco::CodeGeneration::Utility::resolveParamDecl(pIn, *itF);
				if ((*itF)->hasDefaultValue())
				{
					decl.append(" = ");
					decl.append(Poco::CodeGeneration::Utility::resolveType(_pStructIn, (*itF)->declType()));
					decl.append("(");
					decl.append((*itF)->defaultValue());
					decl.append(")");
				}
				
				Poco::CppParser::Parameter* pParam = new Poco::CppParser::Parameter(decl, pCpyFct);
				
				pCpyFct->addParameter(pParam);
			}
		}
			
	}
}