44// Generator Code Begin Cpp
55#include " dbChip.h"
66
7- #include < string>
8-
97#include " dbBlock.h"
108#include " dbBlockItr.h"
119#include " dbDatabase.h"
@@ -22,7 +20,7 @@ template class dbTable<_dbChip>;
2220
2321bool _dbChip::operator ==(const _dbChip& rhs) const
2422{
25- if (name_ != rhs.name_ ) {
23+ if (_name != rhs._name ) {
2624 return false ;
2725 }
2826 if (type_ != rhs.type_ ) {
@@ -76,6 +74,9 @@ bool _dbChip::operator==(const _dbChip& rhs) const
7674 if (*_prop_tbl != *rhs._prop_tbl ) {
7775 return false ;
7876 }
77+ if (_next_entry != rhs._next_entry ) {
78+ return false ;
79+ }
7980
8081 // User Code Begin ==
8182 if (*_block_tbl != *rhs._block_tbl ) {
@@ -99,6 +100,7 @@ bool _dbChip::operator<(const _dbChip& rhs) const
99100
100101_dbChip::_dbChip (_dbDatabase* db)
101102{
103+ _name = nullptr ;
102104 type_ = 0 ;
103105 offset_ = {};
104106 width_ = 0 ;
@@ -131,7 +133,7 @@ _dbChip::_dbChip(_dbDatabase* db)
131133dbIStream& operator >>(dbIStream& stream, _dbChip& obj)
132134{
133135 if (obj.getDatabase ()->isSchema (db_schema_chip_extended)) {
134- stream >> obj.name_ ;
136+ stream >> obj._name ;
135137 }
136138 if (obj.getDatabase ()->isSchema (db_schema_chip_extended)) {
137139 stream >> obj.type_ ;
@@ -183,14 +185,17 @@ dbIStream& operator>>(dbIStream& stream, _dbChip& obj)
183185 stream >> *obj._block_tbl ;
184186 stream >> *obj._prop_tbl ;
185187 stream >> *obj._name_cache ;
188+ if (obj.getDatabase ()->isSchema (db_schema_chip_hash_table)) {
189+ stream >> obj._next_entry ;
190+ }
186191 // User Code End >>
187192 return stream;
188193}
189194
190195dbOStream& operator <<(dbOStream& stream, const _dbChip& obj)
191196{
192197 dbOStreamScope scope (stream, " dbChip" );
193- stream << obj.name_ ;
198+ stream << obj._name ;
194199 stream << obj.type_ ;
195200 stream << obj.offset_ ;
196201 stream << obj.width_ ;
@@ -211,6 +216,7 @@ dbOStream& operator<<(dbOStream& stream, const _dbChip& obj)
211216 stream << *obj._block_tbl ;
212217 stream << NamedTable (" prop_tbl" , obj._prop_tbl );
213218 stream << *obj._name_cache ;
219+ stream << obj._next_entry ;
214220 // User Code End <<
215221 return stream;
216222}
@@ -244,6 +250,9 @@ void _dbChip::collectMemInfo(MemInfo& info)
244250
245251_dbChip::~_dbChip ()
246252{
253+ if (_name) {
254+ free ((void *) _name);
255+ }
247256 delete _prop_tbl;
248257 // User Code Begin Destructor
249258 delete _block_tbl;
@@ -259,10 +268,10 @@ _dbChip::~_dbChip()
259268//
260269// //////////////////////////////////////////////////////////////////
261270
262- std::string dbChip::getName () const
271+ const char * dbChip::getName () const
263272{
264273 _dbChip* obj = (_dbChip*) this ;
265- return obj->name_ ;
274+ return obj->_name ;
266275}
267276
268277void dbChip::setOffset (Point offset)
@@ -448,6 +457,13 @@ bool dbChip::isTsv() const
448457}
449458
450459// User Code Begin dbChipPublicMethods
460+
461+ dbChip::ChipType dbChip::getChipType () const
462+ {
463+ _dbChip* obj = (_dbChip*) this ;
464+ return (dbChip::ChipType) obj->type_ ;
465+ }
466+
451467dbBlock* dbChip::getBlock ()
452468{
453469 _dbChip* chip = (_dbChip*) this ;
@@ -459,31 +475,35 @@ dbBlock* dbChip::getBlock()
459475 return (dbBlock*) chip->_block_tbl ->getPtr (chip->_top );
460476}
461477
462- dbChip* dbChip::create (dbDatabase* db_)
478+ dbChip* dbChip::create (dbDatabase* db_, const std::string& name, ChipType type )
463479{
464480 _dbDatabase* db = (_dbDatabase*) db_;
465-
466- if (db->_chip != 0 ) {
467- return nullptr ;
481+ _dbChip* chip = db->chip_tbl_ ->create ();
482+ chip->_name = safe_strdup (name.c_str ());
483+ chip->type_ = (uint) type;
484+ if (db->_chip == 0 ) {
485+ db->_chip = chip->getOID ();
468486 }
469-
470- _dbChip* chip = db->_chip_tbl ->create ();
471- db->_chip = chip->getOID ();
487+ db->chip_hash_ .insert (chip);
472488 return (dbChip*) chip;
473489}
474490
475491dbChip* dbChip::getChip (dbDatabase* db_, uint dbid_)
476492{
477493 _dbDatabase* db = (_dbDatabase*) db_;
478- return (dbChip*) db->_chip_tbl ->getPtr (dbid_);
494+ return (dbChip*) db->chip_tbl_ ->getPtr (dbid_);
479495}
480496
481497void dbChip::destroy (dbChip* chip_)
482498{
483499 _dbChip* chip = (_dbChip*) chip_;
484500 _dbDatabase* db = chip->getDatabase ();
501+ if (db->_chip == chip->getOID ()) {
502+ db->_chip = 0 ;
503+ }
485504 dbProperty::destroyProperties (chip);
486- db->_chip_tbl ->destroy (chip);
505+ db->chip_hash_ .remove (chip);
506+ db->chip_tbl_ ->destroy (chip);
487507 db->_chip = 0 ;
488508}
489509// User Code End dbChipPublicMethods
0 commit comments