Skip to content

Commit

Permalink
odb: split row and column in dbGDSARef into separate fields/methods
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Liberty <[email protected]>
  • Loading branch information
maliberty committed Jan 2, 2025
1 parent c6aeb06 commit dc393fd
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 18 deletions.
8 changes: 6 additions & 2 deletions src/odb/include/odb/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -7460,9 +7460,13 @@ class dbGDSARef : public dbObject

dbGDSSTrans getTransform() const;

void set_colRow(const std::pair<int16_t, int16_t>& colRow);
void setNumRows(int16_t num_rows);

std::pair<int16_t, int16_t> get_colRow() const;
int16_t getNumRows() const;

void setNumColumns(int16_t num_columns);

int16_t getNumColumns() const;

// User Code Begin dbGDSARef
dbGDSStructure* getStructure() const;
Expand Down
11 changes: 8 additions & 3 deletions src/odb/src/codeGenerator/schema/gds/dbGDSARef.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@
"flags":[]
},
{
"name":"_colRow",
"type":"std::pair<int16_t,int16_t>",
"flags":["no-template"]
"name":"_num_rows",
"type":"int16_t",
"default":"1"
},
{
"name":"_num_columns",
"type":"int16_t",
"default":"1"
},
{
"name":"_structure",
Expand Down
41 changes: 35 additions & 6 deletions src/odb/src/db/dbGDSARef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ bool _dbGDSARef::operator==(const _dbGDSARef& rhs) const
if (_ul != rhs._ul) {
return false;
}
if (_num_rows != rhs._num_rows) {
return false;
}
if (_num_columns != rhs._num_columns) {
return false;
}
if (_structure != rhs._structure) {
return false;
}
Expand All @@ -76,6 +82,8 @@ void _dbGDSARef::differences(dbDiff& diff,
DIFF_FIELD(_origin);
DIFF_FIELD(_lr);
DIFF_FIELD(_ul);
DIFF_FIELD(_num_rows);
DIFF_FIELD(_num_columns);
DIFF_FIELD(_structure);
DIFF_END
}
Expand All @@ -86,20 +94,26 @@ void _dbGDSARef::out(dbDiff& diff, char side, const char* field) const
DIFF_OUT_FIELD(_origin);
DIFF_OUT_FIELD(_lr);
DIFF_OUT_FIELD(_ul);
DIFF_OUT_FIELD(_num_rows);
DIFF_OUT_FIELD(_num_columns);
DIFF_OUT_FIELD(_structure);

DIFF_END
}

_dbGDSARef::_dbGDSARef(_dbDatabase* db)
{
_num_rows = 1;
_num_columns = 1;
}

_dbGDSARef::_dbGDSARef(_dbDatabase* db, const _dbGDSARef& r)
{
_origin = r._origin;
_lr = r._lr;
_ul = r._ul;
_num_rows = r._num_rows;
_num_columns = r._num_columns;
_structure = r._structure;
}

Expand All @@ -110,7 +124,8 @@ dbIStream& operator>>(dbIStream& stream, _dbGDSARef& obj)
stream >> obj._ul;
stream >> obj._propattr;
stream >> obj._transform;
stream >> obj._colRow;
stream >> obj._num_rows;
stream >> obj._num_columns;
stream >> obj._structure;
return stream;
}
Expand All @@ -122,7 +137,8 @@ dbOStream& operator<<(dbOStream& stream, const _dbGDSARef& obj)
stream << obj._ul;
stream << obj._propattr;
stream << obj._transform;
stream << obj._colRow;
stream << obj._num_rows;
stream << obj._num_columns;
stream << obj._structure;
return stream;
}
Expand Down Expand Up @@ -185,17 +201,30 @@ dbGDSSTrans dbGDSARef::getTransform() const
return obj->_transform;
}

void dbGDSARef::set_colRow(const std::pair<int16_t, int16_t>& colRow)
void dbGDSARef::setNumRows(int16_t num_rows)
{
_dbGDSARef* obj = (_dbGDSARef*) this;

obj->_num_rows = num_rows;
}

int16_t dbGDSARef::getNumRows() const
{
_dbGDSARef* obj = (_dbGDSARef*) this;
return obj->_num_rows;
}

void dbGDSARef::setNumColumns(int16_t num_columns)
{
_dbGDSARef* obj = (_dbGDSARef*) this;

obj->_colRow = colRow;
obj->_num_columns = num_columns;
}

std::pair<int16_t, int16_t> dbGDSARef::get_colRow() const
int16_t dbGDSARef::getNumColumns() const
{
_dbGDSARef* obj = (_dbGDSARef*) this;
return obj->_colRow;
return obj->_num_columns;
}

// User Code Begin dbGDSARefPublicMethods
Expand Down
3 changes: 2 additions & 1 deletion src/odb/src/db/dbGDSARef.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ class _dbGDSARef : public _dbObject
Point _ul;
std::vector<std::pair<std::int16_t, std::string>> _propattr;
dbGDSSTrans _transform;
std::pair<int16_t, int16_t> _colRow;
int16_t _num_rows;
int16_t _num_columns;
dbId<_dbGDSStructure> _structure;
};
dbIStream& operator>>(dbIStream& stream, _dbGDSARef& obj);
Expand Down
5 changes: 2 additions & 3 deletions src/odb/src/gdsin/gdsin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,9 @@ dbGDSARef* GDSReader::processARef(dbGDSStructure* structure)
}

if (_r.type == RecordType::COLROW) {
aref->set_colRow({_r.data16[0], _r.data16[1]});
aref->setNumColumns(_r.data16[0]);
aref->setNumRows(_r.data16[1]);
readRecord();
} else {
aref->set_colRow({1, 1});
}

std::vector<Point> points = processXY();
Expand Down
7 changes: 4 additions & 3 deletions src/odb/src/gdsout/gdsout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,6 @@ void GDSWriter::writeSRef(dbGDSSRef* sref)
void GDSWriter::writeARef(dbGDSARef* aref)
{
record_t r;
auto colrow = aref->get_colRow();
r.type = RecordType::AREF;
r.dataType = DataType::NO_DATA;
writeRecord(r);
Expand All @@ -403,11 +402,13 @@ void GDSWriter::writeARef(dbGDSARef* aref)
writeSTrans(aref->getTransform());
}

if (colrow.first != 1 || colrow.second != 1) {
const int16_t cols = aref->getNumColumns();
const int16_t rows = aref->getNumRows();
if (cols != 1 || rows != 1) {
record_t r4;
r4.type = RecordType::COLROW;
r4.dataType = DataType::INT_2;
r4.data16 = {colrow.first, colrow.second};
r4.data16 = {cols, rows};
writeRecord(r4);
}

Expand Down

0 comments on commit dc393fd

Please sign in to comment.