EgtGeomKernel :

- gestione cancellazione oggetti puntati da GdbIterator
- aggiunte a GdbIterator EraseAndGoToNext e EraseAndGoToPrev
- possibilità di passare IGeomDB* al costruttore di GdbIterator.
This commit is contained in:
Dario Sassi
2014-03-23 21:38:09 +00:00
parent 155c722466
commit 033236491d
10 changed files with 176 additions and 19 deletions
+43 -6
View File
@@ -21,24 +21,29 @@ using namespace std ;
//----------------------------------------------------------------------------
IGdbIterator*
CreateGdbIterator( void)
CreateGdbIterator( IGeomDB* pGDB)
{
return static_cast<IGdbIterator*> ( new GdbIterator) ;
return static_cast<IGdbIterator*> ( new GdbIterator( pGDB) ) ;
}
//----------------------------------------------------------------------------
// GdbIterator
//----------------------------------------------------------------------------
GdbIterator::GdbIterator( void)
GdbIterator::GdbIterator( IGeomDB* pGDB)
{
m_pGDB = nullptr ;
if ( pGDB != nullptr)
SetGDB( pGDB) ;
else
m_pGDB = nullptr ;
m_pCurrObj = nullptr ;
}
//----------------------------------------------------------------------------
GdbIterator::~GdbIterator( void)
{
// TODO : togliere link da GdbGeom per essere notificato della cancellazione di nodi
if ( m_pGDB != nullptr)
m_pGDB->RemoveGdbIteratorFromList( this) ;
}
//----------------------------------------------------------------------------
@@ -46,8 +51,10 @@ bool
GdbIterator::SetGDB( IGeomDB* pGDB)
{
m_pGDB = dynamic_cast<GeomDB*>( pGDB) ;
if ( m_pGDB == nullptr)
return false ;
return ( m_pGDB != nullptr) ;
return m_pGDB->AddGdbIteratorToList( this) ;
}
//----------------------------------------------------------------------------
@@ -188,6 +195,36 @@ GdbIterator::GoToPrev( void)
return ( m_pCurrObj != nullptr) ;
}
//----------------------------------------------------------------------------
bool
GdbIterator::EraseAndGoToNext( void)
{
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
// passo al successivo
GdbObj* pObjToErase = m_pCurrObj ;
m_pCurrObj = m_pCurrObj->GetNext() ;
// eseguo cancellazione
m_pGDB->Erase( pObjToErase) ;
return ( m_pCurrObj != nullptr) ;
}
//----------------------------------------------------------------------------
bool
GdbIterator::EraseAndGoToPrev( void)
{
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
return false ;
// passo al precedente
GdbObj* pObjToErase = m_pCurrObj ;
m_pCurrObj = m_pCurrObj->GetPrev() ;
// eseguo cancellazione
m_pGDB->Erase( pObjToErase) ;
return true ;
}
//----------------------------------------------------------------------------
int
GdbIterator::GetGdbType( void) const