EgtGeomKernel 1.5b6 :
- adattamenti per modifiche a ICmdParser.
This commit is contained in:
+45
-40
@@ -20,6 +20,7 @@
|
||||
#include "DllMain.h"
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include "/EgtDev/Include/EgnStringConverter.h"
|
||||
#include "/EgtDev/Include/EgnCmdParser.h"
|
||||
#include "/EgtDev/Include/EgkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EgkGeoVector3d.h"
|
||||
#include "/EgtDev/Include/EgkGeoFrame3d.h"
|
||||
@@ -47,12 +48,8 @@ CreateGdbExecutor( void)
|
||||
GdbExecutor::GdbExecutor( void)
|
||||
{
|
||||
m_pGDB = nullptr ;
|
||||
m_pParser = nullptr ;
|
||||
m_pOtherExec = nullptr ;
|
||||
// dimensioni mappa dei nomi
|
||||
m_NameMap.rehash( 100) ;
|
||||
// nomi predefiniti
|
||||
m_NameMap.insert( pair< string, int>( "$ROOT", GDB_ID_ROOT)) ;
|
||||
m_NameMap.insert( pair< string, int>( "$NN", ID_NO)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -62,11 +59,22 @@ GdbExecutor::~GdbExecutor( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::Init( IGeomDB* pGdb)
|
||||
GdbExecutor::SetCmdParser( ICmdParser* pParser)
|
||||
{
|
||||
m_pGDB = pGdb ;
|
||||
// salvo e verifico
|
||||
m_pParser = pParser ;
|
||||
if ( m_pParser == nullptr)
|
||||
return false ;
|
||||
|
||||
return ( m_pGDB != nullptr) ;
|
||||
// imposto eventuale parser dipendente
|
||||
if ( m_pOtherExec != nullptr)
|
||||
m_pOtherExec->SetCmdParser( m_pParser) ;
|
||||
|
||||
// imposto variabili predefinite
|
||||
m_pParser->AddVariable( "$ROOT", GDB_ID_ROOT) ;
|
||||
m_pParser->AddVariable( "$NN", ID_NO) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -77,26 +85,19 @@ GdbExecutor::AddExecutor( ICmdExecutor* pOtherExec)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::SetGeomDB( IGeomDB* pGdb)
|
||||
{
|
||||
m_pGDB = pGdb ;
|
||||
|
||||
return ( m_pGDB != nullptr) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::Execute( const string& sCmd1, const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
string sOut ;
|
||||
STRVECTOR::const_iterator theConstIter ;
|
||||
|
||||
|
||||
// output di debug
|
||||
sOut = " " + sCmd1 ;
|
||||
if ( ! sCmd2.empty())
|
||||
sOut += "." + sCmd2 ;
|
||||
sOut += "( " ;
|
||||
for ( theConstIter = vsParams.begin() ; theConstIter != vsParams.end() ; ++theConstIter) {
|
||||
if ( theConstIter != vsParams.begin())
|
||||
sOut += ", " ;
|
||||
sOut += *theConstIter ;
|
||||
}
|
||||
sOut += ")" ;
|
||||
LOG_DBG_INFO( GetEGkLogger(), sOut.c_str())
|
||||
|
||||
// verifico validita GeomDB
|
||||
if ( m_pGDB == nullptr) {
|
||||
@@ -104,6 +105,12 @@ GdbExecutor::Execute( const string& sCmd1, const string& sCmd2, const STRVECTOR&
|
||||
return false ;
|
||||
}
|
||||
|
||||
// verifico validità CmdParser
|
||||
if ( m_pParser == nullptr) {
|
||||
LOG_ERROR( GetEGkLogger(), "Error : null CmdParser.")
|
||||
return false ;
|
||||
}
|
||||
|
||||
// esecuzione comando
|
||||
if ( sCmd1 == "GR" || sCmd1 == "GROUP")
|
||||
return ExecuteGroup( sCmd2, vsParams) ;
|
||||
@@ -198,9 +205,9 @@ GdbExecutor::ExecuteGroup( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
// creo il gruppo
|
||||
int nIdDest = GetIdParam( vsParams[0], true) ;
|
||||
int nIdNew = m_pGDB->AddGroup( nIdDest, GetIdParam( vsParams[1]), frFrame) ;
|
||||
// se IdDest da calcolare e indicato da Alias, ne cambio il valore
|
||||
if ( nIdDest == GDB_ID_NULL && m_NameMap.find( vsParams[0]) != m_NameMap.end())
|
||||
m_NameMap[vsParams[0]] = nIdNew ;
|
||||
// se IdDest da calcolare, può essere una variabili a cui cambiare il valore
|
||||
if ( nIdDest == GDB_ID_NULL)
|
||||
m_pParser->SetVariable( vsParams[0], nIdNew) ;
|
||||
|
||||
return ( nIdNew != GDB_ID_NULL) ;
|
||||
}
|
||||
@@ -690,9 +697,9 @@ GdbExecutor::AddGeoObj( const string& sId, const string& sIdParent, IGeoObj* pGe
|
||||
// creo il gruppo
|
||||
int nId = GetIdParam( sId, true) ;
|
||||
int nIdNew = m_pGDB->AddGeoObj( nId, GetIdParam( sIdParent), pGeoObj) ;
|
||||
// se IdDest da calcolare e indicato da Alias, ne cambio il valore
|
||||
if ( nId == GDB_ID_NULL && m_NameMap.find( sId) != m_NameMap.end())
|
||||
m_NameMap[sId] = nIdNew ;
|
||||
// se IdDest da calcolare, può essere una variabili a cui cambiare il valore
|
||||
if ( nId == GDB_ID_NULL)
|
||||
m_pParser->SetVariable( sId, nIdNew) ;
|
||||
|
||||
return ( nIdNew != GDB_ID_NULL) ;
|
||||
}
|
||||
@@ -701,19 +708,17 @@ GdbExecutor::AddGeoObj( const string& sId, const string& sIdParent, IGeoObj* pGe
|
||||
int
|
||||
GdbExecutor::GetIdParam( const std::string& sParam, bool bNewAllowed)
|
||||
{
|
||||
int nVal ;
|
||||
NameMap::iterator Iter ;
|
||||
int nVal ;
|
||||
|
||||
|
||||
// se nome di identificatore numerico
|
||||
if ( sParam[0] == '$') {
|
||||
// se già presente nella lista dei nomi, ne restituisco il valore
|
||||
Iter = m_NameMap.find( sParam) ;
|
||||
if ( Iter != m_NameMap.end())
|
||||
return Iter->second ;
|
||||
// se variabile già definita, ne restituisco il valore
|
||||
if ( m_pParser->GetVariable( sParam, nVal))
|
||||
return nVal ;
|
||||
// se ammessa nuova definizione, provo ad inserirlo
|
||||
else if ( bNewAllowed &&
|
||||
m_NameMap.insert( pair< string, int>( sParam, GDB_ID_NULL)).second)
|
||||
m_pParser->AddVariable( sParam, GDB_ID_NULL))
|
||||
return GDB_ID_NULL ;
|
||||
// altrimenti errore
|
||||
else
|
||||
@@ -893,9 +898,9 @@ GdbExecutor::ExecuteCopy( const std::string& sCmd2, const STRVECTOR& vsParams)
|
||||
nIdNew = m_pGDB->CopyGlob( GetIdParam( vsParams[0]), nIdDest, GetIdParam( vsParams[2])) ;
|
||||
else
|
||||
nIdNew = m_pGDB->Copy( GetIdParam( vsParams[0]), nIdDest, GetIdParam( vsParams[2])) ;
|
||||
// se IdDest da calcolare e indicato da Alias, ne cambio il valore
|
||||
if ( nIdDest == GDB_ID_NULL && m_NameMap.find( vsParams[1]) != m_NameMap.end())
|
||||
m_NameMap[vsParams[1]] = nIdNew ;
|
||||
// se IdDest da calcolare, può essere una variabili a cui cambiare il valore
|
||||
if ( nIdDest == GDB_ID_NULL)
|
||||
m_pParser->SetVariable( vsParams[1], nIdNew) ;
|
||||
|
||||
return ( nIdNew != GDB_ID_NULL) ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user