Files
EgtExchange/ExcExecutor.cpp
T
Dario Sassi 1ec34dc4e1 EgtExchange 1.5d4 :
- aggiunta importazione DXF.
2014-04-21 21:58:16 +00:00

138 lines
3.9 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : ExcExecutor.cpp Data : 04.04.14 Versione : 1.5d1
// Contenuto : Implementazione della classe ExcExecutor.
//
//
//
// Modifiche : 04.04.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "ExcExecutor.h"
#include "DllMain.h"
#include "/EgtDev/Include/EgnStringUtils.h"
#include "/EgtDev/Include/EgnCmdParser.h"
#include "/EgtDev/Include/EExImportStl.h"
#include "/EgtDev/Include/EExImportDxf.h"
using namespace std ;
//----------------------------------------------------------------------------
IExcExecutor*
CreateExcExecutor( void)
{
return static_cast<IExcExecutor*> ( new ExcExecutor) ;
}
//----------------------------------------------------------------------------
ExcExecutor::ExcExecutor( void)
{
// assegno chiavi a funzioni di esecuzione
m_ExecMgr.Init( 4) ;
m_ExecMgr.Insert( "IMPORTSTL", &ExcExecutor::ExecuteImportStl) ;
m_ExecMgr.Insert( "IMPORTDXF", &ExcExecutor::ExecuteImportDxf) ;
}
//----------------------------------------------------------------------------
ExcExecutor::~ExcExecutor( void)
{
}
//----------------------------------------------------------------------------
bool
ExcExecutor::SetCmdParser( ICmdParser* pParser)
{
m_pParser = pParser ;
return ( m_pParser != nullptr) ;
}
//----------------------------------------------------------------------------
int
ExcExecutor::Execute( const string& sCmd1, const string& sCmd2, const STRVECTOR& vsParams)
{
// verifico validita GeomDB
if ( m_pGDB == nullptr) {
LOG_ERROR( GetEExLogger(), "Error : null GeomDb in ExcExecutor.")
return ER_ERR ;
}
// verifico validità CmdParser
if ( m_pParser == nullptr) {
LOG_ERROR( GetEExLogger(), "Error : null CmdParser in ExcExecutor.")
return ER_ERR ;
}
// esecuzione comando
return m_ExecMgr.Execute( *this, sCmd1, sCmd2, vsParams) ;
}
//----------------------------------------------------------------------------
bool
ExcExecutor::SetGeomDB( IGeomDB* pGdb)
{
m_pGDB = pGdb ;
return ( m_pGDB != nullptr) ;
}
//----------------------------------------------------------------------------
bool
ExcExecutor::ExecuteImportStl( const string& sCmd2, const STRVECTOR& vsParams)
{
// 2 parametri : nome del file e Id del gruppo
if ( vsParams.size() != 2)
return false ;
// recupero l'Id
int nId = m_pParser->GetIdParam( vsParams[1]) ;
if ( nId == CMD_ID_ERROR)
return false ;
// preparo l'importatore
IImportStl* pImpStl = CreateImportStl() ;
if ( pImpStl == nullptr) {
LOG_ERROR( GetEExLogger(), "Error : CreateImportStl")
return false ;
}
// eseguo l'importazione
bool bOk = pImpStl->Import( vsParams[0], m_pGDB, nId) ;
// cancello l'importatore
delete pImpStl ;
return bOk ;
}
//----------------------------------------------------------------------------
bool
ExcExecutor::ExecuteImportDxf( const string& sCmd2, const STRVECTOR& vsParams)
{
// 2 parametri : nome del file e Id del gruppo
if ( vsParams.size() != 2)
return false ;
// recupero l'Id
int nId = m_pParser->GetIdParam( vsParams[1]) ;
if ( nId == CMD_ID_ERROR)
return false ;
// preparo l'importatore
IImportDxf* pImpDxf = CreateImportDxf() ;
if ( pImpDxf == nullptr) {
LOG_ERROR( GetEExLogger(), "Error : CreateImportDxf")
return false ;
}
// eseguo l'importazione
bool bOk = pImpDxf->Import( vsParams[0], m_pGDB, nId) ;
// cancello l'importatore
delete pImpDxf ;
return bOk ;
}