Map

本文介绍了一种在C++程序中通过动态链接库(DLL)加载运动模型的方法,并展示了如何根据不同的运动模型类型(如DLL文件或Matlab)进行初始化的过程。重点包括使用迭代器遍历存储运动模型参数的map容器、加载DLL文件、解析内部函数以及针对Matlab环境的特殊处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

 

//.h

std::map<int,MinesSourParam> DigitModlMines,MinesPreStore;   //实体

 

//.cpp
//获取运动模型dll函数
void DigitalMinesNode::InitDLLFunc()
{
	std::map<int,MinesSourParam>::iterator it_ = DigitModlMines.begin();
	for (;it_ != DigitModlMines.end();++it_)
	{
		if (it_->second.FuncType == AttackDLL)
		{
			QString FilePath = QString::fromStdString(it_->second.AttackFilePath);
			FilePath = exetopath+"/"+FilePath;
			//找到DLL文件
			//QLibrary myLib("DigitalMinesDll.dll");
			QLibrary myLib(FilePath);
			if (myLib.load())
			{
				//从DLL中找到地雷攻击函数
				MinesObjectFun = (MinesFun)myLib.resolve("MinesAttackMoving");
				it_->second.AttackMoveFunc = (MinesFun)myLib.resolve("MinesAttackMoving");
				if (!MinesObjectFun)
				{
					qDebug()<<"未找到函数对应";
				}
			}
			else		
			{
				qDebug()<<"未找到DLL文件";
			}
			MainAttackType = AttackDLL;
		}
		if (it_->second.FuncType == AttackM)
		{
			if (pEng == NULL)
			{
				if (!(pEng = engOpen(NULL)))
				{
					qDebug()<<"Init Matlab fail";
				}
				else
				{
					it_->second.AttackMoveFunc = MatlabAttackMoving;
				}
			}
			MainAttackType = AttackM;
		}
	}

	if (MainAttackType == AttackM)
	{
		InitMatlabInfo(DigitModlMines);
	}
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值