Files
TestEGk/TestEGk.cpp
T
Dario Sassi 2525a3edeb TestEgk 1.5d2 :
- aggiunta gestione Exchange.
2014-04-05 20:49:20 +00:00

164 lines
4.7 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2013-2014
//----------------------------------------------------------------------------
// File : TestEGk.cpp Data : 04.04.14 Versione : 1.5d2
// Contenuto : Programma di test della libreria EgtGeomKernel.
//
//
//
// Modifiche : 20.11.13 DS Creazione modulo.
// 04.04.14 DS Agg. esecutore di Exchange.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "/EgtDev/Include/EGnDllMain.h"
#include "/EgtDev/Include/EgnGetModuleVer.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EGnStringConverter.h"
#include "/EgtDev/Include/EGnCmdParser.h"
#include "/EgtDev/Include/ENkDllMain.h"
#include "/EgtDev/Include/EGkDllMain.h"
#include "/EgtDev/Include/EGkGeomDB.h"
#include "/EgtDev/Include/EGkGdbExecutor.h"
#include "/EgtDev/Include/EExDllMain.h"
#include "/EgtDev/Include/EExExcExecutor.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
#include "/EgtDev/Include/EgtLogger.h"
#include "/EgtDev/Include/EgtIniFile.h"
//--------------------------- Define -----------------------------------------
#if defined( _WIN64)
#if defined( NDEBUG)
#define STR_EXE "TestEGkR64.exe"
#else
#define STR_EXE "TestEGkD64.exe"
#endif
#elif defined( _WIN32)
#if defined( NDEBUG)
#define STR_EXE "TestEGkR32.exe"
#else
#define STR_EXE "TestEGkD32.exe"
#endif
#endif
using namespace std ;
using namespace egtlogger ;
//----------------------------------------------------------------------------
int
wmain( int argc, wchar_t* argv[])
{
int nErr ;
int nDebug ;
string sIn ;
string sDir ;
string sFileIni ;
// se debug, imposto stampe memory leaks all'uscita
#ifdef _DEBUG
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF) ;
#endif
// recupero il direttorio del programma e costruisco path file INI
GetModuleDirectory( NULL, sDir) ;
sFileIni = sDir + "\\TestEgk.ini" ;
// imposto direttorio di lavoro
SetCurrentDirectory( sDir) ;
// interpreto i parametri di linea
// nome file di comandi
if ( argc >= 2)
sIn = LPSTR( WtoA( argv[1])) ;
else
sIn = GetPrivateProfileStringUtf8( "General", "Batch", "In.btsc", sFileIni.c_str()) ;
// livello di debug
nDebug = GetPrivateProfileInt( "General", "Debug", 0, sFileIni.c_str()) ;
// inizializzazioni del logger
Logger logger( ( nDebug > 0 ? LL_DEBUG : LL_INFO), "TestEGk") ;
logger.AddOutputStream( cout, false, LL_INFO) ;
logger.AddOutputStream( new(nothrow) ofstream( "TestEgk.log"), true) ;
// inizio programma
LOG_DATETIME( &logger, " Start Test")
// versione del programma
{ string sVer ;
GetModuleVersion( NULL, sVer) ;
LOG_INFO( &logger, string( STR_EXE " v." + sVer).c_str())
}
// versione delle librerie
LOG_INFO( &logger, GetEGnVersion())
LOG_INFO( &logger, GetENkVersion())
LOG_INFO( &logger, GetEGkVersion())
LOG_INFO( &logger, GetEExVersion())
// passo logger alle librerie
SetEGnLogger( &logger) ;
SetENkLogger( &logger) ;
SetEGkLogger( &logger) ;
SetEExLogger( &logger) ;
// nessun errore
nErr = 0 ;
// esecuzione script
PtrOwner<IGeomDB> pGdb( CreateGeomDB()) ;
PtrOwner<IGdbExecutor> pGdbExec( CreateGdbExecutor()) ;
PtrOwner<IExcExecutor> pExcExec( CreateExcExecutor()) ;
PtrOwner<ICmdParser> pCmdParser( CreateCmdParser()) ;
// controllo validità oggetti
if ( ! IsValid( pGdb)) {
LOG_ERROR( &logger, "Error in CreateGeomDB")
nErr = 1 ;
goto END ;
}
if ( ! IsValid( pGdbExec)) {
LOG_ERROR( &logger, "Error in CreateGdbExecutor")
nErr = 1 ;
goto END ;
}
if ( ! IsValid( pExcExec)) {
LOG_ERROR( &logger, "Error in CreateExcExecutor")
nErr = 1 ;
goto END ;
}
if ( ! IsValid( pCmdParser)) {
LOG_ERROR( &logger, "Error in CreateCmdParser")
nErr = 1 ;
goto END ;
}
// inizializzazioni
pGdb->Init() ;
pGdbExec->SetGeomDB( Get( pGdb)) ;
pExcExec->SetGeomDB( Get( pGdb)) ;
pCmdParser->SetExecutor( Get( pGdbExec)) ;
pCmdParser->AddExecutor( Get( pExcExec)) ;
if ( ! pCmdParser->Init( )) {
LOG_ERROR( &logger, "Error on Parser.Init")
nErr = 2 ;
goto END ;
}
// esecuzione comandi
if ( ! pCmdParser->Run( sIn)) {
nErr = 3 ;
goto END ;
}
END :
// fine programma
LOG_DATETIME( &logger, " End Test")
return nErr ;
}