Files
EgtGeomKernel/GdbObj.cpp
T

120 lines
3.0 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2013-2013
//----------------------------------------------------------------------------
// File : GdbObj.cpp Data : 24.11.13 Versione : 1.3a1
// Contenuto : Implementazione della classe CGdbObj oggetto del DB geometrico.
//
//
//
// Modifiche : 22.01.13 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include <new>
#include "\EgtDev\Include\EGnStringUtils.h"
#include "GdbObj.h"
#include "GeoObjFactory.h"
using namespace std ;
//----------------------------------------------------------------------------
GdbObj::GdbObj( void)
{
m_pGeoObj = nullptr ;
}
//----------------------------------------------------------------------------
GdbObj::~GdbObj( void)
{
if ( m_pGeoObj != nullptr)
delete m_pGeoObj ;
m_pGeoObj = nullptr ;
}
//----------------------------------------------------------------------------
GdbObj*
GdbObj::Clone( void) const
{
GdbObj* pGdbObj ;
// alloco oggetto Gdb
pGdbObj = new(nothrow) GdbObj ;
if ( pGdbObj != nullptr) {
// copio dati oggetto Gdb
// ...
// copio oggetto Geo
pGdbObj->m_pGeoObj = m_pGeoObj->Clone() ;
}
return pGdbObj ;
}
//----------------------------------------------------------------------------
GeoObjType
GdbObj::GetType( void) const
{
// non esiste l'oggetto geometrico
if ( m_pGeoObj == nullptr)
return GEO_NONE ;
return m_pGeoObj->GetType() ;
}
//----------------------------------------------------------------------------
bool
GdbObj::Save( std::ostream& osOut) const
{
// tipo entità
osOut << m_pGeoObj->GetKey() << endl ;
// nome
osOut << m_nId << endl ;
// parametri geometrici
return m_pGeoObj->Save( osOut) ;
return true ;
}
//----------------------------------------------------------------------------
bool
GdbObj::Load( CScan& TheScanner, string& sErrLine)
{
int nType ;
string sLine ;
STRVECTOR vsParams ;
// reset linea errata
sErrLine.clear() ;
// leggo la prossima linea : tipo di entità
if ( ! TheScanner.GetLine( sLine))
return false ;
// creo l'oggetto geometrico corrispondente
nType = GEOOBJ_KEYTOTYPE( sLine) ;
m_pGeoObj = GEOOBJ_CREATE( nType) ;
if ( m_pGeoObj == nullptr) {
sErrLine = sLine ;
return false ;
}
// leggo la prossima linea
if ( ! TheScanner.GetLine( sLine))
return false ;
// la divido in parametri
Tokenize( sLine, ",", vsParams) ;
// 1 parametro : Id
if ( vsParams.size() != 1)
return false ;
// assegno l'identificativo
if ( ! FromString( vsParams[0], m_nId))
return false ;
// parametri geometrici
return m_pGeoObj->Load( TheScanner) ;
}