685966ac11
- aggiunta prima gestione semplice della macchina.
116 lines
3.9 KiB
C++
116 lines
3.9 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : MachMgrMachines.cpp Data : 02.05.15 Versione : 1.6e1
|
|
// Contenuto : Implementazione gestione macchine della classe MachMgr.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 02.05.15 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "MachMgr.h"
|
|
#include "MachConst.h"
|
|
#include "/EgtDev/Include/EGkGdbIterator.h"
|
|
#include "/EgtDev/Include/EgnStringUtils.h"
|
|
#include "/EgtDev/Include/EgnFileUtils.h"
|
|
#include "/EgtDev/Include/EgtPointerOwner.h"
|
|
|
|
using namespace std ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::LoadMachine( const string& sMachineName)
|
|
{
|
|
// verifico validità del nome
|
|
if ( ! IsValidName( sMachineName))
|
|
return false ;
|
|
// se macchina già caricata, non devo fare alcunchè
|
|
if ( GetMachine( sMachineName) != - 1)
|
|
return true ;
|
|
// creo gruppo ausiliario di base per le macchine
|
|
if ( ! CreateMachAux())
|
|
return false ;
|
|
// creo una nuova macchina
|
|
PtrOwner<Machine> pMch( new( nothrow) Machine) ;
|
|
if ( IsNull( pMch))
|
|
return false ;
|
|
// tento di caricarla
|
|
string sMachineDir = m_sMachinesDir + "\\" + sMachineName ;
|
|
if ( pMch->Init( m_nContextId, m_pGeomDB, m_nMachAuxId, sMachineDir, sMachineName)) {
|
|
m_vMachines.push_back( Release( pMch)) ;
|
|
return true ;
|
|
}
|
|
return false ;
|
|
|
|
#if 0
|
|
// verifico esistenza macchina
|
|
string sMachineDir = m_sMachinesDir + "\\" + sMachineName ;
|
|
string sMachineMde = sMachineDir + "\\" + sMachineName + ".Mde" ;
|
|
if ( ! ExistsFile( sMachineMde))
|
|
return false ;
|
|
// carico la macchina
|
|
if ( ! CreateMachAux())
|
|
return false ;
|
|
// creo il gruppo per la macchina
|
|
int nId = m_pGeomDB->InsertGroup( GDB_ID_NULL, m_nMachAuxId, GDB_LAST_SON, GLOB_FRM) ;
|
|
if ( nId == GDB_ID_NULL)
|
|
return false ;
|
|
// imposto nome del gruppo
|
|
m_pGeomDB->SetName( nId, sMachineName) ;
|
|
// inserisco la geometria della macchina !!! PROVVISORIO !!!
|
|
string sMachineNge = sMachineDir + "\\" + sMachineName + ".Nge" ;
|
|
return m_pGeomDB->Load( sMachineNge, nId) ;
|
|
#endif
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
MachMgr::GetMachine( const string& sMachineName) const
|
|
{
|
|
// ciclo sulle macchine
|
|
for ( size_t i = 0 ; i < m_vMachines.size() ; ++ i) {
|
|
if ( m_vMachines[i] != nullptr &&
|
|
CompareNoCase( m_vMachines[i]->GetMachineName(), sMachineName))
|
|
return int( i) ;
|
|
}
|
|
return - 1 ;
|
|
|
|
#if 0
|
|
// verifico validità del nome
|
|
if ( ! IsValidName( sMachineName))
|
|
return GDB_ID_NULL ;
|
|
// se non c'è il gruppo ausiliario per le macchine, non ci può essere la macchina
|
|
if ( ! VerifyMachAux())
|
|
return GDB_ID_NULL ;
|
|
// recupero l'identificativo del gruppo con il nome indicato
|
|
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGeomDB)) ;
|
|
if ( IsNull( pIter))
|
|
return GDB_ID_NULL ;
|
|
bool bIter = pIter->GoToFirstGroupInGroup( m_nMachAuxId) ;
|
|
while( bIter) {
|
|
// verifico il nome
|
|
string sMGroupName ;
|
|
if ( pIter->GetName( sMGroupName) && sMGroupName == sMachineName)
|
|
return pIter->GetId() ;
|
|
// passo al successivo
|
|
bIter = pIter->GoToNextGroup() ;
|
|
}
|
|
return GDB_ID_NULL ;
|
|
#endif
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
MachMgr::GetCurrMGeoId( void) const
|
|
{
|
|
if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()) ||
|
|
m_vMachines[m_nCurrMch] == nullptr)
|
|
return GDB_ID_NULL ;
|
|
return ( m_vMachines[m_nCurrMch]->GetMGeoId()) ;
|
|
}
|