//---------------------------------------------------------------------------- // EgalTech 2014-2014 //---------------------------------------------------------------------------- // File : SelManager.h Data : 19.05.14 Versione : 1.5e7 // Contenuto : Dichiarazione e implementazione della classe SelManager. // // // // Modifiche : 19.03.14 DS Creazione modulo. // 19.05.14 DS La AddObj non controlla eventuale precedente presenza // oggetto in lista, perchè già si fa tramite flag di GdbObj. // //---------------------------------------------------------------------------- #pragma once #include class GdbObj ; //---------------------------------------------------------------------------- typedef std::list 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 AddObj( GdbObj* pGObj) { if ( pGObj == nullptr) return false ; 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) ; } GdbObj* GetLastObj( void) const { m_Iter = m_SelList.end() ; if ( m_Iter == m_SelList.begin()) return nullptr ; -- m_Iter ; if ( m_Iter == m_SelList.end()) return nullptr ; return (*m_Iter) ; } GdbObj* GetPrevObj( void) const { if ( m_Iter == m_SelList.begin()) 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 ; } ;