Files
EgtGeomKernel/SelManager.h
T
Dario Sassi 033236491d EgtGeomKernel :
- gestione cancellazione oggetti puntati da GdbIterator
- aggiunte a GdbIterator EraseAndGoToNext e EraseAndGoToPrev
- possibilità di passare IGeomDB* al costruttore di GdbIterator.
2014-03-23 21:38:09 +00:00

77 lines
2.7 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : SelManager.h Data : 19.03.14 Versione : 1.5c8
// Contenuto : Dichiarazione e implementazione della classe SelManager.
//
//
//
// Modifiche : 19.03.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include <list>
class GdbObj ;
//----------------------------------------------------------------------------
typedef std::list<GdbObj*> PGDBO_LIST ;
//----------------------------------------------------------------------------
class SelManager
{
public :
SelManager( void)
{ m_Iter = m_SelList.end() ; }
void Clear( void)
{ m_SelList.clear() ;
m_Iter = m_SelList.end() ; }
int GetSize( void) const
{ return int ( m_SelList.size()) ; }
bool IsObjInList( GdbObj* pGObj)
{ PGDBO_LIST::const_iterator Iter ;
for ( Iter = m_SelList.begin() ; Iter != m_SelList.end() ; ++ Iter) {
if ( *Iter == pGObj)
return true ;
}
return false ; }
bool AddObj( GdbObj* pGObj)
{ if ( pGObj == nullptr)
return false ;
if ( IsObjInList( pGObj))
return true ;
try { m_SelList.push_back( pGObj) ; }
catch (...) { return false ;}
return true ; }
bool RemoveObj( GdbObj* pGObj)
{ PGDBO_LIST::iterator Iter ;
for ( Iter = m_SelList.begin() ; Iter != m_SelList.end() ; ++ Iter) {
if ( *Iter == pGObj) {
if ( Iter == m_Iter)
m_Iter = m_SelList.end() ;
m_SelList.erase( Iter) ;
return true ;
}
}
return true ; }
GdbObj* GetFirstObj( void) const
{ m_Iter = m_SelList.begin() ;
if ( m_Iter == m_SelList.end())
return nullptr ;
return (*m_Iter) ; }
GdbObj* GetNextObj( void) const
{ if ( m_Iter == m_SelList.end())
return nullptr ;
++ m_Iter ;
if ( m_Iter == m_SelList.end())
return nullptr ;
return (*m_Iter) ; }
private :
PGDBO_LIST m_SelList ;
mutable PGDBO_LIST::const_iterator m_Iter ;
} ;