diff --git a/API_Exchange.cpp b/API_Exchange.cpp index f991d1c..e9af731 100644 --- a/API_Exchange.cpp +++ b/API_Exchange.cpp @@ -15,6 +15,7 @@ #include "stdafx.h" #include "API.h" #include "API_Macro.h" +#include "DllExchange.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EExImportStl.h" #include "/EgtDev/Include/EExImportDxf.h" @@ -87,7 +88,7 @@ EgtImportDxf( const string& sFilePath) // aggiungo un gruppo pezzo int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; // preparo l'importatore - PtrOwner pImpDxf( CreateImportDxf()) ; + PtrOwner pImpDxf( MyCreateImportDxf()) ; bOk = bOk && ! IsNull( pImpDxf) ; // eseguo l'importazione bOk = bOk && pImpDxf->Import( sFilePath, pGseCtx->m_pGeomDB, nPartId) ; @@ -125,7 +126,7 @@ EgtImportStl( const string& sFilePath) int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; int nLayerId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, nPartId, Frame3d()) ; // preparo l'importatore - PtrOwner pImpStl( CreateImportStl()) ; + PtrOwner pImpStl( MyCreateImportStl()) ; bOk = bOk && ! IsNull( pImpStl) ; // eseguo l'importazione bOk = bOk && pImpStl->Import( sFilePath, pGseCtx->m_pGeomDB, nLayerId) ; @@ -162,7 +163,7 @@ EgtImportCnc( const string& sFilePath) // aggiungo un gruppo pezzo int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; // preparo l'importatore - PtrOwner pImpCnc( CreateImportCnc()) ; + PtrOwner pImpCnc( MyCreateImportCnc()) ; bOk = bOk && ! IsNull( pImpCnc) ; // eseguo l'importazione bOk = bOk && pImpCnc->Import( sFilePath, pGseCtx->m_pGeomDB, nPartId) ; @@ -197,7 +198,7 @@ EgtExportDxf( int nId, const string& sFilePath) bool bOk = true ; // esporto il file DXF // preparo l'esportatore - PtrOwner pExpDxf( CreateExportDxf()) ; + PtrOwner pExpDxf( MyCreateExportDxf()) ; bOk = bOk && ! IsNull( pExpDxf) ; // eseguo l'esportazione bOk = bOk && pExpDxf->Export( pGeomDB, nId, sFilePath) ; @@ -230,7 +231,7 @@ EgtExportStl( int nId, const string& sFilePath) bool bOk = true ; // esporto il file STL // preparo l'esportatore - PtrOwner pExpStl( CreateExportStl()) ; + PtrOwner pExpStl( MyCreateExportStl()) ; bOk = bOk && ! IsNull( pExpStl) ; // eseguo l'esportazione bOk = bOk && pExpStl->Export( pGeomDB, nId, sFilePath) ; diff --git a/API_General.cpp b/API_General.cpp index 3c0dc92..b476a9f 100644 --- a/API_General.cpp +++ b/API_General.cpp @@ -15,14 +15,14 @@ #include "stdafx.h" #include "API.h" #include "LUA_Base.h" +#include "DllGraphics.h" +#include "DllExchange.h" +#include "DllMachKernel.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EInDllMain.h" #include "/EgtDev/Include/EGnDllMain.h" #include "/EgtDev/Include/ENkDllMain.h" -#include "/EgtDev/Include/EMkDllMain.h" #include "/EgtDev/Include/EGkDllMain.h" -#include "/EgtDev/Include/EExDllMain.h" -#include "/EgtDev/Include/EGrDllMain.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnStringConverter.h" #include "/EgtDev/Include/EGnPcInfo.h" @@ -46,6 +46,7 @@ __stdcall EgtInit( int nDebug, const wchar_t* sLogFile, const wchar_t* sLogMsg) // cancello eventuale vecchio logger if ( s_pGenLog != nullptr) delete s_pGenLog ; + // creo il logger generale s_pGenLog = new Logger( ( nDebug > 0 ? LL_DEBUG : LL_INFO), "EgtInterface") ; if ( s_pGenLog == nullptr) @@ -56,24 +57,24 @@ __stdcall EgtInit( int nDebug, const wchar_t* sLogFile, const wchar_t* sLogMsg) SetEGnLogger( s_pGenLog) ; SetENkLogger( s_pGenLog) ; SetEGkLogger( s_pGenLog) ; - SetEMkLogger( s_pGenLog) ; - SetEExLogger( s_pGenLog) ; - SetEGrLogger( s_pGenLog) ; + + // carico librerie opzionali + LoadGraphicsDll() ; + MySetEGrLogger( s_pGenLog) ; + LoadExchangeDll() ; + MySetEExLogger( s_pGenLog) ; + LoadMachKernelDll() ; + MySetEMkLogger( s_pGenLog) ; // dichiaro inizio programma LOG_DATETIME( s_pGenLog, " Init") // eventuale messaggio dall'applicazione if ( sLogMsg != nullptr && sLogMsg[0] != L'\0') LOG_INFO( s_pGenLog, LPSTR( WtoA( sLogMsg))) - // versione dell'interfaccia - LOG_INFO( s_pGenLog, GetEInVersion()) - // versione delle librerie - LOG_INFO( s_pGenLog, GetEGnVersion()) - LOG_INFO( s_pGenLog, GetENkVersion()) - LOG_INFO( s_pGenLog, GetEGkVersion()) - LOG_INFO( s_pGenLog, GetEMkVersion()) - LOG_INFO( s_pGenLog, GetEExVersion()) - LOG_INFO( s_pGenLog, GetEGrVersion()) + // versione di interfaccia e componenti + string sVer ; + EgtGetVersionInfo( sVer, "\n") ; + LOG_INFO( s_pGenLog, sVer.c_str()) // Info sul sistema string sTmp ; if ( GetOsInfo( sTmp)) @@ -99,6 +100,11 @@ __stdcall EgtExit( void) // termino l'interprete LUA LuaExit() ; + // libero le librerie opzionali + FreeMachKernelDll() ; + FreeExchangeDll() ; + FreeGraphicsDll() ; + // fine programma LOG_DATETIME( s_pGenLog, " Exit") @@ -123,7 +129,9 @@ __stdcall EgtSetKey( const wchar_t* swKey) { string sKey = WtoA( swKey) ; SetEGkKey( sKey) ; - SetEMkKey( sKey) ; + MySetEGrKey( sKey) ; + MySetEExKey( sKey) ; + MySetEMkKey( sKey) ; return TRUE ; } @@ -226,18 +234,28 @@ EgtGetVersionInfo( string& sVer, const char* szNewLine) // verifico il parametro if ( &sVer == nullptr) return false ; - // recupero le informazioni sulle DLL + // recupero le informazioni sulle DLL sempre presenti sVer += GetEInVersion() ; sVer += szNewLine ; - sVer += GetEGrVersion() ; - sVer += szNewLine ; - sVer += GetEExVersion() ; - sVer += szNewLine ; - sVer += GetEGkVersion() ; + sVer += GetEGnVersion() ; sVer += szNewLine ; sVer += GetENkVersion() ; sVer += szNewLine ; - sVer += GetEGnVersion() ; + sVer += GetEGkVersion() ; + // recupero le informazioni sulle DLL opzionali + if ( IsLoadedGraphicsDll()) { + sVer += szNewLine ; + sVer += MyGetEGrVersion() ; + } + if ( IsLoadedExchangeDll()) { + sVer += szNewLine ; + sVer += MyGetEExVersion() ; + } + string sEMkVer = MyGetEMkVersion() ; + if ( ! sEMkVer.empty()) { + sVer += szNewLine ; + sVer += sEMkVer ; + } return true ; } diff --git a/API_MachMgr.cpp b/API_MachMgr.cpp index 1289214..9fa2fab 100644 --- a/API_MachMgr.cpp +++ b/API_MachMgr.cpp @@ -15,6 +15,7 @@ #include "stdafx.h" #include "API.h" #include "API_Macro.h" +#include "DllMachKernel.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EGnStringConverter.h" #include "/EgtDev/Include/EgtPointerOwner.h" @@ -28,7 +29,7 @@ __stdcall EgtInitMachMgr( void) GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX( pGseCtx, FALSE) // inizializzazione gestore lavorazioni - PtrOwner pMachMgr( CreateMachMgr()) ; + PtrOwner pMachMgr( MyCreateMachMgr()) ; VERIFY_NULL( Get( pMachMgr), "Error in CreateMachMgr", FALSE) pMachMgr->Init( pGseCtx->m_pGeomDB) ; // assegno il gestore al contesto diff --git a/API_Scene.cpp b/API_Scene.cpp index 841d113..b05ae14 100644 --- a/API_Scene.cpp +++ b/API_Scene.cpp @@ -15,6 +15,7 @@ #include "stdafx.h" #include "API.h" #include "API_Macro.h" +#include "DllGraphics.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EGnStringConverter.h" #include "/EgtDev/Include/EgtPointerOwner.h" @@ -29,7 +30,7 @@ __stdcall EgtInitScene( HWND hWnd, int nDriver, int b2Buff, int nColorBits, int GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX( pGseCtx, FALSE) // inizializzazione scena OpenGL - PtrOwner pScene( CreateEGrScene()) ; + PtrOwner pScene( MyCreateEGrScene()) ; VERIFY_NULL( Get( pScene), "Error in CreateEGrScene", FALSE) HDC hdc = GetDC( hWnd) ; if ( ! pScene->CreateContext( hdc, nDriver, ( b2Buff != 0), nColorBits, nDepthBits)) diff --git a/API_TscExec.cpp b/API_TscExec.cpp index 9713b7b..f5f117b 100644 --- a/API_TscExec.cpp +++ b/API_TscExec.cpp @@ -15,6 +15,8 @@ #include "stdafx.h" #include "API.h" #include "API_Macro.h" +#include "DllGraphics.h" +#include "DllExchange.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EGkGdbExecutor.h" #include "/EgtDev/Include/EExExcExecutor.h" @@ -49,20 +51,22 @@ __stdcall EgtInitTscExec( void) pGdbExec->SetGeomDB( pGseCtx->m_pGeomDB) ; pCmdParser->SetExecutor( Release( pGdbExec)) ; - // creazione oggetto per esecuzione funzioni di Exchange - PtrOwner pExcExec( CreateExcExecutor()) ; - VERIFY_NULL( Get( pExcExec), "Error in CreateExcExecutor", FALSE) - pExcExec->SetGeomDB( pGseCtx->m_pGeomDB) ; - pCmdParser->AddExecutor( Release( pExcExec)) ; - // eventuale creazione oggetto per esecuzione funzioni di Scene - if ( pGseCtx->m_pScene != nullptr) { - PtrOwner pSceExec( CreateSceExecutor()) ; + if ( pGseCtx->m_pScene != nullptr && IsLoadedGraphicsDll()) { + PtrOwner 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 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) ; diff --git a/DllExchange.cpp b/DllExchange.cpp new file mode 100644 index 0000000..f191239 --- /dev/null +++ b/DllExchange.cpp @@ -0,0 +1,213 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : DllExchange.cpp Data : 27.03.15 Versione : 1.6c9 +// Contenuto : Funzioni di gestione della libreria opzionale EgtExchange. +// +// +// +// Modifiche : 27.03.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "DllExchange.h" +#define NOMINMAX +#include + +using namespace std ; + +//----------------------------------------------------------------------------- +// Nome della libreria +#if defined( _WIN64) && defined( _DEBUG) + static const wchar_t* EEX_NAME = L"EgtExchangeD64.dll" ; +#elif defined( _WIN64) + static const wchar_t* EEX_NAME = L"EgtExchangeR64.dll" ; +#elif defined( _WIN32) && defined( _DEBUG) + static const wchar_t* EEX_NAME = L"EgtExchangeD32.dll" ; +#else + static const wchar_t* EEX_NAME = L"EgtExchangeR32.dll" ; +#endif +// Nome delle funzioni caricate +static const char* EEX_SETEEXLOGGER = "SetEExLogger" ; +static const char* EEX_GETEEXVERSION = "GetEExVersion" ; +static const char* EEX_SETEEXKEY = "SetEExKey" ; +static const char* EEX_CREATEIMPORTCNC = "CreateImportCnc" ; +static const char* EEX_CREATEIMPORTDXF = "CreateImportDxf" ; +static const char* EEX_CREATEIMPORTSTL = "CreateImportStl" ; +static const char* EEX_CREATEEXPORTDXF = "CreateExportDxf" ; +static const char* EEX_CREATEEXPORTSTL = "CreateExportStl" ; +static const char* EEX_CREATEEEXEXECUTOR = "CreateExcExecutor" ; + + +//----------------------------------------------------------------------------- +HMODULE s_hEEx = nullptr ; + +//----------------------------------------------------------------------------- +bool +LoadExchangeDll( void) +{ + // se già caricata + if ( s_hEEx != nullptr) + return true ; + // carico la libreria EgtExchange + s_hEEx = LoadLibrary( EEX_NAME) ; + return ( s_hEEx != nullptr) ; +} + +//----------------------------------------------------------------------------- +bool +FreeExchangeDll( void) +{ + // se non è già caricata + if ( s_hEEx == nullptr) + return true ; + // libero la libreria EgtExchange + FreeLibrary( s_hEEx) ; + s_hEEx = nullptr ; + return true ; +} + +//----------------------------------------------------------------------------- +bool +IsLoadedExchangeDll( void) +{ + return ( s_hEEx != nullptr) ; +} + +//----------------------------------------------------------------------------- +void +MySetEExLogger( ILogger* pLogger) +{ + // verifico caricamento libreria EgtExchange + if ( s_hEEx == nullptr) + return ; + // recupero funzione che imposta il logger + typedef void (* PF_SetEExLogger) ( ILogger* pLogger) ; + PF_SetEExLogger pFun = (PF_SetEExLogger)GetProcAddress( s_hEEx, EEX_SETEEXLOGGER) ; + if ( pFun == nullptr) + return ; + pFun( pLogger) ; +} + +//----------------------------------------------------------------------------- +const char* +MyGetEExVersion( void) +{ + // verifico caricamento libreria EgtExchange + if ( s_hEEx == nullptr) + return "" ; + // recupero funzione che restituisce la versione della libreria + typedef const char* (* PF_GetEExVersion) ( void) ; + PF_GetEExVersion pFun = (PF_GetEExVersion)GetProcAddress( s_hEEx, EEX_GETEEXVERSION) ; + if ( pFun == nullptr) + return "" ; + return pFun() ; +} + +//----------------------------------------------------------------------------- +void +MySetEExKey( const string& sKey) +{ + // verifico caricamento libreria EgtExchange + if ( s_hEEx == nullptr) + return ; + // recupero funzione che imposta i codici di protezione + typedef void (* PF_SetEExKey) ( const string& sKey) ; + PF_SetEExKey pFun = (PF_SetEExKey)GetProcAddress( s_hEEx, EEX_SETEEXKEY) ; + if ( pFun == nullptr) + return ; + pFun( sKey) ; +} + +//----------------------------------------------------------------------------- +IImportCnc* +MyCreateImportCnc( void) +{ + // verifico caricamento libreria EgtExchange + if ( s_hEEx == nullptr) + return nullptr ; + // recupero funzione creazione oggetto + typedef IImportCnc* (* PF_CreateImportCnc) ( void) ; + PF_CreateImportCnc pFun = (PF_CreateImportCnc)GetProcAddress( s_hEEx, EEX_CREATEIMPORTCNC) ; + if ( pFun == nullptr) + return nullptr ; + return pFun() ; +} + +//----------------------------------------------------------------------------- +IImportDxf* +MyCreateImportDxf( void) +{ + // verifico caricamento libreria EgtExchange + if ( s_hEEx == nullptr) + return nullptr ; + // recupero funzione creazione oggetto + typedef IImportDxf* (* PF_CreateImportDxf) ( void) ; + PF_CreateImportDxf pFun = (PF_CreateImportDxf)GetProcAddress( s_hEEx, EEX_CREATEIMPORTDXF) ; + if ( pFun == nullptr) + return nullptr ; + return pFun() ; +} + +//----------------------------------------------------------------------------- +IImportStl* +MyCreateImportStl( void) +{ + // verifico caricamento libreria EgtExchange + if ( s_hEEx == nullptr) + return nullptr ; + // recupero funzione creazione oggetto + typedef IImportStl* (* PF_CreateImportStl) ( void) ; + PF_CreateImportStl pFun = (PF_CreateImportStl)GetProcAddress( s_hEEx, EEX_CREATEIMPORTSTL) ; + if ( pFun == nullptr) + return nullptr ; + return pFun() ; +} + +//----------------------------------------------------------------------------- +IExportDxf* +MyCreateExportDxf( void) +{ + // verifico caricamento libreria EgtExchange + if ( s_hEEx == nullptr) + return nullptr ; + // recupero funzione creazione oggetto + typedef IExportDxf* (* PF_CreateExportDxf) ( void) ; + PF_CreateExportDxf pFun = (PF_CreateExportDxf)GetProcAddress( s_hEEx, EEX_CREATEEXPORTDXF) ; + if ( pFun == nullptr) + return nullptr ; + return pFun() ; +} + +//----------------------------------------------------------------------------- +IExportStl* +MyCreateExportStl( void) +{ + // verifico caricamento libreria EgtExchange + if ( s_hEEx == nullptr) + return nullptr ; + // recupero funzione creazione oggetto + typedef IExportStl* (* PF_CreateExportStl) ( void) ; + PF_CreateExportStl pFun = (PF_CreateExportStl)GetProcAddress( s_hEEx, EEX_CREATEEXPORTSTL) ; + if ( pFun == nullptr) + return nullptr ; + return pFun() ; +} + +//----------------------------------------------------------------------------- +IExcExecutor* +MyCreateExcExecutor( void) +{ + // verifico caricamento libreria EgtExchange + if ( s_hEEx == nullptr) + return nullptr ; + // recupero funzione creazione oggetto + typedef IExcExecutor* (* PF_CreateExcExecutor) ( void) ; + PF_CreateExcExecutor pFun = (PF_CreateExcExecutor)GetProcAddress( s_hEEx, EEX_CREATEEEXEXECUTOR) ; + if ( pFun == nullptr) + return nullptr ; + return pFun() ; +} diff --git a/DllExchange.h b/DllExchange.h new file mode 100644 index 0000000..130f20f --- /dev/null +++ b/DllExchange.h @@ -0,0 +1,38 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : DllGraphics.h Data : 27.03.15 Versione : 1.6c9 +// Contenuto : Dichiarazioni funzioni per libreria opzionale EgtGraphics. +// +// +// +// Modifiche : 27.03.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include + +class ILogger ; +class IImportCnc ; +class IImportDxf ; +class IImportStl ; +class IExportDxf ; +class IExportStl ; +class IExcExecutor ; + +//---------------------------------------------------------------------------- +bool LoadExchangeDll( void) ; +bool FreeExchangeDll( void) ; +bool IsLoadedExchangeDll( void) ; +void MySetEExLogger( ILogger* pLogger) ; +void MySetEExKey( const std::string& sKey) ; +const char* MyGetEExVersion( void) ; +IImportCnc* MyCreateImportCnc( void) ; +IImportDxf* MyCreateImportDxf( void) ; +IImportStl* MyCreateImportStl( void) ; +IExportDxf* MyCreateExportDxf( void) ; +IExportStl* MyCreateExportStl( void) ; +IExcExecutor* MyCreateExcExecutor(void) ; diff --git a/DllGraphics.cpp b/DllGraphics.cpp new file mode 100644 index 0000000..9573156 --- /dev/null +++ b/DllGraphics.cpp @@ -0,0 +1,149 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : DllGraphics.cpp Data : 27.03.15 Versione : 1.6c9 +// Contenuto : Funzioni di gestione della libreria opzionale EgtGraphics. +// +// +// +// Modifiche : 27.03.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "DllGraphics.h" +#define NOMINMAX +#include + +using namespace std ; + +//----------------------------------------------------------------------------- +// Nome della libreria +#if defined( _WIN64) && defined( _DEBUG) + static const wchar_t* EGR_NAME = L"EgtGraphicsD64.dll" ; +#elif defined( _WIN64) + static const wchar_t* EGR_NAME = L"EgtGraphicsR64.dll" ; +#elif defined( _WIN32) && defined( _DEBUG) + static const wchar_t* EGR_NAME = L"EgtGraphicsD32.dll" ; +#else + static const wchar_t* EGR_NAME = L"EgtGraphicsR32.dll" ; +#endif +// Nome delle funzioni caricate +static const char* EGR_SETEGRLOGGER = "SetEGrLogger" ; +static const char* EGR_GETEGRVERSION = "GetEGrVersion" ; +static const char* EGR_SETEGRKEY = "SetEGrKey" ; +static const char* EGR_CREATEEGRSCENE = "CreateEGrScene" ; +static const char* EGR_CREATESCEEXECUTOR = "CreateSceExecutor" ; + + +//----------------------------------------------------------------------------- +HMODULE s_hEGr = nullptr ; + +//----------------------------------------------------------------------------- +bool +LoadGraphicsDll( void) +{ + // se già caricata + if ( s_hEGr != nullptr) + return true ; + // carico la libreria EgtGraphics + s_hEGr = LoadLibrary( EGR_NAME) ; + return ( s_hEGr != nullptr) ; +} + +//----------------------------------------------------------------------------- +bool +FreeGraphicsDll( void) +{ + // se non è già caricata + if ( s_hEGr == nullptr) + return true ; + // libero la libreria EgtGraphics + FreeLibrary( s_hEGr) ; + s_hEGr = nullptr ; + return true ; +} + +//----------------------------------------------------------------------------- +bool +IsLoadedGraphicsDll( void) +{ + return ( s_hEGr != nullptr) ; +} + +//----------------------------------------------------------------------------- +void +MySetEGrLogger( ILogger* pLogger) +{ + // verifico caricamento libreria MachMgr + if ( s_hEGr == nullptr) + return ; + // recupero funzione che imposta il logger + typedef void (* PF_SetEMkLogger) ( ILogger* pLogger) ; + PF_SetEMkLogger pFun = (PF_SetEMkLogger)GetProcAddress( s_hEGr, EGR_SETEGRLOGGER) ; + if ( pFun == nullptr) + return ; + pFun( pLogger) ; +} + +//----------------------------------------------------------------------------- +const char* +MyGetEGrVersion( void) +{ + // verifico caricamento libreria MachMgr + if ( s_hEGr == nullptr) + return "" ; + // recupero funzione che restituisce la versione della libreria + typedef const char* (* PF_GetEGrVersion) ( void) ; + PF_GetEGrVersion pFun = (PF_GetEGrVersion)GetProcAddress( s_hEGr, EGR_GETEGRVERSION) ; + if ( pFun == nullptr) + return "" ; + return pFun() ; +} + +//----------------------------------------------------------------------------- +void +MySetEGrKey( const string& sKey) +{ + // verifico caricamento libreria MachMgr + if ( s_hEGr == nullptr) + return ; + // recupero funzione che imposta i codici di protezione + typedef void (* PF_SetEGrKey) ( const string& sKey) ; + PF_SetEGrKey pFun = (PF_SetEGrKey)GetProcAddress( s_hEGr, EGR_SETEGRKEY) ; + if ( pFun == nullptr) + return ; + pFun( sKey) ; +} + +//----------------------------------------------------------------------------- +IEGrScene* +MyCreateEGrScene( void) +{ + // verifico caricamento libreria MachMgr + if ( s_hEGr == nullptr) + return nullptr ; + // recupero funzione creazione oggetto + typedef IEGrScene* (* PF_CreateEGrScene) ( void) ; + PF_CreateEGrScene pFun = (PF_CreateEGrScene)GetProcAddress( s_hEGr, EGR_CREATEEGRSCENE) ; + if ( pFun == nullptr) + return nullptr ; + return pFun() ; +} + +//----------------------------------------------------------------------------- +ISceExecutor* +MyCreateSceExecutor( void) +{ + // verifico caricamento libreria MachMgr + if ( s_hEGr == nullptr) + return nullptr ; + // recupero funzione creazione oggetto + typedef ISceExecutor* (* PF_CreateSceExecutor) ( void) ; + PF_CreateSceExecutor pFun = (PF_CreateSceExecutor)GetProcAddress( s_hEGr, EGR_CREATESCEEXECUTOR) ; + if ( pFun == nullptr) + return nullptr ; + return pFun() ; +} diff --git a/DllGraphics.h b/DllGraphics.h new file mode 100644 index 0000000..237950e --- /dev/null +++ b/DllGraphics.h @@ -0,0 +1,30 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : DllGraphics.h Data : 27.03.15 Versione : 1.6c9 +// Contenuto : Dichiarazioni funzioni per libreria opzionale EgtGraphics. +// +// +// +// Modifiche : 27.03.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include + +class ILogger ; +class IEGrScene ; +class ISceExecutor ; + +//---------------------------------------------------------------------------- +bool LoadGraphicsDll( void) ; +bool FreeGraphicsDll( void) ; +bool IsLoadedGraphicsDll( void) ; +void MySetEGrLogger( ILogger* pLogger) ; +void MySetEGrKey( const std::string& sKey) ; +const char* MyGetEGrVersion( void) ; +IEGrScene* MyCreateEGrScene( void) ; +ISceExecutor* MyCreateSceExecutor(void) ; diff --git a/DllMachKernel.cpp b/DllMachKernel.cpp new file mode 100644 index 0000000..fd14329 --- /dev/null +++ b/DllMachKernel.cpp @@ -0,0 +1,133 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : DllMachKernel.cpp Data : 27.03.15 Versione : 1.6c9 +// Contenuto : Funzioni di gestione della libreria opzionale EgtMachKernel. +// +// +// +// Modifiche : 27.03.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "DllMachKernel.h" +#define NOMINMAX +#include + +using namespace std ; + +//----------------------------------------------------------------------------- +// Nome della libreria +#if defined( _WIN64) && defined( _DEBUG) + static const wchar_t* EMK_NAME = L"EgtMachKernelD64.dll" ; +#elif defined( _WIN64) + static const wchar_t* EMK_NAME = L"EgtMachKernelR64.dll" ; +#elif defined( _WIN32) && defined( _DEBUG) + static const wchar_t* EMK_NAME = L"EgtMachKernelD32.dll" ; +#else + static const wchar_t* EMK_NAME = L"EgtMachKernelR32.dll" ; +#endif +// Nome delle funzioni caricate +static const char* EMK_SETEMKLOGGER = "SetEMkLogger" ; +static const char* EMK_GETEMKVERSION = "GetEMkVersion" ; +static const char* EMK_SETEMKKEY = "SetEMkKey" ; +static const char* EMK_CREATEMACHMGR = "CreateMachMgr" ; + + +//----------------------------------------------------------------------------- +HMODULE s_hEMk = nullptr ; + +//----------------------------------------------------------------------------- +bool +LoadMachKernelDll( void) +{ + // se già caricata + if ( s_hEMk != nullptr) + return true ; + // carico la libreria EgtMachKernel + s_hEMk = LoadLibrary( EMK_NAME) ; + return ( s_hEMk != nullptr) ; +} + +//----------------------------------------------------------------------------- +bool +FreeMachKernelDll( void) +{ + // se non è già caricata + if ( s_hEMk == nullptr) + return true ; + // libero la libreria EgtMachKernel + FreeLibrary( s_hEMk) ; + s_hEMk = nullptr ; + return true ; +} + +//----------------------------------------------------------------------------- +bool +IsLoadedMachKernelDll( void) +{ + return ( s_hEMk != nullptr) ; +} + +//----------------------------------------------------------------------------- +void +MySetEMkLogger( ILogger* pLogger) +{ + // verifico caricamento libreria MachMgr + if ( s_hEMk == nullptr) + return ; + // recupero funzione che imposta il logger + typedef void (* PF_SetEMkLogger) ( ILogger* pLogger) ; + PF_SetEMkLogger pFun = (PF_SetEMkLogger)GetProcAddress( s_hEMk, EMK_SETEMKLOGGER) ; + if ( pFun == nullptr) + return ; + pFun( pLogger) ; +} + +//----------------------------------------------------------------------------- +const char* +MyGetEMkVersion( void) +{ + // verifico caricamento libreria MachMgr + if ( s_hEMk == nullptr) + return "" ; + // recupero funzione che restituisce la versione della libreria + typedef const char* (* PF_GetEMkVersion) ( void) ; + PF_GetEMkVersion pFun = (PF_GetEMkVersion)GetProcAddress( s_hEMk, EMK_GETEMKVERSION) ; + if ( pFun == nullptr) + return "" ; + return pFun() ; +} + +//----------------------------------------------------------------------------- +void +MySetEMkKey( const string& sKey) +{ + // verifico caricamento libreria MachMgr + if ( s_hEMk == nullptr) + return ; + // recupero funzione che imposta i codici di protezione + typedef void (* PF_SetEMkKey) ( const string& sKey) ; + PF_SetEMkKey pFun = (PF_SetEMkKey)GetProcAddress( s_hEMk, EMK_SETEMKKEY) ; + if ( pFun == nullptr) + return ; + pFun( sKey) ; +} + +//----------------------------------------------------------------------------- +IMachMgr* +MyCreateMachMgr( void) +{ + // verifico caricamento libreria MachMgr + if ( s_hEMk == nullptr) + return nullptr ; + // recupero funzione creazione oggetto + typedef IMachMgr* (* PF_CreateMachMgr) ( void) ; + PF_CreateMachMgr pFun = (PF_CreateMachMgr)GetProcAddress( s_hEMk, EMK_CREATEMACHMGR) ; + if ( pFun == nullptr) + return nullptr ; + return pFun() ; +} diff --git a/DllMachKernel.h b/DllMachKernel.h new file mode 100644 index 0000000..babe4ac --- /dev/null +++ b/DllMachKernel.h @@ -0,0 +1,28 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : DllMachKernel.h Data : 27.03.15 Versione : 1.6c9 +// Contenuto : Dichiarazioni funzioni per libreria opzionale EgtMachKernel. +// +// +// +// Modifiche : 27.03.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include + +class ILogger ; +class IMachMgr ; + +//---------------------------------------------------------------------------- +bool LoadMachKernelDll( void) ; +bool FreeMachKernelDll( void) ; +bool IsLoadedMachKernelDll( void) ; +void MySetEMkLogger( ILogger* pLogger) ; +void MySetEMkKey( const std::string& sKey) ; +const char* MyGetEMkVersion( void) ; +IMachMgr* MyCreateMachMgr( void) ; diff --git a/EgtInterface.rc b/EgtInterface.rc index 8e51660..cbf9b2a 100644 Binary files a/EgtInterface.rc and b/EgtInterface.rc differ diff --git a/EgtInterface.vcxproj b/EgtInterface.vcxproj index bb28794..c7349fe 100644 --- a/EgtInterface.vcxproj +++ b/EgtInterface.vcxproj @@ -211,6 +211,9 @@ copy $(TargetPath) \EgtProg\Dll64 + + + @@ -242,6 +245,9 @@ copy $(TargetPath) \EgtProg\Dll64 + + + diff --git a/EgtInterface.vcxproj.filters b/EgtInterface.vcxproj.filters index 3f0410a..91afdda 100644 --- a/EgtInterface.vcxproj.filters +++ b/EgtInterface.vcxproj.filters @@ -25,6 +25,12 @@ {51194dc4-ffc1-435f-aa51-523e8d34f02a} + + {d42d96c4-e8e4-4bcf-a6de-65b5f0492a14} + + + {85a1c0e1-b6e3-4b5c-be4a-75dc9570c4db} + @@ -33,12 +39,6 @@ File di intestazione - - File di intestazione - - - File di intestazione - File di intestazione @@ -51,18 +51,9 @@ File di intestazione - - File di intestazione - - - File di intestazione - File di intestazione - - File di intestazione - File di intestazione @@ -72,6 +63,30 @@ File di intestazione + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione + + + File di intestazione + + + File di intestazione + @@ -212,6 +227,15 @@ File di origine\LUA + + File di origine\Optional Dll + + + File di origine\Optional Dll + + + File di origine\Optional Dll + diff --git a/stdafx.h b/stdafx.h index b3681f3..d41bf0c 100644 --- a/stdafx.h +++ b/stdafx.h @@ -31,7 +31,4 @@ #pragma comment(lib, EGTLIBDIR "EgtGeneral" EGTLIBVER ".lib") #pragma comment(lib, EGTLIBDIR "EgtNumKernel" EGTLIBVER ".lib") #pragma comment(lib, EGTLIBDIR "EgtGeomKernel" EGTLIBVER ".lib") -#pragma comment(lib, EGTLIBDIR "EgtMachKernel" EGTLIBVER ".lib") -#pragma comment(lib, EGTLIBDIR "EgtExchange" EGTLIBVER ".lib") -#pragma comment(lib, EGTLIBDIR "EgtGraphics" EGTLIBVER ".lib") #pragma comment(lib, EGTEXTDIR "Lua/Lib/Lua52" EGTLIBVER ".lib")