📄 cmodelmanager.cpp
字号:
//-- {CycleCode: 162} file [0..3588]
//-- {StartSubRegion: 163} module.includes preserve=yes [0..431]
//-- {CycleCode: 19} file [0..376]
//-- {AddDecl: 20} module.includes preserve=yes [0..142]
//## begin module.includes preserve=yes
// Copyright (C) 1991 - 1999 Rational Software Corporation
#include "stdafx.h"
#include "CModelManager.h"
#include "ModelInfoOperation.h"
//##Modelid=431658FE02FD
//## end module.includes preserve=yes
//-- {AddDecl: 21} region.unprotectedFunction [143..265]
//##Modelid=431658FE02FD
//-- {AddDecl: 164} region.unprotectedFunction [432..567]
BOOL CModelManager::Init(CObjectManager * pCOjbectManager)
{
//## begin CModelManager::Init%9066EE9CFEED.body preserve=yes
m_pCObjectManager = pCOjbectManager;
LoadAutoFile();
return TRUE;
//## end CModelManager::Init%9066EE9CFEED.body
}
//-- {InsertRegion: 171} module.vulnerableDeclarations [568..747]
//-- {InsertRegion: 23} module.vulnerableDeclarations [266..295]
//##Modelid=4316593801A5
//-- {AddDecl: 22} region.unprotectedFunction [296..371]
//##Modelid=4316593801A5
//-- {AddDecl: 165} region.unprotectedFunction [748..1112]
void CModelManager::Clear()
{
//## begin CModelManager::Clear%865BA049FEED.body preserve=yes
for (UINT i = 0 ; i < m_ModelInfoArray.GetSize() ; i ++ )
{
ModelInfo * pMI = m_ModelInfoArray.GetPtrAt( i );
ASSERT( pMI );
if ( pMI->CallBaceOut )
{
UNLOADMODELDE_DEFAULT_FUNCTION UnloadFunction = pMI->CallBaceOut;
UnloadFunction();
}
ASSERT(pMI->Hinstance);
AfxFreeLibrary( pMI->Hinstance );
}
//## end CModelManager::Clear%865BA049FEED.body
}
//-- {InsertRegion: 172} module.vulnerableDeclarations [1113..1213]
//-- {InsertRegion: 24} module.vulnerableDeclarations [372..376]
//##Modelid=43165BE50213
//-- {AddDecl: 166} region.unprotectedFunction [1214..2320]
bool CModelManager::LoadModel(CString strDllName)
{
//## begin CModelManager::LoadModel%737D726EFEED.body preserve=yes
// TODO: Add your specialized code here.
CString strPath = strDllName; //路径
FARPROC pFuncIn; //模块In函数
FARPROC pFuncOut; //模块Out函数
ModelInfo MI;
HINSTANCE hIns = AfxLoadLibrary(strPath);//DLL句柄
//无法加载DLL时,加载默认目录文件
if (!hIns)
{
strPath = MFXGetModelPath() + strDllName;
hIns = AfxLoadLibrary(strPath);
}
//还加载不成功时,返回FALSE
if (!hIns)
{
return FALSE;
}
//Get In and Out Function;
pFuncIn = GetProcAddress( hIns, _T("PublicLoadFunction"));
pFuncOut = GetProcAddress( hIns, _T("PublicUnloadFunction"));
//if have not In function ,Free DLL
if ( !pFuncIn )
{
AfxFreeLibrary( hIns );
return FALSE;
}
//if In function return FALSE ,Free DLL
LOADMODELDE_DEFAULT_FUNCTION LMDFunction = (LOADMODELDE_DEFAULT_FUNCTION)pFuncIn;
if((*LMDFunction)(m_pCObjectManager))
{
AfxFreeLibrary( hIns );
return FALSE;
}
MI.CallBaceOut = pFuncOut;
MI.CallBackIn = pFuncIn;
MI.Hinstance = hIns;
MI.KeyValue = strPath;
// right
return TRUE;
//## end CModelManager::LoadModel%737D726EFEED.body
}
//-- {InsertRegion: 173} module.vulnerableDeclarations [2321..2350]
//##Modelid=431670660290
//-- {AddDecl: 167} region.unprotectedFunction [2351..2829]
BOOL CModelManager::UnloadModel(CString strDllName)
{
//## begin CModelManager::UnloadModel%82EB0066FEED.body preserve=yes
// TODO: Add your specialized code here.
ModelInfo * pMI ;
m_ModelInfoArray.FindAt( strDllName , &pMI );
if ( pMI )
{
if ( pMI->CallBaceOut )
{
UNLOADMODELDE_DEFAULT_FUNCTION UnloadFunction = pMI->CallBaceOut;
if (UnloadFunction())
{
return AfxFreeLibrary( pMI->Hinstance );
}
return FALSE;
}
else
{
return AfxFreeLibrary( pMI->Hinstance );
}
}
return FALSE;
//## end CModelManager::UnloadModel%82EB0066FEED.body
}
//-- {InsertRegion: 174} module.vulnerableDeclarations [2830..2859]
//##Modelid=43167535000F
//-- {AddDecl: 168} region.unprotectedFunction [2860..3130]
BOOL CModelManager::LoadAutoFile()
{
//## begin CModelManager::LoadAutoFile%D903B957FEED.body preserve=yes
//AUTOMODEL.MFW
CStdioFile file;
if (file.Open( "AUTOMODEL.MFW" , CFile::modeRead|CFile::typeText))
{
return FALSE;
}
CString strLine;
while(file.ReadString(strLine))
{
LoadModel( strLine);
}
return TRUE;
//## end CModelManager::LoadAutoFile%D903B957FEED.body
}
//-- {InsertRegion: 175} module.vulnerableDeclarations [3131..3164]
//##Modelid=4316F2330177
//-- {AddDecl: 169} region.unprotectedFunction [3165..3297]
ModelInfoOperation* CModelManager::GetLoadedModelInfo()
{
//## begin CModelManager::GetLoadedModelInfo%8A2B79AFFEED.body preserve=yes
// TODO: Add your specialized code here.
return &m_ModelInfoArray ;
//## end CModelManager::GetLoadedModelInfo%8A2B79AFFEED.body
}
//-- {AddDecl: 170} region.unprotectedFunction [3298..3585]
void CModelManager::GetLoadedModelName(CStringArray &strNameArray)
{
//## begin CModelManager::GetLoadedModelName%70A8D496FEED.body preserve=yes
strNameArray.SetSize( m_ModelInfoArray.GetSize());
for (UINT i = 0 ; i < m_ModelInfoArray.GetSize() ; i ++ )
{
ModelInfo * PMI = m_ModelInfoArray.GetPtrAt( i );
strNameArray[i] = PMI->KeyValue;
}
//## end CModelManager::GetLoadedModelName%70A8D496FEED.body
}
//-- {InsertRegion: 176} module.vulnerableDeclarations [3586..3588]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -