EgtGeomKernel :

- migliorie a IdManager per aggiornamento dopo cancellazione entità.
This commit is contained in:
Dario Sassi
2018-12-12 07:31:51 +00:00
parent 06b8c000fd
commit 974d050025
+9 -14
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2013
// EgalTech 2013-2018
//----------------------------------------------------------------------------
// File : IdManager.h Data : 02.12.13 Versione : 1.4a3
// File : IdManager.h Data : 11.12.18 Versione : 1.9l2
// Contenuto : Dichiarazione e implementazione della classe IdManager.
//
//
@@ -14,8 +14,6 @@
#pragma once
#include <unordered_map>
#include <algorithm>
//----------------------------------------------------------------------------
class IdManager
@@ -45,8 +43,7 @@ class IdManager
return m_GdbIdMap.emplace( nId, pGObj).second ; }
bool RemoveObj( int nId)
{ m_GdbIdMap.erase( nId) ;
if ( nId == m_nMaxId && m_nMaxId > 0)
UpdateMaxId() ;
UpdateMaxId() ;
return true ; }
int GetNewId( void) const
{ return ( m_nMaxId + 1) ; }
@@ -56,14 +53,12 @@ class IdManager
{ if ( nId > m_nMaxId)
m_nMaxId = nId ; }
void UpdateMaxId( void)
{ int nMaxId = 0 ;
if ( m_GdbIdMap.find( m_nMaxId - 1) != m_GdbIdMap.end()) {
-- m_nMaxId ;
return ;
}
for (const auto& Igdbo : m_GdbIdMap)
nMaxId = std::max( nMaxId, Igdbo.first) ;
m_nMaxId = nMaxId ; }
{ while ( m_nMaxId > 0) {
if ( m_GdbIdMap.find( m_nMaxId) == m_GdbIdMap.end())
-- m_nMaxId ;
else
return ;
} }
private :
typedef std::unordered_map< int, GdbObj*> INTPGDBO_UMAP ;