@@ -130,55 +130,55 @@ bool _dbSBox::operator<(const _dbSBox& rhs) const
130130//
131131// //////////////////////////////////////////////////////////////////
132132
133- dbWireShapeType dbSBox::getWireShapeType ()
133+ dbWireShapeType dbSBox::getWireShapeType () const
134134{
135- _dbSBox* box = (_dbSBox*) this ;
135+ const _dbSBox* box = (const _dbSBox*) this ;
136136 return dbWireShapeType (box->_sflags ._wire_type );
137137}
138138
139- dbSBox::Direction dbSBox::getDirection ()
139+ dbSBox::Direction dbSBox::getDirection () const
140140{
141- _dbSBox* box = (_dbSBox*) this ;
141+ const _dbSBox* box = (const _dbSBox*) this ;
142142 return (dbSBox::Direction) box->_sflags ._direction ;
143143}
144144
145- dbSWire* dbSBox::getSWire ()
145+ dbSWire* dbSBox::getSWire () const
146146{
147147 return (dbSWire*) getBoxOwner ();
148148}
149149
150- Oct dbSBox::getOct ()
150+ Oct dbSBox::getOct () const
151151{
152- _dbSBox* box = (_dbSBox*) this ;
152+ const _dbSBox* box = (const _dbSBox*) this ;
153153 return box->_shape ._oct ;
154154}
155155
156- uint dbSBox::getViaBottomLayerMask ()
156+ uint dbSBox::getViaBottomLayerMask () const
157157{
158- _dbSBox* box = (_dbSBox*) this ;
158+ const _dbSBox* box = (const _dbSBox*) this ;
159159 return box->_sflags ._via_bottom_mask ;
160160}
161161
162- uint dbSBox::getViaCutLayerMask ()
162+ uint dbSBox::getViaCutLayerMask () const
163163{
164- _dbSBox* box = (_dbSBox*) this ;
164+ const _dbSBox* box = (const _dbSBox*) this ;
165165 return box->_sflags ._via_cut_mask ;
166166}
167167
168- uint dbSBox::getViaTopLayerMask ()
168+ uint dbSBox::getViaTopLayerMask () const
169169{
170- _dbSBox* box = (_dbSBox*) this ;
170+ const _dbSBox* box = (const _dbSBox*) this ;
171171 return box->_sflags ._via_top_mask ;
172172}
173173
174- bool dbSBox::hasViaLayerMasks ()
174+ bool dbSBox::hasViaLayerMasks () const
175175{
176- _dbSBox* box = (_dbSBox*) this ;
176+ const _dbSBox* box = (const _dbSBox*) this ;
177177 return box->_sflags ._via_bottom_mask != 0 || box->_sflags ._via_cut_mask != 0
178178 || box->_sflags ._via_top_mask != 0 ;
179179}
180180
181- void dbSBox::setViaLayerMask (uint bottom, uint cut, uint top)
181+ void dbSBox::setViaLayerMask (const uint bottom, const uint cut, const uint top)
182182{
183183 _dbSBox* box = (_dbSBox*) this ;
184184 box->checkMask (bottom);
@@ -192,31 +192,20 @@ void dbSBox::setViaLayerMask(uint bottom, uint cut, uint top)
192192
193193dbSBox* dbSBox::create (dbSWire* wire_,
194194 dbTechLayer* layer_,
195- int x1,
196- int y1,
197- int x2,
198- int y2,
199- dbWireShapeType type,
200- Direction dir,
201- int width)
195+ const int x1,
196+ const int y1,
197+ const int x2,
198+ const int y2,
199+ const dbWireShapeType type,
200+ const Direction dir,
201+ const int width)
202202{
203203 _dbSWire* wire = (_dbSWire*) wire_;
204204 _dbBlock* block = (_dbBlock*) wire->getOwner ();
205205 _dbSBox* box = block->_sbox_tbl ->create ();
206206
207- uint dx;
208- if (x2 > x1) {
209- dx = x2 - x1;
210- } else {
211- dx = x1 - x2;
212- }
213-
214- uint dy;
215- if (y2 > y1) {
216- dy = y2 - y1;
217- } else {
218- dy = y1 - y2;
219- }
207+ const uint dx = std::abs (x2 - x1);
208+ const uint dy = std::abs (y2 - y1);
220209
221210 switch (dir) {
222211 case UNDEFINED:
@@ -247,8 +236,8 @@ dbSBox* dbSBox::create(dbSWire* wire_,
247236 box->_flags ._layer_id = layer_->getImpl ()->getOID ();
248237 box->_flags ._owner_type = dbBoxOwner::SWIRE;
249238 if (dir == OCTILINEAR) {
250- Point p1 (x1, y1);
251- Point p2 (x2, y2);
239+ const Point p1 (x1, y1);
240+ const Point p2 (x2, y2);
252241 new (&box->_shape ._oct ) Oct ();
253242 box->_shape ._oct .init (p1, p2, width);
254243 box->_flags ._octilinear = true ;
@@ -269,9 +258,9 @@ dbSBox* dbSBox::create(dbSWire* wire_,
269258
270259dbSBox* dbSBox::create (dbSWire* wire_,
271260 dbVia* via_,
272- int x,
273- int y,
274- dbWireShapeType type)
261+ const int x,
262+ const int y,
263+ const dbWireShapeType type)
275264{
276265 _dbSWire* wire = (_dbSWire*) wire_;
277266 _dbVia* via = (_dbVia*) via_;
@@ -282,10 +271,10 @@ dbSBox* dbSBox::create(dbSWire* wire_,
282271 }
283272
284273 _dbBox* vbbox = block->_box_tbl ->getPtr (via->_bbox );
285- int xmin = vbbox->_shape ._rect .xMin () + x;
286- int ymin = vbbox->_shape ._rect .yMin () + y;
287- int xmax = vbbox->_shape ._rect .xMax () + x;
288- int ymax = vbbox->_shape ._rect .yMax () + y;
274+ const int xmin = vbbox->_shape ._rect .xMin () + x;
275+ const int ymin = vbbox->_shape ._rect .yMin () + y;
276+ const int xmax = vbbox->_shape ._rect .xMax () + x;
277+ const int ymax = vbbox->_shape ._rect .yMax () + y;
289278 _dbSBox* box = block->_sbox_tbl ->create ();
290279 box->_flags ._owner_type = dbBoxOwner::SWIRE;
291280 box->_shape ._rect .init (xmin, ymin, xmax, ymax);
@@ -302,9 +291,9 @@ dbSBox* dbSBox::create(dbSWire* wire_,
302291
303292dbSBox* dbSBox::create (dbSWire* wire_,
304293 dbTechVia* via_,
305- int x,
306- int y,
307- dbWireShapeType type)
294+ const int x,
295+ const int y,
296+ const dbWireShapeType type)
308297{
309298 _dbSWire* wire = (_dbSWire*) wire_;
310299 _dbTechVia* via = (_dbTechVia*) via_;
@@ -316,10 +305,10 @@ dbSBox* dbSBox::create(dbSWire* wire_,
316305
317306 _dbTech* tech = (_dbTech*) via->getOwner ();
318307 _dbBox* vbbox = tech->_box_tbl ->getPtr (via->_bbox );
319- int xmin = vbbox->_shape ._rect .xMin () + x;
320- int ymin = vbbox->_shape ._rect .yMin () + y;
321- int xmax = vbbox->_shape ._rect .xMax () + x;
322- int ymax = vbbox->_shape ._rect .yMax () + y;
308+ const int xmin = vbbox->_shape ._rect .xMin () + x;
309+ const int ymin = vbbox->_shape ._rect .yMin () + y;
310+ const int xmax = vbbox->_shape ._rect .xMax () + x;
311+ const int ymax = vbbox->_shape ._rect .yMax () + y;
323312 _dbSBox* box = block->_sbox_tbl ->create ();
324313 box->_flags ._owner_type = dbBoxOwner::SWIRE;
325314 box->_shape ._rect .init (xmin, ymin, xmax, ymax);
@@ -417,4 +406,35 @@ std::vector<dbSBox*> dbSBox::smashVia()
417406 return new_boxes;
418407}
419408
409+ _dbSBox::_dbSBox (_dbDatabase* db, const _dbSBox& b)
410+ : _dbBox(db, b), _sflags(b._sflags)
411+ {
412+ }
413+
414+ _dbSBox::_dbSBox (_dbDatabase* db) : _dbBox(db)
415+ {
416+ _sflags._wire_type = dbWireShapeType::COREWIRE;
417+ _sflags._direction = 0 ;
418+ _sflags._via_bottom_mask = 0 ;
419+ _sflags._via_cut_mask = 0 ;
420+ _sflags._via_top_mask = 0 ;
421+ _sflags._spare_bits = 0 ;
422+ }
423+
424+ dbOStream& operator <<(dbOStream& stream, const _dbSBox& box)
425+ {
426+ stream << (_dbBox&) box;
427+ uint* bit_field = (uint*) &box._sflags ;
428+ stream << *bit_field;
429+ return stream;
430+ }
431+
432+ dbIStream& operator >>(dbIStream& stream, _dbSBox& box)
433+ {
434+ stream >> (_dbBox&) box;
435+ uint* bit_field = (uint*) &box._sflags ;
436+ stream >> *bit_field;
437+ return stream;
438+ }
439+
420440} // namespace odb
0 commit comments