1f1c589f47
- aggiunte a Exe e Lua funzioni ExecTscLine, SetTscVar e GetTscVar.
129 lines
4.2 KiB
C++
129 lines
4.2 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2014-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : EXE_TscExec.cpp Data : 05.05.15 Versione : 1.6e1
|
|
// Contenuto : Funzioni esecuzione TSC per EXE.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 01.09.14 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "EXE.h"
|
|
#include "EXE_Macro.h"
|
|
#include "DllGraphics.h"
|
|
#include "DllExchange.h"
|
|
#include "/EgtDev/Include/EXeExecutor.h"
|
|
#include "/EgtDev/Include/EGkGdbExecutor.h"
|
|
#include "/EgtDev/Include/EExExcExecutor.h"
|
|
#include "/EgtDev/Include/EGrSceExecutor.h"
|
|
#include "/EgtDev/Include/EGnStringUtils.h"
|
|
#include "/EgtDev/Include/EgtStringConverter.h"
|
|
#include "/EgtDev/Include/EgtPointerOwner.h"
|
|
#include <string>
|
|
|
|
using namespace std ;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeInitTscExec( void)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
|
|
|
// eventuale pulizia esecutore e suoi oggetti
|
|
if ( pGseCtx->m_pTscExec != nullptr) {
|
|
delete pGseCtx->m_pTscExec ;
|
|
pGseCtx->m_pTscExec = nullptr ;
|
|
}
|
|
|
|
// creo esecutore
|
|
PtrOwner<ICmdParser> pCmdParser( CreateCmdParser()) ;
|
|
VERIFY_NULL( Get( pCmdParser), "Error in CreateCmdParser", false)
|
|
|
|
// creo oggetto per esecuzione funzioni di GeomKernel
|
|
PtrOwner<IGdbExecutor> pGdbExec( CreateGdbExecutor()) ;
|
|
VERIFY_NULL( Get( pGdbExec), "Error in CreateGdbExecutor", false)
|
|
pGdbExec->SetGeomDB( pGseCtx->m_pGeomDB) ;
|
|
pCmdParser->SetExecutor( Release( pGdbExec)) ;
|
|
|
|
// eventuale creazione oggetto per esecuzione funzioni di Scene
|
|
if ( pGseCtx->m_pScene != nullptr && IsLoadedGraphicsDll()) {
|
|
PtrOwner<ISceExecutor> pSceExec( MyCreateSceExecutor()) ;
|
|
VERIFY_NULL( Get( pSceExec), "Error in CreateSceExecutor", false)
|
|
pSceExec->SetScene( pGseCtx->m_pScene) ;
|
|
pCmdParser->AddExecutor( Release( pSceExec)) ;
|
|
}
|
|
|
|
// eventuale creazione oggetto per esecuzione funzioni di Exchange
|
|
if ( IsLoadedExchangeDll()) {
|
|
PtrOwner<IExcExecutor> pExcExec( MyCreateExcExecutor()) ;
|
|
VERIFY_NULL( Get( pExcExec), "Error in CreateExcExecutor", false)
|
|
pExcExec->SetGeomDB( pGseCtx->m_pGeomDB) ;
|
|
pCmdParser->AddExecutor( Release( pExcExec)) ;
|
|
}
|
|
|
|
// completo inizializzazioni
|
|
pCmdParser->Init() ;
|
|
pGseCtx->m_pTscExec = Release( pCmdParser) ;
|
|
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeTscExecFile( const string& sFilePath)
|
|
{
|
|
ICmdParser* pTscExec = GetCurrTscExecutor() ;
|
|
VERIFY_TSCEXEC( pTscExec, false)
|
|
|
|
// emetto info
|
|
string sInfo = "Exec File = " + sFilePath ;
|
|
LOG_INFO( GetLogger(), sInfo.c_str())
|
|
|
|
// imposto il direttorio dello script
|
|
string sFileDir, sFileName ;
|
|
SplitLast( sFilePath, "\\", sFileDir, sFileName) ;
|
|
pTscExec->SetDirReplace( "<TSCDIR>", sFileDir) ;
|
|
|
|
// esecuzione script
|
|
return pTscExec->Run( sFilePath) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeTscExecLine( const string& sLine)
|
|
{
|
|
ICmdParser* pTscExec = GetCurrTscExecutor() ;
|
|
VERIFY_TSCEXEC( pTscExec, false)
|
|
// eseguo il comando
|
|
return pTscExec->ExecLine( sLine) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeTscSetVariable( const string& sName, int nVal)
|
|
{
|
|
ICmdParser* pTscExec = GetCurrTscExecutor() ;
|
|
VERIFY_TSCEXEC( pTscExec, false)
|
|
// eseguo il comando
|
|
if ( pTscExec->SetVariable( sName, nVal))
|
|
return true ;
|
|
else
|
|
return pTscExec->AddVariable( sName, nVal) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeTscGetVariable( const string& sName, int& nVal)
|
|
{
|
|
ICmdParser* pTscExec = GetCurrTscExecutor() ;
|
|
VERIFY_TSCEXEC( pTscExec, false)
|
|
// eseguo il comando
|
|
return pTscExec->GetVariable( sName, nVal) ;
|
|
}
|