diff --git a/src/db/db/dbAsIfFlatEdgePairs.cc b/src/db/db/dbAsIfFlatEdgePairs.cc index 70c853734..a698bc91f 100644 --- a/src/db/db/dbAsIfFlatEdgePairs.cc +++ b/src/db/db/dbAsIfFlatEdgePairs.cc @@ -174,7 +174,6 @@ RegionDelegate * AsIfFlatEdgePairs::processed_to_polygons (const EdgePairToPolygonProcessorBase &filter) const { std::unique_ptr region (new FlatRegion ()); - db::PropertyMapper pm (region->properties_repository (), properties_repository ()); if (filter.result_must_not_be_merged ()) { region->set_merged_semantics (false); @@ -186,7 +185,7 @@ AsIfFlatEdgePairs::processed_to_polygons (const EdgePairToPolygonProcessorBase & res_polygons.clear (); filter.process (*e, res_polygons); for (std::vector::const_iterator pr = res_polygons.begin (); pr != res_polygons.end (); ++pr) { - db::properties_id_type prop_id = pm (e.prop_id ()); + db::properties_id_type prop_id = e.prop_id (); if (prop_id != 0) { region->insert (db::PolygonWithProperties (*pr, prop_id)); } else { @@ -202,7 +201,6 @@ EdgesDelegate * AsIfFlatEdgePairs::processed_to_edges (const EdgePairToEdgeProcessorBase &filter) const { std::unique_ptr edges (new FlatEdges ()); - db::PropertyMapper pm (edges->properties_repository (), properties_repository ()); if (filter.result_must_not_be_merged ()) { edges->set_merged_semantics (false); @@ -214,7 +212,7 @@ AsIfFlatEdgePairs::processed_to_edges (const EdgePairToEdgeProcessorBase &filter res_edges.clear (); filter.process (*e, res_edges); for (std::vector::const_iterator pr = res_edges.begin (); pr != res_edges.end (); ++pr) { - db::properties_id_type prop_id = pm (e.prop_id ()); + db::properties_id_type prop_id = e.prop_id (); if (prop_id != 0) { edges->insert (db::EdgeWithProperties (*pr, prop_id)); } else { @@ -230,11 +228,10 @@ EdgePairsDelegate * AsIfFlatEdgePairs::filtered (const EdgePairFilterBase &filter) const { std::unique_ptr new_edge_pairs (new FlatEdgePairs ()); - db::PropertyMapper pm (new_edge_pairs->properties_repository (), properties_repository ()); for (EdgePairsIterator p (begin ()); ! p.at_end (); ++p) { if (filter.selected (*p)) { - db::properties_id_type prop_id = pm (p.prop_id ()); + db::properties_id_type prop_id = p.prop_id (); if (prop_id != 0) { new_edge_pairs->insert (db::EdgePairWithProperties (*p, prop_id)); } else { @@ -552,12 +549,11 @@ RegionDelegate * AsIfFlatEdgePairs::polygons (db::Coord e) const { std::unique_ptr output (new FlatRegion ()); - db::PropertyMapper pm (output->properties_repository (), properties_repository ()); for (EdgePairsIterator ep (begin ()); ! ep.at_end (); ++ep) { db::Polygon poly = ep->normalized ().to_polygon (e); if (poly.vertices () >= 3) { - db::properties_id_type prop_id = pm (ep.prop_id ()); + db::properties_id_type prop_id = ep.prop_id (); if (prop_id != 0) { output->insert (db::PolygonWithProperties (poly, prop_id)); } else { @@ -573,10 +569,9 @@ EdgesDelegate * AsIfFlatEdgePairs::edges () const { std::unique_ptr output (new FlatEdges ()); - db::PropertyMapper pm (output->properties_repository (), properties_repository ()); for (EdgePairsIterator ep (begin ()); ! ep.at_end (); ++ep) { - db::properties_id_type prop_id = pm (ep.prop_id ()); + db::properties_id_type prop_id = ep.prop_id (); if (prop_id != 0) { output->insert (db::EdgeWithProperties (ep->first (), prop_id)); output->insert (db::EdgeWithProperties (ep->second (), prop_id)); @@ -593,10 +588,9 @@ EdgesDelegate * AsIfFlatEdgePairs::first_edges () const { std::unique_ptr output (new FlatEdges ()); - db::PropertyMapper pm (output->properties_repository (), properties_repository ()); for (EdgePairsIterator ep (begin ()); ! ep.at_end (); ++ep) { - db::properties_id_type prop_id = pm (ep.prop_id ()); + db::properties_id_type prop_id = ep.prop_id (); if (prop_id != 0) { output->insert (db::EdgeWithProperties (ep->first (), prop_id)); } else { @@ -611,10 +605,9 @@ EdgesDelegate * AsIfFlatEdgePairs::second_edges () const { std::unique_ptr output (new FlatEdges ()); - db::PropertyMapper pm (output->properties_repository (), properties_repository ()); for (EdgePairsIterator ep (begin ()); ! ep.at_end (); ++ep) { - db::properties_id_type prop_id = pm (ep.prop_id ()); + db::properties_id_type prop_id = ep.prop_id (); if (prop_id != 0) { output->insert (db::EdgeWithProperties (ep->second (), prop_id)); } else { @@ -634,14 +627,12 @@ AsIfFlatEdgePairs::add (const EdgePairs &other) const std::unique_ptr new_edge_pairs (new FlatEdgePairs (*other_flat)); new_edge_pairs->invalidate_cache (); - db::PropertyMapper pm (new_edge_pairs->properties_repository (), properties_repository ()); - size_t n = new_edge_pairs->raw_edge_pairs ().size () + count (); new_edge_pairs->reserve (n); for (EdgePairsIterator p (begin ()); ! p.at_end (); ++p) { - db::properties_id_type prop_id = pm (p.prop_id ()); + db::properties_id_type prop_id = p.prop_id (); if (prop_id) { new_edge_pairs->raw_edge_pairs ().insert (db::EdgePairWithProperties (*p, prop_id)); } else { @@ -655,15 +646,12 @@ AsIfFlatEdgePairs::add (const EdgePairs &other) const std::unique_ptr new_edge_pairs (new FlatEdgePairs ()); - db::PropertyMapper pm (new_edge_pairs->properties_repository (), properties_repository ()); - db::PropertyMapper pm_other (new_edge_pairs->properties_repository (), &other.properties_repository ()); - size_t n = count () + other.count (); new_edge_pairs->reserve (n); for (EdgePairsIterator p (begin ()); ! p.at_end (); ++p) { - db::properties_id_type prop_id = pm (p.prop_id ()); + db::properties_id_type prop_id = p.prop_id (); if (prop_id) { new_edge_pairs->raw_edge_pairs ().insert (db::EdgePairWithProperties (*p, prop_id)); } else { @@ -671,7 +659,7 @@ AsIfFlatEdgePairs::add (const EdgePairs &other) const } } for (EdgePairsIterator p (other.begin ()); ! p.at_end (); ++p) { - db::properties_id_type prop_id = pm_other (p.prop_id ()); + db::properties_id_type prop_id = p.prop_id (); if (prop_id) { new_edge_pairs->raw_edge_pairs ().insert (db::EdgePairWithProperties (*p, prop_id)); } else { @@ -732,11 +720,9 @@ AsIfFlatEdgePairs::insert_into (Layout *layout, db::cell_index_type into_cell, u // improves performance when inserting an original layout into the same layout db::LayoutLocker locker (layout); - db::PropertyMapper pm (&layout->properties_repository (), properties_repository ()); - db::Shapes &shapes = layout->cell (into_cell).shapes (into_layer); for (EdgePairsIterator e (begin ()); ! e.at_end (); ++e) { - db::properties_id_type prop_id = pm (e.prop_id ()); + db::properties_id_type prop_id = e.prop_id (); if (prop_id) { shapes.insert (db::EdgePairWithProperties (*e, prop_id)); } else { @@ -751,11 +737,9 @@ AsIfFlatEdgePairs::insert_into_as_polygons (Layout *layout, db::cell_index_type // improves performance when inserting an original layout into the same layout db::LayoutLocker locker (layout); - db::PropertyMapper pm (&layout->properties_repository (), properties_repository ()); - db::Shapes &shapes = layout->cell (into_cell).shapes (into_layer); for (EdgePairsIterator e (begin ()); ! e.at_end (); ++e) { - db::properties_id_type prop_id = pm (e.prop_id ()); + db::properties_id_type prop_id = e.prop_id (); if (prop_id) { shapes.insert (db::SimplePolygonWithProperties (e->normalized ().to_simple_polygon (enl), prop_id)); } else { diff --git a/src/db/db/dbAsIfFlatEdges.cc b/src/db/db/dbAsIfFlatEdges.cc index b428919c6..7d86ebf32 100644 --- a/src/db/db/dbAsIfFlatEdges.cc +++ b/src/db/db/dbAsIfFlatEdges.cc @@ -487,10 +487,9 @@ AsIfFlatEdges::extended (coord_type ext_b, coord_type ext_e, coord_type ext_o, c } else { std::unique_ptr output (new FlatRegion ()); - db::PropertyMapper pm (output->properties_repository (), properties_repository ()); for (EdgesIterator e (begin_merged ()); ! e.at_end (); ++e) { - db::properties_id_type prop_id = pm (e.prop_id ()); + db::properties_id_type prop_id = e.prop_id (); if (prop_id != 0) { output->insert (db::PolygonWithProperties (extended_edge (*e, ext_b, ext_e, ext_o, ext_i), prop_id)); } else { @@ -1087,12 +1086,11 @@ AsIfFlatEdges::insert_into (Layout *layout, db::cell_index_type into_cell, unsig { // improves performance when inserting an original layout into the same layout db::LayoutLocker locker (layout); - db::PropertyMapper pm (&layout->properties_repository (), properties_repository ()); db::Shapes &shapes = layout->cell (into_cell).shapes (into_layer); for (EdgesIterator e (begin ()); ! e.at_end (); ++e) { if (e.prop_id () != 0) { - shapes.insert (db::EdgeWithProperties (*e, pm (e.prop_id ()))); + shapes.insert (db::EdgeWithProperties (*e, e.prop_id ())); } else { shapes.insert (*e); } diff --git a/src/db/db/dbAsIfFlatRegion.cc b/src/db/db/dbAsIfFlatRegion.cc index a62894e47..db124b66c 100644 --- a/src/db/db/dbAsIfFlatRegion.cc +++ b/src/db/db/dbAsIfFlatRegion.cc @@ -76,13 +76,12 @@ private: } static -RegionDelegate *region_from_box (const db::Box &b, const db::PropertiesRepository *pr, db::properties_id_type prop_id) +RegionDelegate *region_from_box (const db::Box &b, db::properties_id_type prop_id) { if (! b.empty () && b.width () > 0 && b.height () > 0) { FlatRegion *new_region = new FlatRegion (); if (prop_id != 0) { - db::PropertyMapper pm (const_cast (new_region->properties_repository ()), pr); - new_region->insert (db::BoxWithProperties (b, pm (prop_id))); + new_region->insert (db::BoxWithProperties (b, prop_id)); } else { new_region->insert (b); } @@ -146,7 +145,6 @@ EdgesDelegate * AsIfFlatRegion::edges (const EdgeFilterBase *filter, const PolygonToEdgeProcessorBase *proc) const { std::unique_ptr result (new FlatEdges ()); - db::PropertyMapper pm (result->properties_repository (), properties_repository ()); size_t n = 0; for (RegionIterator p (begin_merged ()); ! p.at_end (); ++p) { @@ -168,7 +166,7 @@ AsIfFlatRegion::edges (const EdgeFilterBase *filter, const PolygonToEdgeProcesso for (auto e = heap.begin (); e != heap.end (); ++e) { if (! filter || filter->selected (*e)) { if (prop_id != 0) { - result->insert (db::EdgeWithProperties (*e, pm (prop_id))); + result->insert (db::EdgeWithProperties (*e, prop_id)); } else { result->insert (*e); } @@ -180,7 +178,7 @@ AsIfFlatRegion::edges (const EdgeFilterBase *filter, const PolygonToEdgeProcesso for (db::Polygon::polygon_edge_iterator e = p->begin_edge (); ! e.at_end (); ++e) { if (! filter || filter->selected (*e)) { if (prop_id != 0) { - result->insert (db::EdgeWithProperties (*e, pm (prop_id))); + result->insert (db::EdgeWithProperties (*e, prop_id)); } else { result->insert (*e); } @@ -308,10 +306,8 @@ void AsIfFlatRegion::invalidate_bbox () m_bbox_valid = false; } -void AsIfFlatRegion::merge_polygons_to (db::Shapes &output, bool min_coherence, unsigned int min_wc, db::PropertiesRepository *target_rp) const +void AsIfFlatRegion::merge_polygons_to (db::Shapes &output, bool min_coherence, unsigned int min_wc) const { - db::PropertyMapper pm (target_rp, properties_repository ()); - db::EdgeProcessor ep (report_progress (), progress_desc ()); ep.set_base_verbosity (base_verbosity ()); @@ -364,7 +360,7 @@ void AsIfFlatRegion::merge_polygons_to (db::Shapes &output, bool min_coherence, // and run the merge step db::MergeOp op (min_wc); - db::ShapeGenerator pc (result, false /*don't clear*/, pm (p->first)); + db::ShapeGenerator pc (result, false /*don't clear*/, p->first); db::PolygonGenerator pg (pc, false /*don't resolve holes*/, min_coherence); ep.process (pg, op); @@ -392,7 +388,7 @@ void AsIfFlatRegion::merge_polygons_to (db::Shapes &output, bool min_coherence, // and run the merge step db::MergeOp op (min_wc); - db::ShapeGenerator pc (output, false /*don't clear*/, pm (prop_id)); + db::ShapeGenerator pc (output, false /*don't clear*/, prop_id); db::PolygonGenerator pg (pc, false /*don't resolve holes*/, min_coherence); ep.process (pg, op); @@ -1022,7 +1018,7 @@ void region_cop_impl (AsIfFlatRegion *region, db::Shapes *output_to, db::Compoun template static -void region_cop_with_properties_impl (AsIfFlatRegion *region, db::Shapes *output_to, db::PropertiesRepository *target_pr, db::CompoundRegionOperationNode &node, db::PropertyConstraint prop_constraint) +void region_cop_with_properties_impl (AsIfFlatRegion *region, db::Shapes *output_to, db::CompoundRegionOperationNode &node, db::PropertyConstraint prop_constraint) { db::local_processor > proc; proc.set_base_verbosity (region->base_verbosity ()); @@ -1031,9 +1027,6 @@ void region_cop_with_properties_impl (AsIfFlatRegion *region, db::Shapes *output db::generic_shape_iterator polygons (db::make_wp_iter (region->begin_merged ())); - std::vector intruder_prs; - const db::PropertiesRepository *subject_pr = region->properties_repository (); - std::vector > others; std::vector foreign; std::vector inputs = node.inputs (); @@ -1041,18 +1034,16 @@ void region_cop_with_properties_impl (AsIfFlatRegion *region, db::Shapes *output if (*i == subject_regionptr () || *i == foreign_regionptr ()) { others.push_back (db::make_wp_iter (region->begin_merged ())); foreign.push_back (*i == foreign_regionptr ()); - intruder_prs.push_back (subject_pr); } else { others.push_back (db::make_wp_iter ((*i)->begin ())); foreign.push_back (false); - intruder_prs.push_back (&(*i)->properties_repository ()); } } std::vector results; results.push_back (output_to); - compound_local_operation_with_properties op (&node, prop_constraint, target_pr, subject_pr, intruder_prs); + compound_local_operation_with_properties op (&node, prop_constraint); proc.run_flat (polygons, others, foreign, &op, results); } @@ -1063,7 +1054,7 @@ AsIfFlatRegion::cop_to_edge_pairs (db::CompoundRegionOperationNode &node, db::Pr if (pc_skip (prop_constraint)) { region_cop_impl (this, &output->raw_edge_pairs (), node); } else { - region_cop_with_properties_impl (this, &output->raw_edge_pairs (), output->properties_repository (), node, prop_constraint); + region_cop_with_properties_impl (this, &output->raw_edge_pairs (), node, prop_constraint); } return output.release (); } @@ -1075,7 +1066,7 @@ AsIfFlatRegion::cop_to_region (db::CompoundRegionOperationNode &node, db::Proper if (pc_skip (prop_constraint)) { region_cop_impl (this, &output->raw_polygons (), node); } else { - region_cop_with_properties_impl (this, &output->raw_polygons (), output->properties_repository (), node, prop_constraint); + region_cop_with_properties_impl (this, &output->raw_polygons (), node, prop_constraint); } return output.release (); } @@ -1087,7 +1078,7 @@ AsIfFlatRegion::cop_to_edges (db::CompoundRegionOperationNode &node, PropertyCon if (pc_skip (prop_constraint)) { region_cop_impl (this, &output->raw_edges (), node); } else { - region_cop_with_properties_impl (this, &output->raw_edges (), output->properties_repository (), node, prop_constraint); + region_cop_with_properties_impl (this, &output->raw_edges (), node, prop_constraint); } return output.release (); } @@ -1210,10 +1201,7 @@ AsIfFlatRegion::run_check (db::edge_relation_type rel, bool different_polygons, } else { - const db::PropertiesRepository *subject_pr = properties_repository (); - const db::PropertiesRepository *intruder_pr = (other == subject_regionptr () || other == foreign_regionptr ()) ? subject_pr : &other->properties_repository (); - - db::check_local_operation_with_properties op (check, different_polygons, primary_is_merged, has_other, other_is_merged, options, output->properties_repository (), subject_pr, intruder_pr); + db::check_local_operation_with_properties op (check, different_polygons, primary_is_merged, has_other, other_is_merged, options); db::local_processor proc; proc.set_base_verbosity (base_verbosity ()); @@ -1236,13 +1224,12 @@ EdgePairsDelegate * AsIfFlatRegion::run_single_polygon_check (db::edge_relation_type rel, db::Coord d, const RegionCheckOptions &options) const { std::unique_ptr result (new FlatEdgePairs ()); - db::PropertyMapper pm (result->properties_repository (), properties_repository ()); EdgeRelationFilter check (rel, d, options); for (RegionIterator p (begin_merged ()); ! p.at_end (); ++p) { - edge2edge_check_negative_or_positive edge_check (check, result->raw_edge_pairs (), options.negative, false /*=same polygons*/, false /*=same layers*/, options.shielded, true /*symmetric edge pairs*/, pc_remove (options.prop_constraint) ? 0 : pm (p.prop_id ())); + edge2edge_check_negative_or_positive edge_check (check, result->raw_edge_pairs (), options.negative, false /*=same polygons*/, false /*=same layers*/, options.shielded, true /*symmetric edge pairs*/, pc_remove (options.prop_constraint) ? 0 : p.prop_id ()); poly2poly_check poly_check (edge_check); do { @@ -1273,7 +1260,7 @@ AsIfFlatRegion::merged (bool min_coherence, unsigned int min_wc) const } else { std::unique_ptr new_region (new FlatRegion (true)); - merge_polygons_to (new_region->raw_polygons (), min_coherence, min_wc, new_region->properties_repository ()); + merge_polygons_to (new_region->raw_polygons (), min_coherence, min_wc); return new_region.release (); @@ -1298,19 +1285,18 @@ AsIfFlatRegion::sized (coord_type dx, coord_type dy, unsigned int mode) const // simplified handling for a box db::Box b = bbox ().enlarged (db::Vector (dx, dy)); - return region_from_box (b, properties_repository (), begin ()->prop_id ()); + return region_from_box (b, begin ()->prop_id ()); } else if (! merged_semantics () || is_merged ()) { // Generic case std::unique_ptr new_region (new FlatRegion ()); - db::PropertyMapper pm (new_region->properties_repository (), properties_repository ()); db::ShapeGenerator pc (new_region->raw_polygons (), false); db::PolygonGenerator pg (pc, false, true); db::SizingPolygonFilter sf (pg, dx, dy, mode); for (RegionIterator p (begin ()); ! p.at_end (); ++p) { - pc.set_prop_id (pm (p.prop_id ())); + pc.set_prop_id (p.prop_id ()); sf.put (*p); } @@ -1354,13 +1340,11 @@ AsIfFlatRegion::sized (coord_type dx, coord_type dy, unsigned int mode) const #else // Generic case - db::PropertyMapper pm (new_region->properties_repository (), properties_repository ()); - db::ShapeGenerator pc (new_region->raw_polygons (), false); db::PolygonGenerator pg (pc, false, true); db::SizingPolygonFilter sf (pg, dx, dy, mode); for (RegionIterator p (begin_merged ()); ! p.at_end (); ++p) { - pc.set_prop_id (pm (p.prop_id ())); + pc.set_prop_id (p.prop_id ()); sf.put (*p); } @@ -1486,7 +1470,7 @@ AsIfFlatRegion::and_with (const Region &other, PropertyConstraint property_const db::properties_id_type prop_id_out = pc_norm (property_constraint, begin ()->prop_id ()); - return region_from_box (b, properties_repository (), prop_id_out); + return region_from_box (b, prop_id_out); } else { return new EmptyRegion (); @@ -1499,9 +1483,8 @@ AsIfFlatRegion::and_with (const Region &other, PropertyConstraint property_const // map AND with box to clip .. db::Box b = bbox (); std::unique_ptr new_region (new FlatRegion (false)); - db::PropertyMapper pm (new_region->properties_repository (), properties_repository ()); - db::properties_id_type prop_id_out = pm (pc_norm (property_constraint, self_prop_id)); + db::properties_id_type prop_id_out = pc_norm (property_constraint, self_prop_id); std::vector clipped; for (RegionIterator p (other.begin ()); ! p.at_end (); ++p) { @@ -1533,7 +1516,6 @@ AsIfFlatRegion::and_with (const Region &other, PropertyConstraint property_const // map AND with box to clip .. db::Box b = other.bbox (); std::unique_ptr new_region (new FlatRegion (false)); - db::PropertyMapper pm (new_region->properties_repository (), properties_repository ()); std::vector clipped; for (RegionIterator p (begin ()); ! p.at_end (); ++p) { @@ -1544,7 +1526,7 @@ AsIfFlatRegion::and_with (const Region &other, PropertyConstraint property_const clipped.clear (); clip_poly (*p, b, clipped); - db::properties_id_type prop_id_out = pm (pc_norm (property_constraint, prop_id)); + db::properties_id_type prop_id_out = pc_norm (property_constraint, prop_id); if (prop_id_out == 0) { new_region->raw_polygons ().insert (clipped.begin (), clipped.end ()); } else { @@ -1637,7 +1619,7 @@ AsIfFlatRegion::and_or_not_with (bool is_and, const Region &other, PropertyConst std::vector results; results.push_back (&output->raw_polygons ()); - db::bool_and_or_not_local_operation_with_properties op (is_and, output->properties_repository (), properties_repository (), &other.properties_repository (), property_constraint); + db::bool_and_or_not_local_operation_with_properties op (is_and, property_constraint); db::local_processor proc; proc.set_base_verbosity (base_verbosity ()); @@ -1725,7 +1707,7 @@ AsIfFlatRegion::andnot_with (const Region &other, PropertyConstraint property_co results.push_back (&output1->raw_polygons ()); results.push_back (&output2->raw_polygons ()); - db::two_bool_and_not_local_operation_with_properties op (output1->properties_repository (), output2->properties_repository (), properties_repository (), &other.properties_repository (), property_constraint); + db::two_bool_and_not_local_operation_with_properties op (property_constraint); db::local_processor proc; proc.set_base_verbosity (base_verbosity ()); @@ -1894,7 +1876,7 @@ AsIfFlatRegion::add (const Region &other) const } static void -deliver_shapes_of_nets_recursive (db::Shapes &out, db::PropertiesRepository *pr, const db::Circuit *circuit, const LayoutToNetlist *l2n, const db::Region *of_layer, NetPropertyMode prop_mode, const tl::Variant &net_prop_name, const db::ICplxTrans &tr, const std::set *net_filter) +deliver_shapes_of_nets_recursive (db::Shapes &out, const db::Circuit *circuit, const LayoutToNetlist *l2n, const db::Region *of_layer, NetPropertyMode prop_mode, const tl::Variant &net_prop_name, const db::ICplxTrans &tr, const std::set *net_filter) { db::CplxTrans dbu_trans (l2n->internal_layout ()->dbu ()); auto dbu_trans_inv = dbu_trans.inverted (); @@ -1902,7 +1884,7 @@ deliver_shapes_of_nets_recursive (db::Shapes &out, db::PropertiesRepository *pr, for (auto n = circuit->begin_nets (); n != circuit->end_nets (); ++n) { if (! net_filter || net_filter->find (n.operator-> ()) != net_filter->end ()) { - db::properties_id_type prop_id = db::NetBuilder::make_netname_propid (*pr, prop_mode, net_prop_name, *n); + db::properties_id_type prop_id = db::NetBuilder::make_netname_propid (prop_mode, net_prop_name, *n); l2n->shapes_of_net (*n, *of_layer, true, out, prop_id, tr); } @@ -1910,7 +1892,7 @@ deliver_shapes_of_nets_recursive (db::Shapes &out, db::PropertiesRepository *pr, for (auto sc = circuit->begin_subcircuits (); sc != circuit->end_subcircuits (); ++sc) { const db::Circuit *circuit_ref = sc->circuit_ref (); db::ICplxTrans tr_ref = tr * (dbu_trans_inv * sc->trans () * dbu_trans); - deliver_shapes_of_nets_recursive (out, pr, circuit_ref, l2n, of_layer, prop_mode, net_prop_name, tr_ref, net_filter); + deliver_shapes_of_nets_recursive (out, circuit_ref, l2n, of_layer, prop_mode, net_prop_name, tr_ref, net_filter); } } @@ -1942,7 +1924,7 @@ AsIfFlatRegion::nets (LayoutToNetlist *l2n, NetPropertyMode prop_mode, const tl: net_filter_set.insert (net_filter->begin (), net_filter->end ()); } - deliver_shapes_of_nets_recursive (result->raw_polygons (), result->properties_repository (), top_circuit, l2n, region_for_layer.get (), prop_mode, net_prop_name, db::ICplxTrans (), net_filter ? &net_filter_set : 0); + deliver_shapes_of_nets_recursive (result->raw_polygons (), top_circuit, l2n, region_for_layer.get (), prop_mode, net_prop_name, db::ICplxTrans (), net_filter ? &net_filter_set : 0); return result.release (); } @@ -1952,13 +1934,12 @@ AsIfFlatRegion::insert_into (Layout *layout, db::cell_index_type into_cell, unsi { // improves performance when inserting an original layout into the same layout db::LayoutLocker locker (layout); - db::PropertyMapper pm (&layout->properties_repository (), properties_repository ()); db::Shapes &shapes = layout->cell (into_cell).shapes (into_layer); for (RegionIterator p (begin ()); ! p.at_end (); ++p) { db::properties_id_type prop_id = p.prop_id (); if (prop_id != 0) { - shapes.insert (db::PolygonWithProperties (*p, pm (prop_id))); + shapes.insert (db::PolygonWithProperties (*p, prop_id)); } else { shapes.insert (*p); } diff --git a/src/db/db/dbAsIfFlatRegion.h b/src/db/db/dbAsIfFlatRegion.h index f06c4c362..da3844a06 100644 --- a/src/db/db/dbAsIfFlatRegion.h +++ b/src/db/db/dbAsIfFlatRegion.h @@ -287,7 +287,7 @@ public: protected: void update_bbox (const db::Box &box); void invalidate_bbox (); - void merge_polygons_to (db::Shapes &output, bool min_coherence, unsigned int min_wc, PropertiesRepository *target_rp = 0) const; + void merge_polygons_to (db::Shapes &output, bool min_coherence, unsigned int min_wc) const; RegionDelegate *and_or_not_with (bool is_and, const Region &other, PropertyConstraint property_constraint) const; virtual EdgePairsDelegate *run_check (db::edge_relation_type rel, bool different_polygons, const Region *other, db::Coord d, const RegionCheckOptions &options) const; diff --git a/src/db/db/dbCell.cc b/src/db/db/dbCell.cc index e5a87ca9a..01993c8dc 100644 --- a/src/db/db/dbCell.cc +++ b/src/db/db/dbCell.cc @@ -801,10 +801,9 @@ Cell::copy_shapes (const db::Cell &source_cell, const db::LayerMapping &layer_ma } if (target_layout != source_layout) { - db::PropertyMapper pm (target_layout, source_layout); db::ICplxTrans trans (source_layout->dbu () / target_layout->dbu ()); for (std::map::const_iterator lm = layer_mapping.begin (); lm != layer_mapping.end (); ++lm) { - shapes (lm->second).insert_transformed (source_cell.shapes (lm->first), trans, pm); + shapes (lm->second).insert_transformed (source_cell.shapes (lm->first), trans); } } else { for (std::map::const_iterator lm = layer_mapping.begin (); lm != layer_mapping.end (); ++lm) { @@ -950,10 +949,9 @@ Cell::move_shapes (db::Cell &source_cell, const db::LayerMapping &layer_mapping) } if (target_layout != source_layout) { - db::PropertyMapper pm (target_layout, source_layout); db::ICplxTrans trans (source_layout->dbu () / target_layout->dbu ()); for (std::map::const_iterator lm = layer_mapping.begin (); lm != layer_mapping.end (); ++lm) { - shapes (lm->second).insert_transformed (source_cell.shapes (lm->first), trans, pm); + shapes (lm->second).insert_transformed (source_cell.shapes (lm->first), trans); source_cell.shapes (lm->first).clear (); } } else { @@ -1023,7 +1021,6 @@ Cell::move_tree (db::Cell &source_cell) throw tl::Exception (tl::to_string (tr ("Source cell does not reside in a layout"))); } - db::PropertyMapper pm (target_layout, source_layout); db::ICplxTrans trans (source_layout->dbu () / target_layout->dbu ()); db::CellMapping cm; @@ -1057,7 +1054,6 @@ Cell::move_tree_shapes (db::Cell &source_cell, const db::CellMapping &cm) throw tl::Exception (tl::to_string (tr ("Source cell does not reside in a layout"))); } - db::PropertyMapper pm (target_layout, source_layout); db::ICplxTrans trans (source_layout->dbu () / target_layout->dbu ()); db::LayerMapping lm; @@ -1084,7 +1080,6 @@ Cell::move_tree_shapes (db::Cell &source_cell, const db::CellMapping &cm, const throw tl::Exception (tl::to_string (tr ("Source cell does not reside in a layout"))); } - db::PropertyMapper pm (target_layout, source_layout); db::ICplxTrans trans (source_layout->dbu () / target_layout->dbu ()); std::vector source_cells; diff --git a/src/db/db/dbCell.h b/src/db/db/dbCell.h index 916650a67..722983c0b 100644 --- a/src/db/db/dbCell.h +++ b/src/db/db/dbCell.h @@ -372,18 +372,17 @@ public: } /** - * @brief Insert an instance given by a instance reference with a different cell index and property ID + * @brief Insert an instance given by a instance reference with a different cell index * * This member may be used to map an instance to another layout object. * * @param ref The instance reference of which to insert a copy * @param im The mapper to new cell index to use (for mapping to a different layout for example) - * @param pm The mapper to new cell property ID use (for mapping to a different layout for example) */ - template - instance_type insert (const instance_type &ref, IndexMap &im, PropIdMap &pm) + template + instance_type insert (const instance_type &ref, IndexMap &im) { - return (m_instances.insert (ref, im, pm)); + return (m_instances.insert (ref, im)); } /** diff --git a/src/db/db/dbCellMapping.cc b/src/db/db/dbCellMapping.cc index a5fd402f6..1950c5ed9 100644 --- a/src/db/db/dbCellMapping.cc +++ b/src/db/db/dbCellMapping.cc @@ -371,8 +371,6 @@ CellMapping::do_create_missing_mapping (db::Layout &layout_a, const db::Layout & if (! new_cells.empty ()) { - db::PropertyMapper pm (&layout_a, &layout_b); - // Note: this avoids frequent cell index table rebuilds if source and target layout are identical layout_a.start_changes (); @@ -394,7 +392,7 @@ CellMapping::do_create_missing_mapping (db::Layout &layout_a, const db::Layout & bci.transform_into (db::ICplxTrans (mag), &layout_a.array_repository ()); if (bi.has_prop_id ()) { - pa.insert (db::CellInstArrayWithProperties (bci, pm (bi.prop_id ()))); + pa.insert (db::CellInstArrayWithProperties (bci, bi.prop_id ())); } else { pa.insert (bci); } diff --git a/src/db/db/dbClipboardData.cc b/src/db/db/dbClipboardData.cc index 9c1b1ffeb..5341440ff 100644 --- a/src/db/db/dbClipboardData.cc +++ b/src/db/db/dbClipboardData.cc @@ -29,7 +29,6 @@ namespace db ClipboardData::ClipboardData () : m_layout (), m_incomplete_cells () { - m_prop_id_map.set_target (&m_layout); m_container_cell_index = m_layout.add_cell (""); } @@ -47,8 +46,7 @@ ClipboardData::add (const db::Layout &layout, unsigned int layer, const db::Shap m_layout.insert_layer (layer, layout.get_properties (layer)); } - m_prop_id_map.set_source (&layout); - m_layout.cell (m_container_cell_index).shapes (layer).insert (shape, m_prop_id_map); + m_layout.cell (m_container_cell_index).shapes (layer).insert (shape); } void @@ -60,8 +58,7 @@ ClipboardData::add (const db::Layout &layout, unsigned int layer, const db::Shap m_layout.insert_layer (layer, layout.get_properties (layer)); } - m_prop_id_map.set_source (&layout); - db::Shape new_shape = m_layout.cell (m_container_cell_index).shapes (layer).insert (shape, m_prop_id_map); + db::Shape new_shape = m_layout.cell (m_container_cell_index).shapes (layer).insert (shape); m_layout.cell (m_container_cell_index).shapes (layer).transform (new_shape, trans); } @@ -80,9 +77,8 @@ ClipboardData::add (const db::Layout &layout, const db::Instance &inst, unsigned } // Insert the instance mapping the cell to the target cell_index and the property ID using the map - m_prop_id_map.set_source (&layout); tl::const_map im (target_cell_index); - m_layout.cell (m_container_cell_index).insert (inst, im, m_prop_id_map); + m_layout.cell (m_container_cell_index).insert (inst, im); } void @@ -102,9 +98,8 @@ ClipboardData::add (const db::Layout &layout, const db::Instance &inst, unsigned } // Insert the instance mapping the cell to the target cell_index and the property ID using the map - m_prop_id_map.set_source (&layout); tl::const_map im (target_cell_index); - db::Instance new_inst = m_layout.cell (m_container_cell_index).insert (inst, im, m_prop_id_map); + db::Instance new_inst = m_layout.cell (m_container_cell_index).insert (inst, im); m_layout.cell (m_container_cell_index).transform (new_inst, trans); } @@ -123,8 +118,6 @@ ClipboardData::add (const db::Layout &layout, const db::Cell &cell, unsigned int m_context_info.erase (target_cell_index); } - m_prop_id_map.set_source (&layout); - // copy the shapes for (unsigned int l = 0; l < layout.layers (); ++l) { @@ -136,7 +129,7 @@ ClipboardData::add (const db::Layout &layout, const db::Cell &cell, unsigned int db::Shapes &shapes = m_layout.cell (target_cell_index).shapes (l); for (db::Shapes::shape_iterator sh = cell.shapes (l).begin (db::Shapes::shape_iterator::All); ! sh.at_end (); ++sh) { - shapes.insert (*sh, m_prop_id_map); + shapes.insert (*sh); } } @@ -164,7 +157,6 @@ ClipboardData::do_insert (db::Layout &layout, const db::ICplxTrans *trans, db::C } std::vector new_layers; - PropertyMapper prop_id_map (&layout, &m_layout); std::map layer_map; for (unsigned int l = 0; l < layout.layers (); ++l) { @@ -258,7 +250,7 @@ ClipboardData::do_insert (db::Layout &layout, const db::ICplxTrans *trans, db::C for (db::Shapes::shape_iterator sh = c->shapes (l).begin (db::Shapes::shape_iterator::All); ! sh.at_end (); ++sh) { - db::Shape new_shape = t.insert (*sh, prop_id_map); + db::Shape new_shape = t.insert (*sh); if (trans) { new_shape = t.transform (new_shape, *trans); } @@ -290,7 +282,7 @@ ClipboardData::do_insert (db::Layout &layout, const db::ICplxTrans *trans, db::C if (callers.find (inst_cell) == callers.end ()) { tl::const_map im (inst_cell); - db::Instance new_inst = t.insert (*inst, im, prop_id_map); + db::Instance new_inst = t.insert (*inst, im); if (trans) { new_inst = t.transform (new_inst, *trans); } diff --git a/src/db/db/dbClipboardData.h b/src/db/db/dbClipboardData.h index 3648f1aa7..f21dfbaa3 100644 --- a/src/db/db/dbClipboardData.h +++ b/src/db/db/dbClipboardData.h @@ -197,8 +197,6 @@ private: std::map m_cell_index_map; db::cell_index_type m_container_cell_index; - PropertyMapper m_prop_id_map; - db::cell_index_type cell_for_cell (const db::Layout &layout, db::cell_index_type cell_index, bool incomplete); std::vector do_insert (db::Layout &into, const db::ICplxTrans *trans, db::Cell *cell, std::vector *new_tops, ClipboardDataInsertReceiver *insert_receiver) const; diff --git a/src/db/db/dbCompoundOperation.h b/src/db/db/dbCompoundOperation.h index cdb125e51..a42ed7e15 100644 --- a/src/db/db/dbCompoundOperation.h +++ b/src/db/db/dbCompoundOperation.h @@ -1794,13 +1794,10 @@ public: * Creates a local operation which utilizes the operation tree. "node" is the root of the operation tree. * Ownership of the node is *not* transferred to the local operation. */ - compound_local_operation_with_properties (CompoundRegionOperationNode *node, db::PropertyConstraint prop_constraint, db::PropertiesRepository *target_pr, const db::PropertiesRepository *subject_pr, const std::vector &intruder_prs) - : mp_node (node), m_prop_constraint (prop_constraint), m_pms (target_pr, subject_pr) + compound_local_operation_with_properties (CompoundRegionOperationNode *node, db::PropertyConstraint prop_constraint) + : mp_node (node), m_prop_constraint (prop_constraint) { - m_pmis.reserve (intruder_prs.size ()); - for (auto i = intruder_prs.begin (); i != intruder_prs.end (); ++i) { - m_pmis.push_back (db::PropertyMapper (target_pr, *i)); - } + // .. nothing yet .. } virtual const TransformationReducer *vars () const @@ -1811,7 +1808,7 @@ public: protected: virtual void do_compute_local (db::Layout *layout, db::Cell *cell, const shape_interactions, db::object_with_properties > &interactions, std::vector > > &results, const db::LocalProcessorBase *proc) const { - auto interactions_by_prop_id = separate_interactions_to_interactions_by_properties (interactions, m_prop_constraint, m_pms, m_pmis); + auto interactions_by_prop_id = separate_interactions_to_interactions_by_properties (interactions, m_prop_constraint); for (auto s2p = interactions_by_prop_id.begin (); s2p != interactions_by_prop_id.end (); ++s2p) { std::vector > results_wo_props; @@ -1839,8 +1836,6 @@ protected: private: tl::weak_ptr mp_node; db::PropertyConstraint m_prop_constraint; - mutable db::PropertyMapper m_pms; - mutable std::vector m_pmis; }; } diff --git a/src/db/db/dbDeepEdgePairs.cc b/src/db/db/dbDeepEdgePairs.cc index bc4be7bb5..115693c47 100644 --- a/src/db/db/dbDeepEdgePairs.cc +++ b/src/db/db/dbDeepEdgePairs.cc @@ -322,16 +322,6 @@ void DeepEdgePairs::apply_property_translator (const db::PropertiesTranslator &p DeepShapeCollectionDelegateBase::apply_property_translator (pt); } -db::PropertiesRepository *DeepEdgePairs::properties_repository () -{ - return &deep_layer ().layout ().properties_repository (); -} - -const db::PropertiesRepository *DeepEdgePairs::properties_repository () const -{ - return &deep_layer ().layout ().properties_repository (); -} - EdgePairsDelegate * DeepEdgePairs::add_in_place (const EdgePairs &other) { diff --git a/src/db/db/dbDeepEdgePairs.h b/src/db/db/dbDeepEdgePairs.h index c9417dfe0..581de9fa4 100644 --- a/src/db/db/dbDeepEdgePairs.h +++ b/src/db/db/dbDeepEdgePairs.h @@ -73,8 +73,6 @@ public: virtual bool has_valid_edge_pairs () const; virtual const db::RecursiveShapeIterator *iter () const; virtual void apply_property_translator (const db::PropertiesTranslator &pt); - virtual db::PropertiesRepository *properties_repository (); - virtual const db::PropertiesRepository *properties_repository () const; virtual EdgePairsDelegate *filter_in_place (const EdgePairFilterBase &filter); virtual EdgePairsDelegate *filtered (const EdgePairFilterBase &) const; diff --git a/src/db/db/dbDeepEdges.cc b/src/db/db/dbDeepEdges.cc index 21591eeda..0eeed2735 100644 --- a/src/db/db/dbDeepEdges.cc +++ b/src/db/db/dbDeepEdges.cc @@ -465,16 +465,6 @@ void DeepEdges::apply_property_translator (const db::PropertiesTranslator &pt) m_merged_edges = db::DeepLayer (); } -db::PropertiesRepository *DeepEdges::properties_repository () -{ - return &deep_layer ().layout ().properties_repository (); -} - -const db::PropertiesRepository *DeepEdges::properties_repository () const -{ - return &deep_layer ().layout ().properties_repository (); -} - bool DeepEdges::equals (const Edges &other) const { const DeepEdges *other_delegate = dynamic_cast (other.delegate ()); diff --git a/src/db/db/dbDeepEdges.h b/src/db/db/dbDeepEdges.h index 91d685695..5d0f09e63 100644 --- a/src/db/db/dbDeepEdges.h +++ b/src/db/db/dbDeepEdges.h @@ -81,8 +81,6 @@ public: virtual const db::RecursiveShapeIterator *iter () const; virtual void apply_property_translator (const db::PropertiesTranslator &pt); - virtual db::PropertiesRepository *properties_repository (); - virtual const db::PropertiesRepository *properties_repository () const; virtual bool equals (const Edges &other) const; virtual bool less (const Edges &other) const; diff --git a/src/db/db/dbDeepRegion.cc b/src/db/db/dbDeepRegion.cc index 5acb010f8..859616fab 100644 --- a/src/db/db/dbDeepRegion.cc +++ b/src/db/db/dbDeepRegion.cc @@ -491,16 +491,6 @@ void DeepRegion::apply_property_translator (const db::PropertiesTranslator &pt) m_merged_polygons = db::DeepLayer (); } -db::PropertiesRepository *DeepRegion::properties_repository () -{ - return &deep_layer ().layout ().properties_repository (); -} - -const db::PropertiesRepository *DeepRegion::properties_repository () const -{ - return &deep_layer ().layout ().properties_repository (); -} - bool DeepRegion::equals (const Region &other) const { @@ -893,7 +883,7 @@ DeepRegion::and_with_impl (const DeepRegion *other, db::PropertyConstraint prope } else { - db::BoolAndOrNotLocalOperationWithProperties op (true, &dl_out.layout ().properties_repository (), &deep_layer ().layout ().properties_repository (), &other->deep_layer ().layout ().properties_repository (), property_constraint); + db::BoolAndOrNotLocalOperationWithProperties op (true, property_constraint); db::local_processor proc (const_cast (&deep_layer ().layout ()), const_cast (&deep_layer ().initial_cell ()), &other->deep_layer ().layout (), &other->deep_layer ().initial_cell (), deep_layer ().breakout_cells (), other->deep_layer ().breakout_cells ()); configure_proc (proc); @@ -996,7 +986,7 @@ DeepRegion::not_with_impl (const DeepRegion *other, db::PropertyConstraint prope } else { - db::BoolAndOrNotLocalOperationWithProperties op (false, &dl_out.layout ().properties_repository (), &deep_layer ().layout ().properties_repository (), &other->deep_layer ().layout ().properties_repository (), property_constraint); + db::BoolAndOrNotLocalOperationWithProperties op (false, property_constraint); db::local_processor proc (const_cast (&deep_layer ().layout ()), const_cast (&deep_layer ().initial_cell ()), &other->deep_layer ().layout (), &other->deep_layer ().initial_cell (), deep_layer ().breakout_cells (), other->deep_layer ().breakout_cells ()); configure_proc (proc); @@ -1038,10 +1028,7 @@ DeepRegion::and_and_not_with (const DeepRegion *other, PropertyConstraint proper } else { - db::PropertiesRepository *pr_out1 = &dl_out1.layout ().properties_repository (); - db::PropertiesRepository *pr_out2 = &dl_out2.layout ().properties_repository (); - const db::PropertiesRepository *pr = &deep_layer ().layout ().properties_repository (); - db::TwoBoolAndNotLocalOperationWithProperties op (pr_out1, pr_out2, pr, pr, property_constraint); + db::TwoBoolAndNotLocalOperationWithProperties op (property_constraint); db::local_processor proc (const_cast (&deep_layer ().layout ()), const_cast (&deep_layer ().initial_cell ()), &other->deep_layer ().layout (), &other->deep_layer ().initial_cell (), deep_layer ().breakout_cells (), other->deep_layer ().breakout_cells ()); configure_proc (proc); @@ -1473,7 +1460,7 @@ DeepRegion::edges (const EdgeFilterBase *filter, const PolygonToEdgeProcessorBas const db::DeepLayer &polygons = deep_layer (); - db::PolygonToEdgeLocalOperation op (res->properties_repository (), &polygons.layout ().properties_repository ()); + db::PolygonToEdgeLocalOperation op; db::local_processor proc (&res->deep_layer ().layout (), &res->deep_layer ().initial_cell (), polygons.breakout_cells ()); @@ -1488,7 +1475,6 @@ DeepRegion::edges (const EdgeFilterBase *filter, const PolygonToEdgeProcessorBas } else { const db::DeepLayer &polygons = merged_deep_layer (); - db::PropertyMapper pm (res->properties_repository (), &polygons.layout ().properties_repository ()); std::unique_ptr vars; db::Layout &layout = const_cast (polygons.layout ()); @@ -1526,7 +1512,7 @@ DeepRegion::edges (const EdgeFilterBase *filter, const PolygonToEdgeProcessorBas for (auto e = heap.begin (); e != heap.end (); ++e) { if (! filter || filter->selected ((*e).transformed (tr))) { - st.insert (db::EdgeWithProperties (*e, pm (si->prop_id ()))); + st.insert (db::EdgeWithProperties (*e, si->prop_id ())); } } @@ -1534,7 +1520,7 @@ DeepRegion::edges (const EdgeFilterBase *filter, const PolygonToEdgeProcessorBas for (db::Polygon::polygon_edge_iterator e = poly.begin_edge (); ! e.at_end (); ++e) { if (! filter || filter->selected ((*e).transformed (tr))) { - st.insert (db::EdgeWithProperties (*e, pm (si->prop_id ()))); + st.insert (db::EdgeWithProperties (*e, si->prop_id ())); } } @@ -2047,8 +2033,6 @@ Output *region_cop_with_properties_impl (DeepRegion *region, db::CompoundRegionO proc.set_threads (region->deep_layer ().store ()->threads ()); std::vector other_layers; - std::vector intruder_prs; - const db::PropertiesRepository *subject_pr = &polygons.layout ().properties_repository (); for (std::vector::const_iterator i = inputs.begin (); i != inputs.end (); ++i) { @@ -2058,7 +2042,6 @@ Output *region_cop_with_properties_impl (DeepRegion *region, db::CompoundRegionO } else { other_layers.push_back (foreign_idlayer ()); } - intruder_prs.push_back (subject_pr); } else { const db::DeepRegion *other_deep = dynamic_cast ((*i)->delegate ()); tl_assert (other_deep != 0); @@ -2066,12 +2049,11 @@ Output *region_cop_with_properties_impl (DeepRegion *region, db::CompoundRegionO throw tl::Exception (tl::to_string (tr ("Complex DeepRegion operations need to use the same layout and top cell for all inputs"))); } other_layers.push_back (other_deep->deep_layer ().layer ()); - intruder_prs.push_back (other_deep->properties_repository ()); } } - compound_local_operation_with_properties op (&node, prop_constraint, res->properties_repository (), subject_pr, intruder_prs); + compound_local_operation_with_properties op (&node, prop_constraint); proc.run (&op, polygons.layer (), other_layers, res->deep_layer ().layer (), true /*make_variants*/); return res.release (); @@ -2199,7 +2181,7 @@ DeepRegion::run_check (db::edge_relation_type rel, bool different_polygons, cons } else { - db::check_local_operation_with_properties op (check, different_polygons, primary_is_merged, other_deep != 0, other_is_merged, options, res->properties_repository (), properties_repository (), other_deep ? other_deep->properties_repository () : &polygons.layout ().properties_repository ()); + db::check_local_operation_with_properties op (check, different_polygons, primary_is_merged, other_deep != 0, other_is_merged, options); db::local_processor proc (subject_layout, subject_top, intruder_layout, intruder_top, diff --git a/src/db/db/dbDeepRegion.h b/src/db/db/dbDeepRegion.h index 80065a931..6cfde0cad 100644 --- a/src/db/db/dbDeepRegion.h +++ b/src/db/db/dbDeepRegion.h @@ -80,8 +80,6 @@ public: virtual const db::RecursiveShapeIterator *iter () const; virtual void apply_property_translator (const db::PropertiesTranslator &pt); - virtual db::PropertiesRepository *properties_repository (); - virtual const db::PropertiesRepository *properties_repository () const; virtual bool equals (const Region &other) const; virtual bool less (const Region &other) const; diff --git a/src/db/db/dbDeepShapeStore.cc b/src/db/db/dbDeepShapeStore.cc index b4be6ee70..4b1fb0146 100644 --- a/src/db/db/dbDeepShapeStore.cc +++ b/src/db/db/dbDeepShapeStore.cc @@ -617,7 +617,7 @@ DeepLayer DeepShapeStore::create_from_flat (const db::Region ®ion, bool for_n db::ICplxTrans ttop = trans * ii.second; // The chain of operators for producing clipped and reduced polygon references - db::PolygonReferenceHierarchyBuilderShapeReceiver refs (&layout (), ii.first.layout (), text_enlargement (), text_property_name ()); + db::PolygonReferenceHierarchyBuilderShapeReceiver refs (&layout (), text_enlargement (), text_property_name ()); db::ReducingHierarchyBuilderShapeReceiver red (&refs, max_area_ratio, max_vertex_count, m_state.reject_odd_polygons ()); while (! ii.first.at_end ()) { @@ -656,7 +656,7 @@ DeepLayer DeepShapeStore::create_from_flat (const db::Edges &edges, const db::IC std::pair ii = edges.begin_iter (); db::ICplxTrans ttop = trans * ii.second; - db::EdgeBuildingHierarchyBuilderShapeReceiver eb (&layout (), ii.first.layout (), false); + db::EdgeBuildingHierarchyBuilderShapeReceiver eb (false); while (! ii.first.at_end ()) { eb.push (*ii.first, ii.first.prop_id (), ttop * ii.first.trans (), world, 0, shapes); ++ii.first; @@ -686,7 +686,7 @@ DeepLayer DeepShapeStore::create_from_flat (const db::Texts &texts, const db::IC std::pair ii = texts.begin_iter (); db::ICplxTrans ttop = trans * ii.second; - db::TextBuildingHierarchyBuilderShapeReceiver tb (&layout (), ii.first.layout ()); + db::TextBuildingHierarchyBuilderShapeReceiver tb (&layout ()); while (! ii.first.at_end ()) { tb.push (*ii.first, ii.first.prop_id (), ttop * ii.first.trans (), world, 0, shapes); @@ -1027,7 +1027,7 @@ DeepLayer DeepShapeStore::create_polygon_layer (const db::RecursiveShapeIterator builder.set_target_layer (layer_index); // The chain of operators for producing clipped and reduced polygon references - db::PolygonReferenceHierarchyBuilderShapeReceiver refs (&layout, si.layout (), text_enlargement (), text_property_name ()); + db::PolygonReferenceHierarchyBuilderShapeReceiver refs (&layout, text_enlargement (), text_property_name ()); db::ReducingHierarchyBuilderShapeReceiver red (&refs, max_area_ratio, max_vertex_count, m_state.reject_odd_polygons ()); db::ClippingHierarchyBuilderShapeReceiver clip (&red); @@ -1105,19 +1105,13 @@ DeepLayer DeepShapeStore::create_copy (const DeepLayer &source, HierarchyBuilder DeepLayer DeepShapeStore::create_edge_layer (const db::RecursiveShapeIterator &si, bool as_edges, const db::ICplxTrans &trans) { - unsigned int layout_index = layout_for_iter (si, trans); - db::Layout &layout = m_layouts[layout_index]->layout; - - db::EdgeBuildingHierarchyBuilderShapeReceiver refs (&layout, si.layout (), as_edges); + db::EdgeBuildingHierarchyBuilderShapeReceiver refs (as_edges); return create_custom_layer (si, &refs, trans); } DeepLayer DeepShapeStore::create_edge_pair_layer (const db::RecursiveShapeIterator &si, const db::ICplxTrans &trans) { - unsigned int layout_index = layout_for_iter (si, trans); - db::Layout &layout = m_layouts[layout_index]->layout; - - db::EdgePairBuildingHierarchyBuilderShapeReceiver refs (&layout, si.layout ()); + db::EdgePairBuildingHierarchyBuilderShapeReceiver refs; return create_custom_layer (si, &refs, trans); } @@ -1126,7 +1120,7 @@ DeepLayer DeepShapeStore::create_text_layer (const db::RecursiveShapeIterator &s unsigned int layout_index = layout_for_iter (si, trans); db::Layout &layout = m_layouts[layout_index]->layout; - db::TextBuildingHierarchyBuilderShapeReceiver refs (&layout, si.layout ()); + db::TextBuildingHierarchyBuilderShapeReceiver refs (&layout); return create_custom_layer (si, &refs, trans); } @@ -1284,16 +1278,16 @@ namespace // this is how the texts are passed for annotating the net names m_text_annot_name_id = std::pair (false, 0); if (! dss.text_property_name ().is_nil ()) { - m_text_annot_name_id = mp_layout->properties_repository ().get_id_of_name (dss.text_property_name ()); + m_text_annot_name_id = db::PropertiesRepository::instance ().get_id_of_name (dss.text_property_name ()); } } - void insert_transformed (Shapes &into, const Shapes &from, const ICplxTrans &trans, PropertyMapper &pm) const + void insert_transformed (Shapes &into, const Shapes &from, const ICplxTrans &trans) const { if (! m_text_annot_name_id.first) { // fast shortcut - into.insert_transformed (from, trans, pm); + into.insert_transformed (from, trans); } else { @@ -1303,12 +1297,12 @@ namespace if (i->prop_id () > 0) { - const db::PropertiesRepository::properties_set &ps = mp_layout->properties_repository ().properties (i->prop_id ()); + const db::PropertiesSet &ps = db::properties (i->prop_id ()); - for (db::PropertiesRepository::properties_set::const_iterator j = ps.begin (); j != ps.end () && ! is_text; ++j) { + for (db::PropertiesSet::iterator j = ps.begin (); j != ps.end () && ! is_text; ++j) { if (j->first == m_text_annot_name_id.second) { - db::Text text (j->second.to_string (), db::Trans (i->bbox ().center () - db::Point ())); + db::Text text (db::property_value (j->second).to_string (), db::Trans (i->bbox ().center () - db::Point ())); text.transform (trans); if (into.layout ()) { into.insert (db::TextRef (text, into.layout ()->shape_repository ())); @@ -1324,13 +1318,12 @@ namespace } if (! is_text) { - into.insert (*i, trans, pm); + into.insert_transformed (*i, trans); } } } - } private: diff --git a/src/db/db/dbDeepTexts.cc b/src/db/db/dbDeepTexts.cc index ebf6daccd..e9225f1ab 100644 --- a/src/db/db/dbDeepTexts.cc +++ b/src/db/db/dbDeepTexts.cc @@ -343,16 +343,6 @@ void DeepTexts::apply_property_translator (const db::PropertiesTranslator &pt) DeepShapeCollectionDelegateBase::apply_property_translator (pt); } -db::PropertiesRepository *DeepTexts::properties_repository () -{ - return &deep_layer ().layout ().properties_repository (); -} - -const db::PropertiesRepository *DeepTexts::properties_repository () const -{ - return &deep_layer ().layout ().properties_repository (); -} - TextsDelegate * DeepTexts::add_in_place (const Texts &other) { diff --git a/src/db/db/dbDeepTexts.h b/src/db/db/dbDeepTexts.h index 44c367e07..e656fd2a1 100644 --- a/src/db/db/dbDeepTexts.h +++ b/src/db/db/dbDeepTexts.h @@ -74,8 +74,6 @@ public: virtual bool has_valid_texts () const; virtual const db::RecursiveShapeIterator *iter () const; virtual void apply_property_translator (const db::PropertiesTranslator &pt); - virtual db::PropertiesRepository *properties_repository (); - virtual const db::PropertiesRepository *properties_repository () const; virtual TextsDelegate *filter_in_place (const TextFilterBase &filter); virtual TextsDelegate *filtered (const TextFilterBase &) const; diff --git a/src/db/db/dbEdgePairs.cc b/src/db/db/dbEdgePairs.cc index 61e6f9bf6..10e127091 100644 --- a/src/db/db/dbEdgePairs.cc +++ b/src/db/db/dbEdgePairs.cc @@ -173,22 +173,6 @@ EdgePairs::iter () const return *(i ? i : &def_iter); } -const db::PropertiesRepository & -EdgePairs::properties_repository () const -{ - static db::PropertiesRepository empty_prop_repo; - const db::PropertiesRepository *r = delegate () ? delegate ()->properties_repository () : 0; - return *(r ? r : &empty_prop_repo); -} - -db::PropertiesRepository & -EdgePairs::properties_repository () -{ - db::PropertiesRepository *r = delegate () ? delegate ()->properties_repository () : 0; - tl_assert (r != 0); - return *r; -} - EdgePairs EdgePairs::processed (const EdgePairProcessorBase &proc) const { return EdgePairs (mp_delegate->processed (proc)); diff --git a/src/db/db/dbEdgePairs.h b/src/db/db/dbEdgePairs.h index cc9ddcd3b..114cb22ac 100644 --- a/src/db/db/dbEdgePairs.h +++ b/src/db/db/dbEdgePairs.h @@ -695,20 +695,6 @@ public: */ const db::RecursiveShapeIterator &iter () const; - /** - * @brief Gets the property repository - * - * Use this object to decode property IDs. - */ - const db::PropertiesRepository &properties_repository () const; - - /** - * @brief Gets the property repository - * - * Use this object to decode and encode property IDs. - */ - db::PropertiesRepository &properties_repository (); - /** * @brief Equality */ diff --git a/src/db/db/dbEdgePairsDelegate.h b/src/db/db/dbEdgePairsDelegate.h index d58ba7661..7e86c5b89 100644 --- a/src/db/db/dbEdgePairsDelegate.h +++ b/src/db/db/dbEdgePairsDelegate.h @@ -237,8 +237,6 @@ public: virtual const db::RecursiveShapeIterator *iter () const = 0; virtual void apply_property_translator (const db::PropertiesTranslator &pt) = 0; - virtual db::PropertiesRepository *properties_repository () = 0; - virtual const db::PropertiesRepository *properties_repository () const = 0; virtual bool equals (const EdgePairs &other) const = 0; virtual bool less (const EdgePairs &other) const = 0; diff --git a/src/db/db/dbEdges.cc b/src/db/db/dbEdges.cc index 5cdefe414..7ae53b009 100644 --- a/src/db/db/dbEdges.cc +++ b/src/db/db/dbEdges.cc @@ -115,22 +115,6 @@ Edges::iter () const return *(i ? i : &def_iter); } -const db::PropertiesRepository & -Edges::properties_repository () const -{ - static db::PropertiesRepository empty_prop_repo; - const db::PropertiesRepository *r = delegate () ? delegate ()->properties_repository () : 0; - return *(r ? r : &empty_prop_repo); -} - -db::PropertiesRepository & -Edges::properties_repository () -{ - db::PropertiesRepository *r = delegate () ? delegate ()->properties_repository () : 0; - tl_assert (r != 0); - return *r; -} - void Edges::set_delegate (EdgesDelegate *delegate, bool keep_attributes) { diff --git a/src/db/db/dbEdgesDelegate.h b/src/db/db/dbEdgesDelegate.h index 5215da02f..553c03597 100644 --- a/src/db/db/dbEdgesDelegate.h +++ b/src/db/db/dbEdgesDelegate.h @@ -284,8 +284,6 @@ public: virtual const db::RecursiveShapeIterator *iter () const = 0; virtual void apply_property_translator (const db::PropertiesTranslator &pt) = 0; - virtual db::PropertiesRepository *properties_repository () = 0; - virtual const db::PropertiesRepository *properties_repository () const = 0; virtual bool equals (const Edges &other) const = 0; virtual bool less (const Edges &other) const = 0; diff --git a/src/db/db/dbEmptyEdgePairs.h b/src/db/db/dbEmptyEdgePairs.h index d74697533..edddff91d 100644 --- a/src/db/db/dbEmptyEdgePairs.h +++ b/src/db/db/dbEmptyEdgePairs.h @@ -92,8 +92,6 @@ public: virtual const db::RecursiveShapeIterator *iter () const { return 0; } virtual void apply_property_translator (const db::PropertiesTranslator &) { } - virtual db::PropertiesRepository *properties_repository () { return 0; } - virtual const db::PropertiesRepository *properties_repository () const { return 0; } virtual bool equals (const EdgePairs &other) const; virtual bool less (const EdgePairs &other) const; diff --git a/src/db/db/dbEmptyEdges.h b/src/db/db/dbEmptyEdges.h index ec265156e..89e1c2190 100644 --- a/src/db/db/dbEmptyEdges.h +++ b/src/db/db/dbEmptyEdges.h @@ -123,8 +123,6 @@ public: virtual const db::RecursiveShapeIterator *iter () const { return 0; } virtual void apply_property_translator (const db::PropertiesTranslator &) { } - virtual db::PropertiesRepository *properties_repository () { return 0; } - virtual const db::PropertiesRepository *properties_repository () const { return 0; } virtual bool equals (const Edges &other) const; virtual bool less (const Edges &other) const; diff --git a/src/db/db/dbEmptyRegion.h b/src/db/db/dbEmptyRegion.h index 4529c159c..345faa5fa 100644 --- a/src/db/db/dbEmptyRegion.h +++ b/src/db/db/dbEmptyRegion.h @@ -144,8 +144,6 @@ public: virtual const db::RecursiveShapeIterator *iter () const { return 0; } virtual void apply_property_translator (const db::PropertiesTranslator &) { } - virtual db::PropertiesRepository *properties_repository () { return 0; } - virtual const db::PropertiesRepository *properties_repository () const { return 0; } virtual bool equals (const Region &other) const; virtual bool less (const Region &other) const; diff --git a/src/db/db/dbEmptyTexts.h b/src/db/db/dbEmptyTexts.h index 9bd206de9..1ad6649a7 100644 --- a/src/db/db/dbEmptyTexts.h +++ b/src/db/db/dbEmptyTexts.h @@ -74,8 +74,6 @@ public: virtual const db::RecursiveShapeIterator *iter () const { return 0; } virtual void apply_property_translator (const db::PropertiesTranslator &) { } - virtual db::PropertiesRepository *properties_repository () { return 0; } - virtual const db::PropertiesRepository *properties_repository () const { return 0; } virtual bool equals (const Texts &other) const; virtual bool less (const Texts &other) const; diff --git a/src/db/db/dbFlatEdgePairs.cc b/src/db/db/dbFlatEdgePairs.cc index e1a961be5..9f49f1ab7 100644 --- a/src/db/db/dbFlatEdgePairs.cc +++ b/src/db/db/dbFlatEdgePairs.cc @@ -32,7 +32,7 @@ namespace db // FlatEdgePairs implementation FlatEdgePairs::FlatEdgePairs () - : MutableEdgePairs (), mp_edge_pairs (new db::Shapes (false)), mp_properties_repository (new db::PropertiesRepository ()) + : MutableEdgePairs (), mp_edge_pairs (new db::Shapes (false)) { // .. nothing yet .. } @@ -43,13 +43,13 @@ FlatEdgePairs::~FlatEdgePairs () } FlatEdgePairs::FlatEdgePairs (const FlatEdgePairs &other) - : MutableEdgePairs (other), mp_edge_pairs (other.mp_edge_pairs), mp_properties_repository (other.mp_properties_repository) + : MutableEdgePairs (other), mp_edge_pairs (other.mp_edge_pairs) { // .. nothing yet .. } FlatEdgePairs::FlatEdgePairs (const db::Shapes &edge_pairs) - : MutableEdgePairs (), mp_edge_pairs (new db::Shapes (edge_pairs)), mp_properties_repository (new db::PropertiesRepository ()) + : MutableEdgePairs (), mp_edge_pairs (new db::Shapes (edge_pairs)) { // .. nothing yet .. } @@ -123,17 +123,15 @@ EdgePairsDelegate *FlatEdgePairs::add (const EdgePairs &other) const std::unique_ptr new_edge_pairs (new FlatEdgePairs (*this)); new_edge_pairs->invalidate_cache (); - db::PropertyMapper pm (new_edge_pairs->properties_repository (), &other.properties_repository ()); - const FlatEdgePairs *other_flat = dynamic_cast (other.delegate ()); if (other_flat) { - new_edge_pairs->raw_edge_pairs ().insert (other_flat->raw_edge_pairs (), pm); + new_edge_pairs->raw_edge_pairs ().insert (other_flat->raw_edge_pairs ()); } else { for (EdgePairsIterator p (other.begin ()); ! p.at_end (); ++p) { - db::properties_id_type prop_id = pm (p.prop_id ()); + db::properties_id_type prop_id = p.prop_id (); if (prop_id != 0) { new_edge_pairs->raw_edge_pairs ().insert (db::EdgePairWithProperties (*p, prop_id)); } else { @@ -152,17 +150,15 @@ EdgePairsDelegate *FlatEdgePairs::add_in_place (const EdgePairs &other) db::Shapes &ep = *mp_edge_pairs; - db::PropertyMapper pm (properties_repository (), &other.properties_repository ()); - const FlatEdgePairs *other_flat = dynamic_cast (other.delegate ()); if (other_flat) { - ep.insert (other_flat->raw_edge_pairs (), pm); + ep.insert (other_flat->raw_edge_pairs ()); } else { for (EdgePairsIterator p (other.begin ()); ! p.at_end (); ++p) { - db::properties_id_type prop_id = pm (p.prop_id ()); + db::properties_id_type prop_id = p.prop_id (); if (prop_id != 0) { ep.insert (db::EdgePairWithProperties (*p, prop_id)); } else { @@ -203,24 +199,13 @@ void FlatEdgePairs::apply_property_translator (const db::PropertiesTranslator &p } } -db::PropertiesRepository *FlatEdgePairs::properties_repository () -{ - return mp_properties_repository.get_non_const (); -} - -const db::PropertiesRepository *FlatEdgePairs::properties_repository () const -{ - return mp_properties_repository.get_const (); -} - void FlatEdgePairs::insert_into_as_polygons (Layout *layout, db::cell_index_type into_cell, unsigned int into_layer, db::Coord enl) const { db::Shapes &out = layout->cell (into_cell).shapes (into_layer); - db::PropertyMapper pm (&layout->properties_repository (), properties_repository ()); for (EdgePairsIterator p (begin ()); ! p.at_end (); ++p) { - db::properties_id_type prop_id = pm (p.prop_id ()); + db::properties_id_type prop_id = p.prop_id (); if (prop_id != 0) { out.insert (db::SimplePolygonWithProperties (p->normalized ().to_simple_polygon (enl), prop_id)); } else { @@ -232,8 +217,7 @@ FlatEdgePairs::insert_into_as_polygons (Layout *layout, db::cell_index_type into void FlatEdgePairs::insert_into (Layout *layout, db::cell_index_type into_cell, unsigned int into_layer) const { - db::PropertyMapper pm (&layout->properties_repository (), properties_repository ()); - layout->cell (into_cell).shapes (into_layer).insert (*mp_edge_pairs, pm); + layout->cell (into_cell).shapes (into_layer).insert (*mp_edge_pairs); } void diff --git a/src/db/db/dbFlatEdgePairs.h b/src/db/db/dbFlatEdgePairs.h index c67e0e30d..399314b6e 100644 --- a/src/db/db/dbFlatEdgePairs.h +++ b/src/db/db/dbFlatEdgePairs.h @@ -79,8 +79,6 @@ public: virtual const db::RecursiveShapeIterator *iter () const; virtual void apply_property_translator (const db::PropertiesTranslator &pt); - virtual db::PropertiesRepository *properties_repository (); - virtual const db::PropertiesRepository *properties_repository () const; virtual void insert_into (Layout *layout, db::cell_index_type into_cell, unsigned int into_layer) const; virtual void insert_into_as_polygons (Layout *layout, db::cell_index_type into_cell, unsigned int into_layer, db::Coord enl) const; @@ -122,7 +120,6 @@ private: FlatEdgePairs &operator= (const FlatEdgePairs &other); mutable tl::copy_on_write_ptr mp_edge_pairs; - mutable tl::copy_on_write_ptr mp_properties_repository; template void transform_generic (const Trans &trans) diff --git a/src/db/db/dbFlatEdges.cc b/src/db/db/dbFlatEdges.cc index 8062902fb..14f055c1e 100644 --- a/src/db/db/dbFlatEdges.cc +++ b/src/db/db/dbFlatEdges.cc @@ -33,7 +33,7 @@ namespace db // FlatEdges implementation FlatEdges::FlatEdges () - : MutableEdges (), mp_edges (new db::Shapes (false)), mp_merged_edges (new db::Shapes (false)), mp_properties_repository (new db::PropertiesRepository ()) + : MutableEdges (), mp_edges (new db::Shapes (false)), mp_merged_edges (new db::Shapes (false)) { init (); } @@ -44,7 +44,7 @@ FlatEdges::~FlatEdges () } FlatEdges::FlatEdges (const FlatEdges &other) - : MutableEdges (other), mp_edges (other.mp_edges), mp_merged_edges (other.mp_merged_edges), mp_properties_repository (other.mp_properties_repository) + : MutableEdges (other), mp_edges (other.mp_edges), mp_merged_edges (other.mp_merged_edges) { init (); @@ -53,7 +53,7 @@ FlatEdges::FlatEdges (const FlatEdges &other) } FlatEdges::FlatEdges (const db::Shapes &edges, bool is_merged) - : MutableEdges (), mp_edges (new db::Shapes (edges)), mp_merged_edges (new db::Shapes (false)), mp_properties_repository (new db::PropertiesRepository ()) + : MutableEdges (), mp_edges (new db::Shapes (edges)), mp_merged_edges (new db::Shapes (false)) { init (); @@ -61,7 +61,7 @@ FlatEdges::FlatEdges (const db::Shapes &edges, bool is_merged) } FlatEdges::FlatEdges (bool is_merged) - : MutableEdges (), mp_edges (new db::Shapes (false)), mp_merged_edges (new db::Shapes (false)), mp_properties_repository (new db::PropertiesRepository ()) + : MutableEdges (), mp_edges (new db::Shapes (false)), mp_merged_edges (new db::Shapes (false)) { init (); @@ -88,8 +88,7 @@ void FlatEdges::init () void FlatEdges::insert_into (Layout *layout, db::cell_index_type into_cell, unsigned int into_layer) const { - db::PropertyMapper pm (&layout->properties_repository (), mp_properties_repository.get_const ()); - layout->cell (into_cell).shapes (into_layer).insert (*mp_edges, pm); + layout->cell (into_cell).shapes (into_layer).insert (*mp_edges); } void FlatEdges::merged_semantics_changed () @@ -397,16 +396,6 @@ void FlatEdges::apply_property_translator (const db::PropertiesTranslator &pt) } } -db::PropertiesRepository *FlatEdges::properties_repository () -{ - return mp_properties_repository.get_non_const (); -} - -const db::PropertiesRepository *FlatEdges::properties_repository () const -{ - return mp_properties_repository.get_const (); -} - void FlatEdges::do_insert (const db::Edge &edge, db::properties_id_type prop_id) { diff --git a/src/db/db/dbFlatEdges.h b/src/db/db/dbFlatEdges.h index 50f2b0a4a..0bf5e19d2 100644 --- a/src/db/db/dbFlatEdges.h +++ b/src/db/db/dbFlatEdges.h @@ -94,8 +94,6 @@ public: virtual const db::RecursiveShapeIterator *iter () const; virtual void apply_property_translator (const db::PropertiesTranslator &pt); - virtual db::PropertiesRepository *properties_repository (); - virtual const db::PropertiesRepository *properties_repository () const; void do_insert (const db::Edge &edge, properties_id_type prop_id); @@ -137,7 +135,6 @@ private: mutable tl::copy_on_write_ptr mp_edges; mutable tl::copy_on_write_ptr mp_merged_edges; mutable bool m_merged_edges_valid; - mutable tl::copy_on_write_ptr mp_properties_repository; void init (); void ensure_merged_edges_valid () const; diff --git a/src/db/db/dbFlatRegion.cc b/src/db/db/dbFlatRegion.cc index 0d79dbe3e..945c08190 100644 --- a/src/db/db/dbFlatRegion.cc +++ b/src/db/db/dbFlatRegion.cc @@ -34,13 +34,13 @@ namespace db // FlatRegion implementation FlatRegion::FlatRegion () - : MutableRegion (), mp_polygons (new db::Shapes (false)), mp_merged_polygons (new db::Shapes (false)), mp_properties_repository (new db::PropertiesRepository ()) + : MutableRegion (), mp_polygons (new db::Shapes (false)), mp_merged_polygons (new db::Shapes (false)) { init (); } FlatRegion::FlatRegion (const FlatRegion &other) - : MutableRegion (other), mp_polygons (other.mp_polygons), mp_merged_polygons (other.mp_merged_polygons), mp_properties_repository (other.mp_properties_repository) + : MutableRegion (other), mp_polygons (other.mp_polygons), mp_merged_polygons (other.mp_merged_polygons) { init (); m_is_merged = other.m_is_merged; @@ -48,14 +48,14 @@ FlatRegion::FlatRegion (const FlatRegion &other) } FlatRegion::FlatRegion (const db::Shapes &polygons, bool is_merged) - : MutableRegion (), mp_polygons (new db::Shapes (polygons)), mp_merged_polygons (new db::Shapes (false)), mp_properties_repository (new db::PropertiesRepository ()) + : MutableRegion (), mp_polygons (new db::Shapes (polygons)), mp_merged_polygons (new db::Shapes (false)) { init (); m_is_merged = is_merged; } FlatRegion::FlatRegion (const db::Shapes &polygons, const db::ICplxTrans &trans, bool merged_semantics, bool is_merged) - : MutableRegion (), mp_polygons (new db::Shapes (polygons)), mp_merged_polygons (new db::Shapes (false)), mp_properties_repository (new db::PropertiesRepository ()) + : MutableRegion (), mp_polygons (new db::Shapes (polygons)), mp_merged_polygons (new db::Shapes (false)) { init (); m_is_merged = is_merged; @@ -64,7 +64,7 @@ FlatRegion::FlatRegion (const db::Shapes &polygons, const db::ICplxTrans &trans, } FlatRegion::FlatRegion (bool is_merged) - : MutableRegion (), mp_polygons (new db::Shapes (false)), mp_merged_polygons (new db::Shapes (false)), mp_properties_repository (new db::PropertiesRepository ()) + : MutableRegion (), mp_polygons (new db::Shapes (false)), mp_merged_polygons (new db::Shapes (false)) { init (); m_is_merged = is_merged; @@ -442,20 +442,9 @@ void FlatRegion::apply_property_translator (const db::PropertiesTranslator &pt) } } -db::PropertiesRepository *FlatRegion::properties_repository () -{ - return mp_properties_repository.get_non_const (); -} - -const db::PropertiesRepository *FlatRegion::properties_repository () const -{ - return mp_properties_repository.get_const (); -} - void FlatRegion::insert_into (Layout *layout, db::cell_index_type into_cell, unsigned int into_layer) const { - db::PropertyMapper pm (&layout->properties_repository (), mp_properties_repository.get_const ()); - layout->cell (into_cell).shapes (into_layer).insert (*mp_polygons, pm); + layout->cell (into_cell).shapes (into_layer).insert (*mp_polygons); } void diff --git a/src/db/db/dbFlatRegion.h b/src/db/db/dbFlatRegion.h index 55805a8a5..0279ae9c6 100644 --- a/src/db/db/dbFlatRegion.h +++ b/src/db/db/dbFlatRegion.h @@ -101,8 +101,6 @@ public: virtual const db::RecursiveShapeIterator *iter () const; virtual void apply_property_translator (const db::PropertiesTranslator &pt); - virtual db::PropertiesRepository *properties_repository (); - virtual const db::PropertiesRepository *properties_repository () const; void do_insert (const db::Polygon &polygon, db::properties_id_type prop_id); @@ -148,7 +146,6 @@ private: mutable tl::copy_on_write_ptr mp_polygons; mutable tl::copy_on_write_ptr mp_merged_polygons; mutable bool m_merged_polygons_valid; - mutable tl::copy_on_write_ptr mp_properties_repository; void init (); void ensure_merged_polygons_valid () const; diff --git a/src/db/db/dbFlatTexts.cc b/src/db/db/dbFlatTexts.cc index 635426b01..8c5a6dc18 100644 --- a/src/db/db/dbFlatTexts.cc +++ b/src/db/db/dbFlatTexts.cc @@ -32,7 +32,7 @@ namespace db // FlatTexts implementation FlatTexts::FlatTexts () - : MutableTexts (), mp_texts (new db::Shapes (false)), mp_properties_repository (new db::PropertiesRepository ()) + : MutableTexts (), mp_texts (new db::Shapes (false)) { // .. nothing yet .. } @@ -43,13 +43,13 @@ FlatTexts::~FlatTexts () } FlatTexts::FlatTexts (const FlatTexts &other) - : MutableTexts (other), mp_texts (other.mp_texts), mp_properties_repository (other.mp_properties_repository) + : MutableTexts (other), mp_texts (other.mp_texts) { // .. nothing yet .. } FlatTexts::FlatTexts (const db::Shapes &texts) - : MutableTexts (), mp_texts (new db::Shapes (texts)), mp_properties_repository (new db::PropertiesRepository ()) + : MutableTexts (), mp_texts (new db::Shapes (texts)) { // .. nothing yet .. } @@ -201,16 +201,6 @@ void FlatTexts::apply_property_translator (const db::PropertiesTranslator &pt) } } -db::PropertiesRepository *FlatTexts::properties_repository () -{ - return mp_properties_repository.get_non_const (); -} - -const db::PropertiesRepository *FlatTexts::properties_repository () const -{ - return mp_properties_repository.get_const (); -} - void FlatTexts::insert_into_as_polygons (Layout *layout, db::cell_index_type into_cell, unsigned int into_layer, db::Coord enl) const { diff --git a/src/db/db/dbFlatTexts.h b/src/db/db/dbFlatTexts.h index 5d8be2265..7078f224f 100644 --- a/src/db/db/dbFlatTexts.h +++ b/src/db/db/dbFlatTexts.h @@ -80,8 +80,6 @@ public: virtual const db::RecursiveShapeIterator *iter () const; virtual void apply_property_translator (const db::PropertiesTranslator &pt); - virtual db::PropertiesRepository *properties_repository (); - virtual const db::PropertiesRepository *properties_repository () const; virtual void insert_into (Layout *layout, db::cell_index_type into_cell, unsigned int into_layer) const; virtual void insert_into_as_polygons (Layout *layout, db::cell_index_type into_cell, unsigned int into_layer, db::Coord enl) const; @@ -123,7 +121,6 @@ private: FlatTexts &operator= (const FlatTexts &other); mutable tl::copy_on_write_ptr mp_texts; - mutable tl::copy_on_write_ptr mp_properties_repository; template void transform_generic (const Trans &trans) diff --git a/src/db/db/dbHierarchyBuilder.cc b/src/db/db/dbHierarchyBuilder.cc index cfb495af6..397564287 100644 --- a/src/db/db/dbHierarchyBuilder.cc +++ b/src/db/db/dbHierarchyBuilder.cc @@ -670,23 +670,17 @@ ReducingHierarchyBuilderShapeReceiver::reduce (const db::Polygon &poly, db::prop // --------------------------------------------------------------------------------------------- -PolygonReferenceHierarchyBuilderShapeReceiver::PolygonReferenceHierarchyBuilderShapeReceiver (db::Layout *layout, const db::Layout *source_layout, int text_enlargement, const tl::Variant &text_prop_name) +PolygonReferenceHierarchyBuilderShapeReceiver::PolygonReferenceHierarchyBuilderShapeReceiver (db::Layout *layout, int text_enlargement, const tl::Variant &text_prop_name) : mp_layout (layout), m_text_enlargement (text_enlargement), m_make_text_prop (false), m_text_prop_id (0) { if (! text_prop_name.is_nil ()) { - m_text_prop_id = layout->properties_repository ().prop_name_id (text_prop_name); + m_text_prop_id = db::property_names_id (text_prop_name); m_make_text_prop = true; } - - if (source_layout && source_layout != layout) { - m_pm.set_source (source_layout); - m_pm.set_target (layout); - } } void PolygonReferenceHierarchyBuilderShapeReceiver::make_pref (db::Shapes *target, const db::Polygon &poly, db::properties_id_type prop_id) { - prop_id = m_pm (prop_id); if (prop_id != 0) { target->insert (db::PolygonRefWithProperties (db::PolygonRef (poly, mp_layout->shape_repository ()), prop_id)); } else { @@ -726,12 +720,12 @@ void PolygonReferenceHierarchyBuilderShapeReceiver::push (const db::Shape &shape // NOTE: text properties override the prop_id passed down from the hierarchy builder when generating the // text marker shape - db::PropertiesRepository::properties_set ps; - ps.insert (std::make_pair (m_text_prop_id, tl::Variant (shape.text_string ()))); - pid = mp_layout->properties_repository ().properties_id (ps); + db::PropertiesSet ps; + ps.insert (m_text_prop_id, tl::Variant (shape.text_string ())); + pid = db::properties_id (ps); } else { - pid = m_pm (prop_id); + pid = prop_id; } if (pid != 0) { @@ -759,13 +753,10 @@ void PolygonReferenceHierarchyBuilderShapeReceiver::push (const db::Polygon &sha // --------------------------------------------------------------------------------------------- -EdgeBuildingHierarchyBuilderShapeReceiver::EdgeBuildingHierarchyBuilderShapeReceiver (db::Layout *layout, const db::Layout *source_layout, bool as_edges) +EdgeBuildingHierarchyBuilderShapeReceiver::EdgeBuildingHierarchyBuilderShapeReceiver (bool as_edges) : m_as_edges (as_edges) { - if (source_layout && source_layout != layout) { - m_pm.set_source (source_layout); - m_pm.set_target (layout); - } + // .. nothing yet .. } void EdgeBuildingHierarchyBuilderShapeReceiver::push (const db::Shape &shape, db::properties_id_type prop_id, const db::ICplxTrans &trans, const db::Box ®ion, const db::RecursiveShapeReceiver::box_tree_type *complex_region, db::Shapes *target) @@ -777,7 +768,6 @@ void EdgeBuildingHierarchyBuilderShapeReceiver::push (const db::Shape &shape, db } else if (m_as_edges && shape.is_box ()) { push (shape.box (), prop_id, trans, region, complex_region, target); } else if (shape.is_edge ()) { - prop_id = m_pm (prop_id); if (prop_id != 0) { target->insert (db::EdgeWithProperties (shape.edge (), shape.prop_id ())); } else { @@ -789,7 +779,6 @@ void EdgeBuildingHierarchyBuilderShapeReceiver::push (const db::Shape &shape, db void EdgeBuildingHierarchyBuilderShapeReceiver::push (const db::Box &box, db::properties_id_type prop_id, const db::ICplxTrans &trans, const db::Box &, const db::RecursiveShapeReceiver::box_tree_type *, db::Shapes *target) { if (m_as_edges && ! box.empty ()) { - prop_id = m_pm (prop_id); if (prop_id != 0) { target->insert (db::EdgeWithProperties (db::Edge (box.p1 (), box.upper_left ()).transformed (trans), prop_id)); target->insert (db::EdgeWithProperties (db::Edge (box.upper_left (), box.p2 ()).transformed (trans), prop_id)); @@ -807,7 +796,6 @@ void EdgeBuildingHierarchyBuilderShapeReceiver::push (const db::Box &box, db::pr void EdgeBuildingHierarchyBuilderShapeReceiver::push (const db::Polygon &poly, db::properties_id_type prop_id, const db::ICplxTrans &trans, const db::Box &, const db::RecursiveShapeReceiver::box_tree_type *, db::Shapes *target) { if (m_as_edges) { - prop_id = m_pm (prop_id); for (db::Polygon::polygon_edge_iterator e = poly.begin_edge (); ! e.at_end (); ++e) { if (prop_id != 0) { target->insert (db::EdgeWithProperties ((*e).transformed (trans), prop_id)); @@ -820,18 +808,14 @@ void EdgeBuildingHierarchyBuilderShapeReceiver::push (const db::Polygon &poly, d // --------------------------------------------------------------------------------------------- -EdgePairBuildingHierarchyBuilderShapeReceiver::EdgePairBuildingHierarchyBuilderShapeReceiver (db::Layout *layout, const db::Layout *source_layout) +EdgePairBuildingHierarchyBuilderShapeReceiver::EdgePairBuildingHierarchyBuilderShapeReceiver () { - if (source_layout && source_layout != layout) { - m_pm.set_source (source_layout); - m_pm.set_target (layout); - } + // .. nothing yet .. } void EdgePairBuildingHierarchyBuilderShapeReceiver::push (const db::Shape &shape, db::properties_id_type prop_id, const db::ICplxTrans &trans, const db::Box & /*region*/, const db::RecursiveShapeReceiver::box_tree_type * /*complex_region*/, db::Shapes *target) { if (shape.is_edge_pair ()) { - prop_id = m_pm (prop_id); if (prop_id != 0) { target->insert (db::EdgePairWithProperties (shape.edge_pair ().transformed (trans), prop_id)); } else { @@ -842,13 +826,10 @@ void EdgePairBuildingHierarchyBuilderShapeReceiver::push (const db::Shape &shape // --------------------------------------------------------------------------------------------- -TextBuildingHierarchyBuilderShapeReceiver::TextBuildingHierarchyBuilderShapeReceiver (db::Layout *layout, const db::Layout *source_layout) +TextBuildingHierarchyBuilderShapeReceiver::TextBuildingHierarchyBuilderShapeReceiver (db::Layout *layout) : mp_layout (layout) { - if (source_layout && source_layout != layout) { - m_pm.set_source (source_layout); - m_pm.set_target (layout); - } + // .. nothing yet .. } void TextBuildingHierarchyBuilderShapeReceiver::push (const db::Shape &shape, db::properties_id_type prop_id, const db::ICplxTrans &trans, const db::Box & /*region*/, const db::RecursiveShapeReceiver::box_tree_type * /*complex_region*/, db::Shapes *target) @@ -857,7 +838,6 @@ void TextBuildingHierarchyBuilderShapeReceiver::push (const db::Shape &shape, db // NOTE: we intentionally skip all the text attributes (font etc.) here because in the context // of a text collections we're only interested in the locations. db::Text t (shape.text_string (), shape.text_trans ()); - prop_id = m_pm (prop_id); if (prop_id != 0) { target->insert (db::TextRefWithProperties (db::TextRef (t.transformed (trans), mp_layout->shape_repository ()), prop_id)); } else { diff --git a/src/db/db/dbHierarchyBuilder.h b/src/db/db/dbHierarchyBuilder.h index 4cd0caf65..84303a03f 100644 --- a/src/db/db/dbHierarchyBuilder.h +++ b/src/db/db/dbHierarchyBuilder.h @@ -164,7 +164,7 @@ class DB_PUBLIC PolygonReferenceHierarchyBuilderShapeReceiver : public HierarchyBuilderShapeReceiver { public: - PolygonReferenceHierarchyBuilderShapeReceiver (db::Layout *layout, const Layout *source_layout, int text_enlargement = -1, const tl::Variant &text_prop_name = tl::Variant ()); + PolygonReferenceHierarchyBuilderShapeReceiver (db::Layout *layout, int text_enlargement = -1, const tl::Variant &text_prop_name = tl::Variant ()); virtual void push (const db::Shape &shape, db::properties_id_type prop_id, const db::ICplxTrans &trans, const db::Box &, const db::RecursiveShapeReceiver::box_tree_type *, db::Shapes *target); virtual void push (const db::Box &shape, db::properties_id_type prop_id, const db::ICplxTrans &trans, const db::Box &, const db::RecursiveShapeReceiver::box_tree_type *, db::Shapes *target); @@ -177,7 +177,6 @@ private: int m_text_enlargement; bool m_make_text_prop; db::property_names_id_type m_text_prop_id; - db::PropertyMapper m_pm; }; /** @@ -187,7 +186,7 @@ class DB_PUBLIC EdgeBuildingHierarchyBuilderShapeReceiver : public HierarchyBuilderShapeReceiver { public: - EdgeBuildingHierarchyBuilderShapeReceiver (db::Layout *layout, const Layout *source_layout, bool as_edges); + EdgeBuildingHierarchyBuilderShapeReceiver (bool as_edges); virtual void push (const db::Shape &shape, properties_id_type prop_id, const db::ICplxTrans &trans, const db::Box &, const db::RecursiveShapeReceiver::box_tree_type *, db::Shapes *target); virtual void push (const db::Box &shape, db::properties_id_type prop_id, const db::ICplxTrans &trans, const db::Box &, const db::RecursiveShapeReceiver::box_tree_type *, db::Shapes *target); @@ -195,7 +194,6 @@ public: private: bool m_as_edges; - db::PropertyMapper m_pm; }; /** @@ -205,14 +203,11 @@ class DB_PUBLIC EdgePairBuildingHierarchyBuilderShapeReceiver : public HierarchyBuilderShapeReceiver { public: - EdgePairBuildingHierarchyBuilderShapeReceiver (db::Layout *layout, const Layout *source_layout); + EdgePairBuildingHierarchyBuilderShapeReceiver (); virtual void push (const db::Shape &shape, properties_id_type prop_id, const db::ICplxTrans &trans, const db::Box &, const db::RecursiveShapeReceiver::box_tree_type *, db::Shapes *target); virtual void push (const db::Box &, db::properties_id_type, const db::ICplxTrans &, const db::Box &, const db::RecursiveShapeReceiver::box_tree_type *, db::Shapes *) { } virtual void push (const db::Polygon &, db::properties_id_type, const db::ICplxTrans &, const db::Box &, const db::RecursiveShapeReceiver::box_tree_type *, db::Shapes *) { } - -private: - db::PropertyMapper m_pm; }; /** @@ -222,7 +217,7 @@ class DB_PUBLIC TextBuildingHierarchyBuilderShapeReceiver : public HierarchyBuilderShapeReceiver { public: - TextBuildingHierarchyBuilderShapeReceiver (db::Layout *layout, const Layout *source_layout); + TextBuildingHierarchyBuilderShapeReceiver (db::Layout *layout); virtual void push (const db::Shape &shape, properties_id_type prop_id, const db::ICplxTrans &trans, const db::Box &, const db::RecursiveShapeReceiver::box_tree_type *, db::Shapes *target); virtual void push (const db::Box &, db::properties_id_type, const db::ICplxTrans &, const db::Box &, const db::RecursiveShapeReceiver::box_tree_type *, db::Shapes *) { } @@ -230,7 +225,6 @@ public: private: db::Layout *mp_layout; - db::PropertyMapper m_pm; }; /** diff --git a/src/db/db/dbInstances.cc b/src/db/db/dbInstances.cc index 12804e249..f5782d646 100644 --- a/src/db/db/dbInstances.cc +++ b/src/db/db/dbInstances.cc @@ -1651,8 +1651,7 @@ Instances::redo (db::Op *op) Instances::instance_type Instances::do_insert (const Instances::instance_type &ref, - tl::func_delegate_base &im, - tl::func_delegate_base &pm) + tl::func_delegate_base &im) { if (ref.instances () == this) { @@ -1667,7 +1666,7 @@ Instances::do_insert (const Instances::instance_type &ref, cell_inst_wp_array_type inst_wp = *ref.basic_ptr (cell_inst_wp_array_type::tag ()); inst_wp.object () = cell_inst_type (im (ref.cell_index ())); - inst_wp.properties_id (pm (ref.prop_id ())); + inst_wp.properties_id (ref.prop_id ()); return insert (inst_wp); @@ -1687,7 +1686,7 @@ Instances::do_insert (const Instances::instance_type &ref, cell_inst_array_type inst (*ref.basic_ptr (cell_inst_wp_array_type::tag ()), layout () ? &layout ()->array_repository () : 0); inst.object () = cell_inst_type (im (ref.cell_index ())); - return insert (cell_inst_wp_array_type (inst, pm (ref.prop_id ()))); + return insert (cell_inst_wp_array_type (inst, ref.prop_id ())); } diff --git a/src/db/db/dbInstances.h b/src/db/db/dbInstances.h index a9f11a17d..6d853f6bc 100644 --- a/src/db/db/dbInstances.h +++ b/src/db/db/dbInstances.h @@ -1465,8 +1465,7 @@ public: instance_type insert (const instance_type &ref) { tl::ident_map im; - tl::ident_map pm; - return insert (ref, im, pm); + return insert (ref, im); } /** @@ -1480,12 +1479,11 @@ public: * @param im The mapper to new cell index to use (for mapping to a different layout for example) * @param pm The mapper to new cell property ID use (for mapping to a different layout for example) */ - template - instance_type insert (const instance_type &ref, IndexMap &im, PropIdMap &pm) + template + instance_type insert (const instance_type &ref, IndexMap &im) { tl::func_delegate im_delegate (im); - tl::func_delegate pm_delegate (pm); - return do_insert (ref, im_delegate, pm_delegate); + return do_insert (ref, im_delegate); } /** @@ -1937,8 +1935,7 @@ private: Instances (const Instances &d); instance_type do_insert (const instance_type &ref, - tl::func_delegate_base &im, - tl::func_delegate_base &pm); + tl::func_delegate_base &im); void do_clear_insts (); diff --git a/src/db/db/dbLayout.cc b/src/db/db/dbLayout.cc index db04a3774..7a2cd8de3 100644 --- a/src/db/db/dbLayout.cc +++ b/src/db/db/dbLayout.cc @@ -445,7 +445,6 @@ Layout::Layout (db::Manager *manager) m_top_cells (0), m_dbu (0.001), m_prop_id (0), - m_properties_repository (), m_do_cleanup (false), m_editable (db::default_editable_mode ()) { @@ -461,7 +460,6 @@ Layout::Layout (bool editable, db::Manager *manager) m_top_cells (0), m_dbu (0.001), m_prop_id (0), - m_properties_repository (), m_do_cleanup (false), m_editable (editable) { @@ -481,7 +479,6 @@ Layout::Layout (const db::Layout &layout) m_top_cells (0), m_dbu (0.001), m_prop_id (0), - m_properties_repository (), m_do_cleanup (false), m_editable (layout.m_editable) { @@ -534,8 +531,6 @@ Layout::clear () m_cell_map.clear (); m_shape_repository = db::GenericRepository (); - db::PropertiesRepository empty_pr; - m_properties_repository = empty_pr; m_array_repository = db::ArrayRepository (); for (std::vector::const_iterator pc = m_pcells.begin (); pc != m_pcells.end (); ++pc) { @@ -583,7 +578,6 @@ Layout::operator= (const Layout &d) m_cell_ptrs [new_cell->cell_index ()] = new_cell; } - m_properties_repository = d.m_properties_repository; // because the cell assign operator does not map property ID's .. m_top_down_list = d.m_top_down_list; m_top_cells = d.m_top_cells; @@ -817,7 +811,6 @@ Layout::mem_stat (MemStatistics *stat, MemStatistics::purpose_t purpose, int cat db::mem_stat (stat, purpose, cat, m_lib_proxy_map, true, (void *) this); db::mem_stat (stat, purpose, cat, m_meta_info, true, (void *) this); db::mem_stat (stat, purpose, cat, m_shape_repository, true, (void *) this); - db::mem_stat (stat, purpose, cat, m_properties_repository, true, (void *) this); db::mem_stat (stat, purpose, cat, m_array_repository, true, (void *) this); for (std::vector::const_iterator i = m_cell_names.begin (); i != m_cell_names.end (); ++i) { diff --git a/src/db/db/dbLayout.h b/src/db/db/dbLayout.h index e7b3d21a3..9e2dad36b 100644 --- a/src/db/db/dbLayout.h +++ b/src/db/db/dbLayout.h @@ -604,22 +604,6 @@ public: return m_shape_repository; } - /** - * @brief Accessor to the properties repository - */ - PropertiesRepository &properties_repository () - { - return m_properties_repository; - } - - /** - * @brief Accessor to the properties repository - */ - const PropertiesRepository &properties_repository () const - { - return m_properties_repository; - } - /** * @brief Gets the lock for the layout object * This is a generic lock that can be used to lock modifications against multiple threads. @@ -2139,7 +2123,6 @@ private: double m_dbu; db::properties_id_type m_prop_id; GenericRepository m_shape_repository; - PropertiesRepository m_properties_repository; ArrayRepository m_array_repository; std::vector m_pcells; pcell_name_map m_pcell_ids; diff --git a/src/db/db/dbLayoutDiff.cc b/src/db/db/dbLayoutDiff.cc index b52e71b02..1c80b6c65 100644 --- a/src/db/db/dbLayoutDiff.cc +++ b/src/db/db/dbLayoutDiff.cc @@ -93,7 +93,7 @@ collect_insts_of_unmapped_cells (const db::Layout & /*l*/, const db::Cell *cell, } static void -rewrite_instances_to (std::vector &insts, unsigned int flags, const std::vector &common_cells, db::PropertyMapper &pn) +rewrite_instances_to (std::vector &insts, unsigned int flags, const std::vector &common_cells) { for (std::vector ::iterator i = insts.begin (); i != insts.end (); ++i) { @@ -101,7 +101,7 @@ rewrite_instances_to (std::vector &insts, unsi db::properties_id_type prop_id = 0; if (! (flags & layout_diff::f_no_properties)) { - prop_id = pn (i->properties_id ()); + prop_id = i->properties_id (); } i->object () = db::CellInst (common_cells [i->object ().cell_index ()]); @@ -111,7 +111,7 @@ rewrite_instances_to (std::vector &insts, unsi } static void -collect_insts (const db::Layout & /*l*/, const db::Cell *cell, unsigned int flags, const std::map &cci, std::vector &insts, PropertyMapper &pn, bool no_duplicates) +collect_insts (const db::Layout & /*l*/, const db::Cell *cell, unsigned int flags, const std::map &cci, std::vector &insts, bool no_duplicates) { insts.clear (); @@ -125,7 +125,7 @@ collect_insts (const db::Layout & /*l*/, const db::Cell *cell, unsigned int flag db::properties_id_type prop_id = 0; if (! (flags & layout_diff::f_no_properties)) { - prop_id = pn (i->prop_id ()); + prop_id = i->prop_id (); } db::Vector a, b; @@ -581,14 +581,14 @@ make_path_compare_func (db::Coord tolerance) } static void -collect_polygons (const db::Layout & /*l*/, const db::Cell *c, unsigned int layer, unsigned int flags, std::vector< std::pair > &shapes, PropertyMapper &pn) +collect_polygons (const db::Layout & /*l*/, const db::Cell *c, unsigned int layer, unsigned int flags, std::vector< std::pair > &shapes) { shapes.clear (); for (db::ShapeIterator s = c->shapes (layer).begin (db::ShapeIterator::Polygons | ((flags & db::layout_diff::f_paths_as_polygons) ? db::ShapeIterator::Paths : 0) | ((flags & db::layout_diff::f_boxes_as_polygons) ? db::ShapeIterator::Boxes : 0)); !s.at_end (); ++s) { db::properties_id_type prop_id = 0; if (! (flags & layout_diff::f_no_properties)) { - prop_id = pn (s->prop_id ()); + prop_id = s->prop_id (); } shapes.push_back (std::make_pair (db::Polygon (), prop_id)); s->polygon (shapes.back ().first); @@ -596,14 +596,14 @@ collect_polygons (const db::Layout & /*l*/, const db::Cell *c, unsigned int laye } static void -collect_edges (const db::Layout & /*l*/, const db::Cell *c, unsigned int layer, unsigned int flags, std::vector< std::pair > &shapes, PropertyMapper &pn) +collect_edges (const db::Layout & /*l*/, const db::Cell *c, unsigned int layer, unsigned int flags, std::vector< std::pair > &shapes) { shapes.clear (); for (db::ShapeIterator s = c->shapes (layer).begin (db::ShapeIterator::Edges); !s.at_end (); ++s) { db::properties_id_type prop_id = 0; if (! (flags & layout_diff::f_no_properties)) { - prop_id = pn (s->prop_id ()); + prop_id = s->prop_id (); } shapes.push_back (std::make_pair (db::Edge (), prop_id)); s->edge (shapes.back ().first); @@ -611,14 +611,14 @@ collect_edges (const db::Layout & /*l*/, const db::Cell *c, unsigned int layer, } static void -collect_edge_pairs (const db::Layout & /*l*/, const db::Cell *c, unsigned int layer, unsigned int flags, std::vector< std::pair > &shapes, PropertyMapper &pn) +collect_edge_pairs (const db::Layout & /*l*/, const db::Cell *c, unsigned int layer, unsigned int flags, std::vector< std::pair > &shapes) { shapes.clear (); for (db::ShapeIterator s = c->shapes (layer).begin (db::ShapeIterator::EdgePairs); !s.at_end (); ++s) { db::properties_id_type prop_id = 0; if (! (flags & layout_diff::f_no_properties)) { - prop_id = pn (s->prop_id ()); + prop_id = s->prop_id (); } shapes.push_back (std::make_pair (db::EdgePair (), prop_id)); s->edge_pair (shapes.back ().first); @@ -626,14 +626,14 @@ collect_edge_pairs (const db::Layout & /*l*/, const db::Cell *c, unsigned int la } static void -collect_boxes (const db::Layout &, const db::Cell *c, unsigned int layer, unsigned int flags, std::vector< std::pair > &shapes, PropertyMapper &pn) +collect_boxes (const db::Layout &, const db::Cell *c, unsigned int layer, unsigned int flags, std::vector< std::pair > &shapes) { shapes.clear (); for (db::ShapeIterator s = c->shapes (layer).begin (db::ShapeIterator::Boxes); !s.at_end (); ++s) { db::properties_id_type prop_id = 0; if (! (flags & layout_diff::f_no_properties)) { - prop_id = pn (s->prop_id ()); + prop_id = s->prop_id (); } shapes.push_back (std::make_pair (db::Box (), prop_id)); s->box (shapes.back ().first); @@ -641,7 +641,7 @@ collect_boxes (const db::Layout &, const db::Cell *c, unsigned int layer, unsign } static void -collect_texts (const db::Layout &, const db::Cell *c, unsigned int layer, unsigned int flags, std::vector< std::pair > &shapes, PropertyMapper &pn) +collect_texts (const db::Layout &, const db::Cell *c, unsigned int layer, unsigned int flags, std::vector< std::pair > &shapes) { shapes.clear (); @@ -649,7 +649,7 @@ collect_texts (const db::Layout &, const db::Cell *c, unsigned int layer, unsign db::properties_id_type prop_id = 0; if (! (flags & layout_diff::f_no_properties)) { - prop_id = pn (s->prop_id ()); + prop_id = s->prop_id (); } shapes.push_back (std::make_pair (db::Text (), prop_id)); s->text (shapes.back ().first); @@ -675,14 +675,14 @@ collect_texts (const db::Layout &, const db::Cell *c, unsigned int layer, unsign } static void -collect_paths (const db::Layout &, const db::Cell *c, unsigned int layer, unsigned int flags, std::vector< std::pair > &shapes, db::PropertyMapper &pn) +collect_paths (const db::Layout &, const db::Cell *c, unsigned int layer, unsigned int flags, std::vector< std::pair > &shapes) { shapes.clear (); for (db::ShapeIterator s = c->shapes (layer).begin (db::ShapeIterator::Paths); !s.at_end (); ++s) { db::properties_id_type prop_id = 0; if (! (flags & layout_diff::f_no_properties)) { - prop_id = pn (s->prop_id ()); + prop_id = s->prop_id (); } shapes.push_back (std::make_pair (db::Path (), prop_id)); s->path (shapes.back ().first); @@ -728,16 +728,6 @@ do_compare_layouts (const db::Layout &a, const db::Cell *top_a, const db::Layout bool verbose = (flags & layout_diff::f_verbose); bool no_duplicates = (flags & layout_diff::f_ignore_duplicates); - db::Layout n, na, nb; - na.properties_repository () = a.properties_repository (); - nb.properties_repository () = b.properties_repository (); - - db::PropertyMapper prop_normalize_a (&n, &a); - db::PropertyMapper prop_normalize_b (&n, &b); - - db::PropertyMapper prop_remap_to_a (&na, &n); - db::PropertyMapper prop_remap_to_b (&nb, &n); - // compare layers std::map layers_a; @@ -986,19 +976,19 @@ do_compare_layouts (const db::Layout &a, const db::Cell *top_a, const db::Layout r.bbox_differs (cell_a->bbox (), cell_b->bbox ()); } - collect_insts (a, cell_a, flags, common_cell_indices_a, insts_a, prop_normalize_a, no_duplicates); - collect_insts (b, cell_b, flags, common_cell_indices_b, insts_b, prop_normalize_b, no_duplicates); + collect_insts (a, cell_a, flags, common_cell_indices_a, insts_a, no_duplicates); + collect_insts (b, cell_b, flags, common_cell_indices_b, insts_b, no_duplicates); std::vector anotb; std::set_difference (insts_a.begin (), insts_a.end (), insts_b.begin (), insts_b.end (), std::back_inserter (anotb)); - rewrite_instances_to (anotb, flags, common_cells_a, prop_remap_to_a); + rewrite_instances_to (anotb, flags, common_cells_a); collect_insts_of_unmapped_cells (a, cell_a, flags, common_cell_indices_a, anotb, no_duplicates); std::vector bnota; std::set_difference (insts_b.begin (), insts_b.end (), insts_a.begin (), insts_a.end (), std::back_inserter (bnota)); - rewrite_instances_to (bnota, flags, common_cells_b, prop_remap_to_b); + rewrite_instances_to (bnota, flags, common_cells_b); collect_insts_of_unmapped_cells (b, cell_b, flags, common_cell_indices_b, bnota, no_duplicates); if (! anotb.empty () || ! bnota.empty ()) { @@ -1013,8 +1003,8 @@ do_compare_layouts (const db::Layout &a, const db::Cell *top_a, const db::Layout if (verbose) { - r.instances_in_a (insts_a, common_cells, n.properties_repository ()); - r.instances_in_b (insts_b, common_cells, n.properties_repository ()); + r.instances_in_a (insts_a, common_cells); + r.instances_in_b (insts_b, common_cells); r.instances_in_a_only (anotb, a); r.instances_in_b_only (bnota, b); @@ -1062,10 +1052,10 @@ do_compare_layouts (const db::Layout &a, const db::Cell *top_a, const db::Layout polygons_a.clear(); polygons_b.clear(); if (is_valid_a) { - collect_polygons (a, cell_a, layer_a, flags, polygons_a, prop_normalize_a); + collect_polygons (a, cell_a, layer_a, flags, polygons_a); } if (is_valid_b) { - collect_polygons (b, cell_b, layer_b, flags, polygons_b, prop_normalize_b); + collect_polygons (b, cell_b, layer_b, flags, polygons_b); } reduce (polygons_a, polygons_b, make_polygon_compare_func (tolerance), tolerance > 0, no_duplicates); @@ -1077,7 +1067,7 @@ do_compare_layouts (const db::Layout &a, const db::Cell *top_a, const db::Layout } r.begin_polygon_differences (); if (verbose) { - r.detailed_diff (n.properties_repository (), polygons_a, polygons_b); + r.detailed_diff (polygons_a, polygons_b); } r.end_polygon_differences (); } @@ -1090,10 +1080,10 @@ do_compare_layouts (const db::Layout &a, const db::Cell *top_a, const db::Layout paths_a.clear(); paths_b.clear(); if (is_valid_a) { - collect_paths (a, cell_a, layer_a, flags, paths_a, prop_normalize_a); + collect_paths (a, cell_a, layer_a, flags, paths_a); } if (is_valid_b) { - collect_paths (b, cell_b, layer_b, flags, paths_b, prop_normalize_b); + collect_paths (b, cell_b, layer_b, flags, paths_b); } reduce (paths_a, paths_b, make_path_compare_func (tolerance), tolerance > 0, no_duplicates); @@ -1105,7 +1095,7 @@ do_compare_layouts (const db::Layout &a, const db::Cell *top_a, const db::Layout } r.begin_path_differences (); if (verbose) { - r.detailed_diff (n.properties_repository (), paths_a, paths_b); + r.detailed_diff (paths_a, paths_b); } r.end_path_differences (); } @@ -1117,10 +1107,10 @@ do_compare_layouts (const db::Layout &a, const db::Cell *top_a, const db::Layout texts_a.clear(); texts_b.clear(); if (is_valid_a) { - collect_texts (a, cell_a, layer_a, flags, texts_a, prop_normalize_a); + collect_texts (a, cell_a, layer_a, flags, texts_a); } if (is_valid_b) { - collect_texts (b, cell_b, layer_b, flags, texts_b, prop_normalize_b); + collect_texts (b, cell_b, layer_b, flags, texts_b); } reduce (texts_a, texts_b, make_text_compare_func (tolerance), tolerance > 0, no_duplicates); @@ -1132,7 +1122,7 @@ do_compare_layouts (const db::Layout &a, const db::Cell *top_a, const db::Layout } r.begin_text_differences (); if (verbose) { - r.detailed_diff (n.properties_repository (), texts_a, texts_b); + r.detailed_diff (texts_a, texts_b); } r.end_text_differences (); } @@ -1144,10 +1134,10 @@ do_compare_layouts (const db::Layout &a, const db::Cell *top_a, const db::Layout boxes_a.clear(); boxes_b.clear(); if (is_valid_a) { - collect_boxes (a, cell_a, layer_a, flags, boxes_a, prop_normalize_a); + collect_boxes (a, cell_a, layer_a, flags, boxes_a); } if (is_valid_b) { - collect_boxes (b, cell_b, layer_b, flags, boxes_b, prop_normalize_b); + collect_boxes (b, cell_b, layer_b, flags, boxes_b); } reduce (boxes_a, boxes_b, make_box_compare_func (tolerance), tolerance > 0, no_duplicates); @@ -1159,7 +1149,7 @@ do_compare_layouts (const db::Layout &a, const db::Cell *top_a, const db::Layout } r.begin_box_differences (); if (verbose) { - r.detailed_diff (n.properties_repository (), boxes_a, boxes_b); + r.detailed_diff (boxes_a, boxes_b); } r.end_box_differences (); } @@ -1171,10 +1161,10 @@ do_compare_layouts (const db::Layout &a, const db::Cell *top_a, const db::Layout edges_a.clear(); edges_b.clear(); if (is_valid_a) { - collect_edges (a, cell_a, layer_a, flags, edges_a, prop_normalize_a); + collect_edges (a, cell_a, layer_a, flags, edges_a); } if (is_valid_b) { - collect_edges (b, cell_b, layer_b, flags, edges_b, prop_normalize_b); + collect_edges (b, cell_b, layer_b, flags, edges_b); } reduce (edges_a, edges_b, make_edge_compare_func (tolerance), tolerance > 0, no_duplicates); @@ -1186,7 +1176,7 @@ do_compare_layouts (const db::Layout &a, const db::Cell *top_a, const db::Layout } r.begin_edge_differences (); if (verbose) { - r.detailed_diff (n.properties_repository (), edges_a, edges_b); + r.detailed_diff (edges_a, edges_b); } r.end_edge_differences (); } @@ -1196,10 +1186,10 @@ do_compare_layouts (const db::Layout &a, const db::Cell *top_a, const db::Layout edge_pairs_a.clear(); edge_pairs_b.clear(); if (is_valid_a) { - collect_edge_pairs (a, cell_a, layer_a, flags, edge_pairs_a, prop_normalize_a); + collect_edge_pairs (a, cell_a, layer_a, flags, edge_pairs_a); } if (is_valid_b) { - collect_edge_pairs (b, cell_b, layer_b, flags, edge_pairs_b, prop_normalize_b); + collect_edge_pairs (b, cell_b, layer_b, flags, edge_pairs_b); } reduce (edge_pairs_a, edge_pairs_b, make_edge_pair_compare_func (tolerance), tolerance > 0, no_duplicates); @@ -1211,7 +1201,7 @@ do_compare_layouts (const db::Layout &a, const db::Cell *top_a, const db::Layout } r.begin_edge_pair_differences (); if (verbose) { - r.detailed_diff (n.properties_repository (), edge_pairs_a, edge_pairs_b); + r.detailed_diff (edge_pairs_a, edge_pairs_b); } r.end_edge_pair_differences (); } @@ -1276,30 +1266,30 @@ public: void cell_meta_info_differs (const std::string &name, const tl::Variant &a, const tl::Variant &b); void bbox_differs (const db::Box &ba, const db::Box &bb); void begin_inst_differences (); - void instances_in_a (const std::vector &insts_a, const std::vector &cell_names, const db::PropertiesRepository &props); - void instances_in_b (const std::vector &insts_b, const std::vector &cell_names, const db::PropertiesRepository &props); + void instances_in_a (const std::vector &insts_a, const std::vector &cell_names); + void instances_in_b (const std::vector &insts_b, const std::vector &cell_names); void instances_in_a_only (const std::vector &anotb, const db::Layout &a); void instances_in_b_only (const std::vector &bnota, const db::Layout &b); void end_inst_differences (); void begin_layer (const db::LayerProperties &layer, unsigned int layer_index_a, bool is_valid_a, unsigned int layer_index_b, bool is_valid_b); void per_layer_bbox_differs (const db::Box &ba, const db::Box &bb); void begin_polygon_differences (); - void detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b); + void detailed_diff (const std::vector > &a, const std::vector > &b); void end_polygon_differences (); void begin_path_differences (); - void detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b); + void detailed_diff (const std::vector > &a, const std::vector > &b); void end_path_differences (); void begin_box_differences (); - void detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b); + void detailed_diff (const std::vector > &a, const std::vector > &b); void end_box_differences (); void begin_edge_differences (); - void detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b); + void detailed_diff (const std::vector > &a, const std::vector > &b); void end_edge_differences (); void begin_edge_pair_differences (); - void detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b); + void detailed_diff (const std::vector > &a, const std::vector > &b); void end_edge_pair_differences (); void begin_text_differences (); - void detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b); + void detailed_diff (const std::vector > &a, const std::vector > &b); void end_text_differences (); void end_layer (); void end_cell (); @@ -1314,7 +1304,7 @@ private: tl::Channel &enough (tl::Channel &); void print_cell_inst (const db::CellInstArrayWithProperties &ci, const std::vector &cell_names); void print_cell_inst (const db::CellInstArrayWithProperties &ci, const db::Layout &l); - template void print_diffs (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b); + template void print_diffs (const std::vector > &a, const std::vector > &b); }; PrintingDifferenceReceiver::PrintingDifferenceReceiver () @@ -1392,7 +1382,7 @@ PrintingDifferenceReceiver::print_cell_inst (const db::CellInstArrayWithProperti template void -PrintingDifferenceReceiver::print_diffs (const db::PropertiesRepository &pr, const std::vector > &_a, const std::vector > &_b) +PrintingDifferenceReceiver::print_diffs (const std::vector > &_a, const std::vector > &_b) { // the vectors may be in any order (specifically because of tolerances) but // for the diff we need to make sure they are ordered. @@ -1407,13 +1397,14 @@ PrintingDifferenceReceiver::print_diffs (const db::PropertiesRepository &pr, con enough (tl::info) << " " << s->first.to_string () << tl::noendl; if (s->second != 0) { if (m_print_properties) { - const db::PropertiesRepository::properties_set &props = pr.properties (s->second); - for (db::PropertiesRepository::properties_set::const_iterator p = props.begin (); p != props.end (); ++p) { - const tl::Variant &name = pr.prop_name (p->first); + const db::PropertiesSet &props = db::properties (s->second); + for (db::PropertiesSet::iterator p = props.begin (); p != props.end (); ++p) { + const tl::Variant &name = property_name (p->first); + const tl::Variant &value = property_value (p->second); if (name.is_long ()) { - tl::info << " {" << int (name.to_long ()) << " {" << p->second.to_string () << "}}" << tl::noendl; + tl::info << " {" << int (name.to_long ()) << " {" << value.to_string () << "}}" << tl::noendl; } else { - tl::info << " {{" << name.to_string () << "} {" << p->second.to_string () << "}}" << tl::noendl; + tl::info << " {{" << name.to_string () << "} {" << value.to_string () << "}}" << tl::noendl; } } tl::info << ""; @@ -1544,12 +1535,12 @@ PrintingDifferenceReceiver::begin_inst_differences () } void -PrintingDifferenceReceiver::instances_in_a (const std::vector & /*insts_a*/, const std::vector & /*cell_names*/, const db::PropertiesRepository & /*props*/) +PrintingDifferenceReceiver::instances_in_a (const std::vector & /*insts_a*/, const std::vector & /*cell_names*/) { } void -PrintingDifferenceReceiver::instances_in_b (const std::vector & /*insts_b*/, const std::vector & /*cell_names*/, const db::PropertiesRepository & /*props*/) +PrintingDifferenceReceiver::instances_in_b (const std::vector & /*insts_b*/, const std::vector & /*cell_names*/) { } @@ -1612,13 +1603,13 @@ PrintingDifferenceReceiver::begin_polygon_differences () } void -PrintingDifferenceReceiver::detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b) +PrintingDifferenceReceiver::detailed_diff (const std::vector > &a, const std::vector > &b) { try { enough (tl::info) << "Not in b but in a:"; - print_diffs (pr, a, b); + print_diffs (a, b); enough (tl::info) << "Not in a but in b:"; - print_diffs (pr, b, a); + print_diffs (b, a); } catch (tl::CancelException &) { // ignore cancel exceptions } @@ -1640,13 +1631,13 @@ PrintingDifferenceReceiver::begin_path_differences () } void -PrintingDifferenceReceiver::detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b) +PrintingDifferenceReceiver::detailed_diff (const std::vector > &a, const std::vector > &b) { try { enough (tl::info) << "Not in b but in a:"; - print_diffs (pr, a, b); + print_diffs (a, b); enough (tl::info) << "Not in a but in b:"; - print_diffs (pr, b, a); + print_diffs (b, a); } catch (tl::CancelException &) { // ignore cancel exceptions } @@ -1668,13 +1659,13 @@ PrintingDifferenceReceiver::begin_box_differences () } void -PrintingDifferenceReceiver::detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b) +PrintingDifferenceReceiver::detailed_diff (const std::vector > &a, const std::vector > &b) { try { enough (tl::info) << "Not in b but in a:"; - print_diffs (pr, a, b); + print_diffs (a, b); enough (tl::info) << "Not in a but in b:"; - print_diffs (pr, b, a); + print_diffs (b, a); } catch (tl::CancelException &) { // ignore cancel exceptions } @@ -1696,13 +1687,13 @@ PrintingDifferenceReceiver::begin_edge_differences () } void -PrintingDifferenceReceiver::detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b) +PrintingDifferenceReceiver::detailed_diff (const std::vector > &a, const std::vector > &b) { try { enough (tl::info) << "Not in b but in a:"; - print_diffs (pr, a, b); + print_diffs (a, b); enough (tl::info) << "Not in a but in b:"; - print_diffs (pr, b, a); + print_diffs (b, a); } catch (tl::CancelException &) { // ignore cancel exceptions } @@ -1724,13 +1715,13 @@ PrintingDifferenceReceiver::begin_edge_pair_differences () } void -PrintingDifferenceReceiver::detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b) +PrintingDifferenceReceiver::detailed_diff (const std::vector > &a, const std::vector > &b) { try { enough (tl::info) << "Not in b but in a:"; - print_diffs (pr, a, b); + print_diffs (a, b); enough (tl::info) << "Not in a but in b:"; - print_diffs (pr, b, a); + print_diffs (b, a); } catch (tl::CancelException &) { // ignore cancel exceptions } @@ -1752,13 +1743,13 @@ PrintingDifferenceReceiver::begin_text_differences () } void -PrintingDifferenceReceiver::detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b) +PrintingDifferenceReceiver::detailed_diff (const std::vector > &a, const std::vector > &b) { try { enough (tl::info) << "Not in b but in a:"; - print_diffs (pr, a, b); + print_diffs (a, b); enough (tl::info) << "Not in a but in b:"; - print_diffs (pr, b, a); + print_diffs (b, a); } catch (tl::CancelException &) { // ignore cancel exceptions } diff --git a/src/db/db/dbLayoutDiff.h b/src/db/db/dbLayoutDiff.h index 223ddd4f4..7c359972b 100644 --- a/src/db/db/dbLayoutDiff.h +++ b/src/db/db/dbLayoutDiff.h @@ -108,30 +108,30 @@ public: virtual void begin_cell (const std::string & /*cellname*/, db::cell_index_type /*cia*/, db::cell_index_type /*cib*/) { } virtual void cell_meta_info_differs (const std::string & /*name*/, const tl::Variant & /*value_a*/, const tl::Variant & /*value_b*/) { } virtual void begin_inst_differences () { } - virtual void instances_in_a (const std::vector & /*insts_a*/, const std::vector & /*cell_names*/, const db::PropertiesRepository & /*props*/) { } - virtual void instances_in_b (const std::vector & /*insts_b*/, const std::vector & /*cell_names*/, const db::PropertiesRepository & /*props*/) { } + virtual void instances_in_a (const std::vector & /*insts_a*/, const std::vector & /*cell_names*/) { } + virtual void instances_in_b (const std::vector & /*insts_b*/, const std::vector & /*cell_names*/) { } virtual void instances_in_a_only (const std::vector & /*anotb*/, const db::Layout & /*a*/) { } virtual void instances_in_b_only (const std::vector & /*bnota*/, const db::Layout & /*b*/) { } virtual void end_inst_differences () { } virtual void begin_layer (const db::LayerProperties & /*layer*/, unsigned int /*layer_index_a*/, bool /*is_valid_a*/, unsigned int /*layer_index_b*/, bool /*is_valid_b*/) { } virtual void per_layer_bbox_differs (const db::Box & /*ba*/, const db::Box & /*bb*/) { } virtual void begin_polygon_differences () { } - virtual void detailed_diff (const db::PropertiesRepository & /*pr*/, const std::vector > & /*a*/, const std::vector > & /*b*/) { } + virtual void detailed_diff (const std::vector > & /*a*/, const std::vector > & /*b*/) { } virtual void end_polygon_differences () { } virtual void begin_path_differences () { } - virtual void detailed_diff (const db::PropertiesRepository & /*pr*/, const std::vector > & /*a*/, const std::vector > & /*b*/) { } + virtual void detailed_diff (const std::vector > & /*a*/, const std::vector > & /*b*/) { } virtual void end_path_differences () { } virtual void begin_box_differences () { } - virtual void detailed_diff (const db::PropertiesRepository & /*pr*/, const std::vector > & /*a*/, const std::vector > & /*b*/) { } + virtual void detailed_diff (const std::vector > & /*a*/, const std::vector > & /*b*/) { } virtual void end_box_differences () { } virtual void begin_edge_differences () { } - virtual void detailed_diff (const db::PropertiesRepository & /*pr*/, const std::vector > & /*a*/, const std::vector > & /*b*/) { } + virtual void detailed_diff (const std::vector > & /*a*/, const std::vector > & /*b*/) { } virtual void end_edge_differences () { } virtual void begin_edge_pair_differences () { } - virtual void detailed_diff (const db::PropertiesRepository & /*pr*/, const std::vector > & /*a*/, const std::vector > & /*b*/) { } + virtual void detailed_diff (const std::vector > & /*a*/, const std::vector > & /*b*/) { } virtual void end_edge_pair_differences () { } virtual void begin_text_differences () { } - virtual void detailed_diff (const db::PropertiesRepository & /*pr*/, const std::vector > & /*a*/, const std::vector > & /*b*/) { } + virtual void detailed_diff (const std::vector > & /*a*/, const std::vector > & /*b*/) { } virtual void end_text_differences () { } virtual void end_layer () { } virtual void end_cell () { } diff --git a/src/db/db/dbLayoutToNetlist.cc b/src/db/db/dbLayoutToNetlist.cc index 4970ac952..b9ecf00e3 100644 --- a/src/db/db/dbLayoutToNetlist.cc +++ b/src/db/db/dbLayoutToNetlist.cc @@ -1935,11 +1935,11 @@ db::Region LayoutToNetlist::antenna_check (const db::Region &gate, double gate_a db::properties_id_type prop_id = 0; if (! values) { - db::PropertiesRepository::properties_set ps; + db::PropertiesSet ps; for (auto v = antenna_values.begin (); v != antenna_values.end (); ++v) { - ps.insert (std::make_pair (ly.properties_repository ().prop_name_id (v->first), v->second)); + ps.insert (v->first, v->second); } - prop_id = ly.properties_repository ().properties_id (ps); + prop_id = db::properties_id (ps); } db::Point ref = get_merged_shapes_of_net (m_net_clusters, *cid, *c, layer_of (metal), &ly, shapes, prop_id); @@ -2157,7 +2157,7 @@ NetBuilder::build_net (db::Cell &target_cell, const db::Net &net, const std::map double mag = mp_source->internal_layout ()->dbu () / mp_target->dbu (); - db::properties_id_type netname_propid = make_netname_propid (target ().properties_repository (), net_prop_mode, netname_prop, net); + db::properties_id_type netname_propid = make_netname_propid (net_prop_mode, netname_prop, net); build_net_rec (net, target_cell, lmap, std::string (), netname_propid, db::ICplxTrans (mag)); } @@ -2190,7 +2190,7 @@ NetBuilder::build_nets (const std::vector *nets, const std::map ()) != net_set.end ()) { - db::properties_id_type netname_propid = make_netname_propid (target ().properties_repository (), prop_mode, netname_prop, *n); + db::properties_id_type netname_propid = make_netname_propid (prop_mode, netname_prop, *n); build_net_rec (*n, c->cell_index (), lmap, std::string (), netname_propid, db::ICplxTrans ()); } @@ -2220,7 +2220,7 @@ NetBuilder::build_nets (const std::vector *nets, const std::mapcell_index (), lmap, net_name_prefix, netname_propid, tr); @@ -2382,7 +2382,7 @@ NetBuilder::build_net_rec (const db::Net &net, db::cell_index_type circuit_cell, } db::properties_id_type -NetBuilder::make_netname_propid (db::PropertiesRepository &pr, NetPropertyMode net_prop_mode, const tl::Variant &netname_prop, const db::Net &net, const std::string &net_name_prefix) +NetBuilder::make_netname_propid (NetPropertyMode net_prop_mode, const tl::Variant &netname_prop, const db::Net &net, const std::string &net_name_prefix) { if (net_prop_mode == NPM_NoProperties) { @@ -2390,30 +2390,28 @@ NetBuilder::make_netname_propid (db::PropertiesRepository &pr, NetPropertyMode n } else if (! netname_prop.is_nil () || (net_prop_mode == NPM_AllProperties && net.begin_properties () != net.end_properties ())) { - db::PropertiesRepository::properties_set propset; + db::PropertiesSet propset; // add the user properties too (TODO: make this configurable?) for (db::Net::property_iterator p = net.begin_properties (); p != net.end_properties (); ++p) { - db::property_names_id_type key_propnameid = pr.prop_name_id (p->first); - propset.insert (std::make_pair (key_propnameid, p->second)); + propset.insert (p->first, p->second); } if (! netname_prop.is_nil ()) { - db::property_names_id_type name_propnameid = pr.prop_name_id (netname_prop); if (net_prop_mode == NPM_NetQualifiedNameOnly) { std::vector l; l.reserve (2); l.push_back (tl::Variant (net_name_prefix + net.expanded_name ())); l.push_back (tl::Variant (net.circuit ()->name ())); - propset.insert (std::make_pair (name_propnameid, tl::Variant (l))); + propset.insert (netname_prop, tl::Variant (l)); } else if (net_prop_mode == NPM_NetIDOnly) { - propset.insert (std::make_pair (name_propnameid, tl::Variant (reinterpret_cast (&net)))); + propset.insert (netname_prop, tl::Variant (reinterpret_cast (&net))); } else { - propset.insert (std::make_pair (name_propnameid, tl::Variant (net_name_prefix + net.expanded_name ()))); + propset.insert (netname_prop, tl::Variant (net_name_prefix + net.expanded_name ())); } } - return pr.properties_id (propset); + return db::properties_id (propset); } else { diff --git a/src/db/db/dbLayoutToNetlist.h b/src/db/db/dbLayoutToNetlist.h index 04de1b4a0..b3820231b 100644 --- a/src/db/db/dbLayoutToNetlist.h +++ b/src/db/db/dbLayoutToNetlist.h @@ -1249,7 +1249,7 @@ public: /** * @brief A helper function to create a property ID for a given net, net property name and net property mode */ - static db::properties_id_type make_netname_propid (db::PropertiesRepository &pr, NetPropertyMode net_prop_mode, const tl::Variant &netname_prop, const db::Net &net, const std::string &net_name_prefix = std::string ()); + static db::properties_id_type make_netname_propid (NetPropertyMode net_prop_mode, const tl::Variant &netname_prop, const db::Net &net, const std::string &net_name_prefix = std::string ()); private: struct CellReuseTableKey diff --git a/src/db/db/dbLayoutUtils.cc b/src/db/db/dbLayoutUtils.cc index 631c03277..44f675635 100644 --- a/src/db/db/dbLayoutUtils.cc +++ b/src/db/db/dbLayoutUtils.cc @@ -58,110 +58,6 @@ DirectLayerMapping::map_layer (const LayerProperties &lprops) } } -// ------------------------------------------------------------------------------------ -// PropertyMapper implementation - -PropertyMapper::PropertyMapper (db::Layout *target, const db::Layout *source) - : mp_target (target ? &target->properties_repository () : 0), mp_source (source ? &source->properties_repository () : 0) -{ - // .. nothing yet .. -} - -PropertyMapper::PropertyMapper (db::PropertiesRepository *target, const db::PropertiesRepository *source) - : mp_target (target), mp_source (source) -{ - // .. nothing yet .. -} - -/** - * @brief Instantiate a property mapper for mapping of property ids from the source to the target layout - * - * This version does not specify a certain source or target layout. These must be set with the - * set_source or set_target methods. - */ -PropertyMapper::PropertyMapper () - : mp_target (0), mp_source (0) -{ - // .. nothing yet .. -} - -/** - * @brief Specify the source layout - */ -void -PropertyMapper::set_source (const db::Layout *source) -{ - const db::PropertiesRepository *pr = source ? &source->properties_repository () : 0; - if (pr != mp_source) { - m_prop_id_map.clear (); - mp_source = pr; - } -} - -/** - * @brief Specify the source property repository - */ -void -PropertyMapper::set_source (const db::PropertiesRepository *source) -{ - if (source != mp_source) { - m_prop_id_map.clear (); - mp_source = source; - } -} - -/** - * @brief Specify the target layout - */ -void -PropertyMapper::set_target (db::Layout *target) -{ - db::PropertiesRepository *pr = target ? &target->properties_repository () : 0; - if (pr != mp_target) { - m_prop_id_map.clear (); - mp_target = pr; - } -} - -/** - * @brief Specify the target property repository - */ -void -PropertyMapper::set_target (db::PropertiesRepository *target) -{ - if (target != mp_target) { - m_prop_id_map.clear (); - mp_target = target; - } -} - -/** - * @brief The actual mapping function - */ -db::Layout::properties_id_type -PropertyMapper::operator() (db::Layout::properties_id_type source_id) -{ - if (source_id == 0 || mp_source == mp_target || ! mp_source || ! mp_target) { - return source_id; - } - - tl_assert (mp_source != 0); - tl_assert (mp_target != 0); - - static tl::Mutex s_mutex; - tl::MutexLocker locker (&s_mutex); - - std::map ::const_iterator p = m_prop_id_map.find (source_id); - - if (p == m_prop_id_map.end ()) { - db::Layout::properties_id_type new_id = mp_target->translate (*mp_source, source_id); - m_prop_id_map.insert (std::make_pair (source_id, new_id)); - return new_id; - } else { - return p->second; - } -} - // ------------------------------------------------------------------------------------ // merge_layouts implementation @@ -231,9 +127,6 @@ merge_layouts (db::Layout &target, final_cell_mapping->insert (new_cell_mapping.begin (), new_cell_mapping.end ()); } - // provide the property mapper - db::PropertyMapper pm (&target, &source); - tl::RelativeProgress progress (tl::to_string (tr ("Merge layouts")), all_cells_to_copy.size (), 1); // actually to the mapping @@ -262,7 +155,7 @@ merge_layouts (db::Layout &target, // copy and transform the shapes for (std::map::const_iterator lm = layer_mapping.begin (); lm != layer_mapping.end (); ++lm) { - target_cell.shapes (lm->second).insert_transformed (source_cell.shapes (lm->first), trans, pm); + target_cell.shapes (lm->second).insert_transformed (source_cell.shapes (lm->first), trans); } // copy the instances @@ -278,7 +171,7 @@ merge_layouts (db::Layout &target, new_inst_array.object ().cell_index (nc->second); if (inst->has_prop_id ()) { - target_cell.insert (db::object_with_properties (new_inst_array, pm (inst->prop_id ()))); + target_cell.insert (db::object_with_properties (new_inst_array, inst->prop_id ())); } else { target_cell.insert (new_inst_array); } @@ -296,7 +189,6 @@ copy_or_propagate_shapes (db::Layout &target, const db::Layout &source, const db::ICplxTrans &trans, const db::ICplxTrans &propagate_trans, - db::PropertyMapper &pm, db::cell_index_type source_cell_index, db::cell_index_type source_parent_cell_index, unsigned int target_layer, unsigned int source_layer, @@ -316,7 +208,7 @@ copy_or_propagate_shapes (db::Layout &target, const db::CellInstArray &cell_inst = p->child_inst ().cell_inst (); for (db::CellInstArray::iterator a = cell_inst.begin (); ! a.at_end (); ++a) { db::ICplxTrans t = db::ICplxTrans (cell_inst.complex_trans (*a)) * propagate_trans; - copy_or_propagate_shapes (target, source, trans, t, pm, source_cell_index, p->parent_cell_index (), target_layer, source_layer, all_cells_to_copy, cell_mapping, transformer); + copy_or_propagate_shapes (target, source, trans, t, source_cell_index, p->parent_cell_index (), target_layer, source_layer, all_cells_to_copy, cell_mapping, transformer); } } @@ -325,7 +217,7 @@ copy_or_propagate_shapes (db::Layout &target, } else if (cm->second != DropCell) { db::Cell &target_cell = target.cell (cm->second); - transformer->insert_transformed (target_cell.shapes (target_layer), source_cell.shapes (source_layer), trans * propagate_trans, pm); + transformer->insert_transformed (target_cell.shapes (target_layer), source_cell.shapes (source_layer), trans * propagate_trans); } } @@ -346,16 +238,13 @@ copy_or_move_shapes (db::Layout &target, collect_cells_to_copy (source, source_cells, cell_mapping, all_top_level_cells, all_cells_to_copy); - // provide the property mapper - db::PropertyMapper pm (&target, &source); - tl::RelativeProgress progress (tl::to_string (tr ("Copy shapes")), all_cells_to_copy.size () * layer_mapping.size (), 1); // and copy for (std::set::const_iterator c = all_cells_to_copy.begin (); c != all_cells_to_copy.end (); ++c) { for (std::map::const_iterator lm = layer_mapping.begin (); lm != layer_mapping.end (); ++lm) { ++progress; - copy_or_propagate_shapes (target, source, trans, db::ICplxTrans (), pm, *c, *c, lm->second, lm->first, all_cells_to_copy, cell_mapping, transformer); + copy_or_propagate_shapes (target, source, trans, db::ICplxTrans (), *c, *c, lm->second, lm->first, all_cells_to_copy, cell_mapping, transformer); if (move) { source.cell (*c).shapes (lm->first).clear (); } @@ -369,9 +258,9 @@ namespace : public ShapesTransformer { public: - void insert_transformed (Shapes &into, const Shapes &from, const ICplxTrans &trans, PropertyMapper &pm) const + void insert_transformed (Shapes &into, const Shapes &from, const ICplxTrans &trans) const { - into.insert_transformed (from, trans, pm); + into.insert_transformed (from, trans); } }; } diff --git a/src/db/db/dbLayoutUtils.h b/src/db/db/dbLayoutUtils.h index d3a15c207..ae16cd5b3 100644 --- a/src/db/db/dbLayoutUtils.h +++ b/src/db/db/dbLayoutUtils.h @@ -65,70 +65,6 @@ private: bool m_initialized; }; -/** - * @brief A property mapper based on a dynamic property id generation - * - * This class can be used as property mapper for certain "insert" flavors of - * the Instance and Shapes class. - */ -class DB_PUBLIC PropertyMapper -{ -public: - /** - * @brief Instantiate a property mapper for mapping of property ids from the source to the target layout - * - * @param source The source layout - * @param target The target layout - */ - PropertyMapper (db::Layout *target, const db::Layout *source); - - /** - * @brief Instantiate a property mapper for mapping of property ids from the source to the target property repository - * - * @param source The source property repository - * @param target The target property repository - */ - PropertyMapper (db::PropertiesRepository *target, const db::PropertiesRepository *source); - - /** - * @brief Instantiate a property mapper for mapping of property ids from the source to the target layout - * - * This version does not specify a certain source or target layout. These must be set with the - * set_source or set_target methods. - */ - PropertyMapper (); - - /** - * @brief Specify the source layout - */ - void set_source (const db::Layout *source); - - /** - * @brief Specify the source property repository - */ - void set_source (const db::PropertiesRepository *source); - - /** - * @brief Specify the target layout - */ - void set_target (db::Layout *target); - - /** - * @brief Specify the target property repository - */ - void set_target (db::PropertiesRepository *target); - - /** - * @brief The actual mapping function - */ - db::Layout::properties_id_type operator() (db::Layout::properties_id_type source_id); - -private: - db::PropertiesRepository *mp_target; - const db::PropertiesRepository *mp_source; - std::map m_prop_id_map; -}; - /** * @brief A constant describing "drop cell" mapping * @@ -170,7 +106,7 @@ class DB_PUBLIC ShapesTransformer public: ShapesTransformer () { } virtual ~ShapesTransformer () { } - virtual void insert_transformed (db::Shapes &into, const db::Shapes &from, const db::ICplxTrans &trans, db::PropertyMapper &pm) const = 0; + virtual void insert_transformed (db::Shapes &into, const db::Shapes &from, const db::ICplxTrans &trans) const = 0; }; /** diff --git a/src/db/db/dbLibraryProxy.cc b/src/db/db/dbLibraryProxy.cc index ff86a6f5e..3066e4a26 100644 --- a/src/db/db/dbLibraryProxy.cc +++ b/src/db/db/dbLibraryProxy.cc @@ -225,18 +225,16 @@ LibraryProxy::update (db::ImportLayerMapping *layer_mapping) clear_shapes (); clear_insts (); - PropertyMapper prop_id_map (layout (), &lib->layout ()); - for (unsigned int l = 0; l < lib->layout ().layers (); ++l) { if (layer_indices [l] >= 0) { - shapes ((unsigned int) layer_indices [l]).assign_transformed (source_cell.shapes (l), tr, prop_id_map); + shapes ((unsigned int) layer_indices [l]).assign_transformed (source_cell.shapes (l), tr); } } LibraryCellIndexMapper cell_index_mapper (*layout (), lib); for (Cell::const_iterator inst = source_cell.begin (); !inst.at_end (); ++inst) { - db::Instance new_inst = insert (*inst, cell_index_mapper, prop_id_map); + db::Instance new_inst = insert (*inst, cell_index_mapper); if (need_transform) { replace (new_inst, new_inst.cell_inst ().transformed_into (tr)); } diff --git a/src/db/db/dbLocalOperationUtils.h b/src/db/db/dbLocalOperationUtils.h index 1c7d33942..6e5f8d04a 100644 --- a/src/db/db/dbLocalOperationUtils.h +++ b/src/db/db/dbLocalOperationUtils.h @@ -39,8 +39,6 @@ namespace db { -class PropertyMapper; - template class polygon_transformation_filter : public PolygonSink @@ -325,7 +323,7 @@ private: template DB_PUBLIC_TEMPLATE std::map, std::set > > -separate_interactions_by_properties (const shape_interactions, db::object_with_properties > &interactions, db::PropertyConstraint property_constraint, db::PropertyMapper &pms, db::PropertyMapper &pmi) +separate_interactions_by_properties (const shape_interactions, db::object_with_properties > &interactions, db::PropertyConstraint property_constraint) { std::map, std::set > > by_prop_id; @@ -333,7 +331,7 @@ separate_interactions_by_properties (const shape_interactions &subject = interactions.subject_shape (i->first); - db::properties_id_type prop_id = pms (subject.properties_id ()); + db::properties_id_type prop_id = subject.properties_id (); std::pair, std::set > &s2p = by_prop_id [prop_id]; s2p.first.push_back (&subject); @@ -342,7 +340,7 @@ separate_interactions_by_properties (const shape_interactions > &intruder = interactions.intruder_shape (*ii); - if (pc_match (property_constraint, prop_id, pmi (intruder.second.properties_id ()))) { + if (pc_match (property_constraint, prop_id, intruder.second.properties_id ())) { s2p.second.insert (&intruder.second); } @@ -363,7 +361,7 @@ separate_interactions_by_properties (const shape_interactions DB_PUBLIC_TEMPLATE std::map > -separate_interactions_to_interactions_by_properties (const shape_interactions, db::object_with_properties > &interactions, db::PropertyConstraint property_constraint, db::PropertyMapper &pms, std::vector &pmis) +separate_interactions_to_interactions_by_properties (const shape_interactions, db::object_with_properties > &interactions, db::PropertyConstraint property_constraint) { std::map > by_prop_id; std::map > intruder_ids_by_prop_id; @@ -371,7 +369,7 @@ separate_interactions_to_interactions_by_properties (const shape_interactions &subject = interactions.subject_shape (i->first); - db::properties_id_type prop_id = pms (subject.properties_id ()); + db::properties_id_type prop_id = subject.properties_id (); db::shape_interactions &s2p = by_prop_id [prop_id]; std::set &intruder_ids = intruder_ids_by_prop_id [prop_id]; @@ -380,9 +378,8 @@ separate_interactions_to_interactions_by_properties (const shape_interactionssecond.begin (); ii != i->second.end (); ++ii) { const std::pair > &intruder = interactions.intruder_shape (*ii); - tl_assert (intruder.first < (unsigned int) pmis.size ()); - if (pc_match (property_constraint, prop_id, pmis[intruder.first] (intruder.second.properties_id ()))) { + if (pc_match (property_constraint, prop_id, intruder.second.properties_id ())) { s2p.add_interaction (i->first, *ii); intruder_ids.insert (*ii); } diff --git a/src/db/db/dbNetlistDeviceExtractor.cc b/src/db/db/dbNetlistDeviceExtractor.cc index 00cbe62a5..356c984d0 100644 --- a/src/db/db/dbNetlistDeviceExtractor.cc +++ b/src/db/db/dbNetlistDeviceExtractor.cc @@ -180,9 +180,9 @@ void NetlistDeviceExtractor::extract_without_initialize (db::Layout &layout, db: mp_breakout_cells = breakout_cells; // terminal properties are kept in a property with the terminal_property_name name - m_terminal_id_propname_id = mp_layout->properties_repository ().prop_name_id (terminal_id_property_name ()); - m_device_id_propname_id = mp_layout->properties_repository ().prop_name_id (device_id_property_name ()); - m_device_class_propname_id = mp_layout->properties_repository ().prop_name_id (device_class_property_name ()); + m_terminal_id_propname_id = db::property_names_id (terminal_id_property_name ()); + m_device_id_propname_id = db::property_names_id (device_id_property_name ()); + m_device_class_propname_id = db::property_names_id (device_class_property_name ()); tl_assert (m_netlist.get () != 0); @@ -362,7 +362,7 @@ void NetlistDeviceExtractor::push_new_devices (const db::Vector &disp_cache) key.parameters.insert (std::make_pair (p->id (), device->parameter_value (p->id ()))); } - db::PropertiesRepository::properties_set ps; + db::PropertiesSet ps; std::map >::iterator c = m_device_cells.find (key); if (c == m_device_cells.end ()) { @@ -378,15 +378,15 @@ void NetlistDeviceExtractor::push_new_devices (const db::Vector &disp_cache) // attach the device class ID to the cell ps.clear (); - ps.insert (std::make_pair (m_device_class_propname_id, tl::Variant (mp_device_class->name ()))); - device_cell.prop_id (mp_layout->properties_repository ().properties_id (ps)); + ps.insert (m_device_class_propname_id, tl::Variant (mp_device_class->name ())); + device_cell.prop_id (db::properties_id (ps)); for (geometry_per_terminal_type::const_iterator t = d->second.second.begin (); t != d->second.second.end (); ++t) { // Build a property set for the device terminal ID ps.clear (); - ps.insert (std::make_pair (m_terminal_id_propname_id, tl::Variant (t->first))); - db::properties_id_type pi = mp_layout->properties_repository ().properties_id (ps); + ps.insert (m_terminal_id_propname_id, tl::Variant (t->first)); + db::properties_id_type pi = db::properties_id (ps); // build the cell shapes for (geometry_per_layer_type::const_iterator l = t->second.begin (); l != t->second.end (); ++l) { @@ -409,8 +409,8 @@ void NetlistDeviceExtractor::push_new_devices (const db::Vector &disp_cache) // Build a property set for the device ID ps.clear (); - ps.insert (std::make_pair (m_device_id_propname_id, tl::Variant (d->first))); - db::properties_id_type pi = mp_layout->properties_repository ().properties_id (ps); + ps.insert (m_device_id_propname_id, tl::Variant (d->first)); + db::properties_id_type pi = db::properties_id (ps); db::CellInstArrayWithProperties inst (db::CellInstArray (db::CellInst (c->second.first), db::Trans (disp_cache + disp)), pi); mp_layout->cell (m_cell_index).insert (inst); @@ -422,7 +422,7 @@ void NetlistDeviceExtractor::push_cached_devices (const tl::vector { db::CplxTrans dbu = db::CplxTrans (mp_layout->dbu ()); db::VCplxTrans dbu_inv = dbu.inverted (); - db::PropertiesRepository::properties_set ps; + db::PropertiesSet ps; for (std::vector::const_iterator d = cached_devices.begin (); d != cached_devices.end (); ++d) { @@ -435,8 +435,8 @@ void NetlistDeviceExtractor::push_cached_devices (const tl::vector // Build a property set for the device ID ps.clear (); - ps.insert (std::make_pair (m_device_id_propname_id, tl::Variant (device->id ()))); - db::properties_id_type pi = mp_layout->properties_repository ().properties_id (ps); + ps.insert (m_device_id_propname_id, tl::Variant (device->id ())); + db::properties_id_type pi = db::properties_id (ps); db::CellInstArrayWithProperties inst (db::CellInstArray (db::CellInst (device->device_abstract ()->cell_index ()), db::Trans (new_disp + disp)), pi); mp_layout->cell (m_cell_index).insert (inst); diff --git a/src/db/db/dbNetlistExtractor.cc b/src/db/db/dbNetlistExtractor.cc index cfd253135..5f8259ffd 100644 --- a/src/db/db/dbNetlistExtractor.cc +++ b/src/db/db/dbNetlistExtractor.cc @@ -65,6 +65,7 @@ build_net_name_equivalence (const db::Layout *layout, const db::Connectivity &co { std::map > prop_by_name; +#if 0 // @@@ for (db::PropertiesRepository::iterator i = layout->properties_repository ().begin (); i != layout->properties_repository ().end (); ++i) { for (db::PropertiesRepository::properties_set::const_iterator p = i->second.begin (); p != i->second.end (); ++p) { if (p->first == net_name_id) { @@ -77,6 +78,7 @@ build_net_name_equivalence (const db::Layout *layout, const db::Connectivity &co } } } +#endif // include pseudo-attributes for global nets to implement "join_with" for global nets for (size_t gid = 0; gid < conn.global_nets (); ++gid) { @@ -113,6 +115,7 @@ build_net_name_equivalence_for_explicit_connections (const db::Layout *layout, c { std::map > prop_by_name; +#if 0 // @@@ for (db::PropertiesRepository::iterator i = layout->properties_repository ().begin (); i != layout->properties_repository ().end (); ++i) { for (db::PropertiesRepository::properties_set::const_iterator p = i->second.begin (); p != i->second.end (); ++p) { if (p->first == net_name_id) { @@ -123,6 +126,7 @@ build_net_name_equivalence_for_explicit_connections (const db::Layout *layout, c } } } +#endif // include pseudo-attributes for global nets to implement "join_with" for global nets for (size_t gid = 0; gid < conn.global_nets (); ++gid) { @@ -171,11 +175,11 @@ NetlistExtractor::extract_nets (const db::DeepShapeStore &dss, unsigned int layo // this is how the texts are passed for annotating the net names m_text_annot_name_id = std::pair (false, 0); if (! dss.text_property_name ().is_nil ()) { - m_text_annot_name_id = mp_layout->properties_repository ().get_id_of_name (dss.text_property_name ()); + m_text_annot_name_id = db::PropertiesRepository::instance ().get_id_of_name (dss.text_property_name ()); } - m_terminal_annot_name_id = mp_layout->properties_repository ().get_id_of_name (db::NetlistDeviceExtractor::terminal_id_property_name ()); - m_device_annot_name_id = mp_layout->properties_repository ().get_id_of_name (db::NetlistDeviceExtractor::device_id_property_name ()); + m_terminal_annot_name_id = db::PropertiesRepository::instance ().get_id_of_name (db::NetlistDeviceExtractor::terminal_id_property_name ()); + m_device_annot_name_id = db::PropertiesRepository::instance ().get_id_of_name (db::NetlistDeviceExtractor::device_id_property_name ()); // build an attribute equivalence map which lists the "attribute IDs" which are identical in terms of net names // TODO: this feature is not really used as must-connect nets now are handled in the LayoutToNetlist class on netlist level. @@ -409,12 +413,12 @@ NetlistExtractor::make_device_abstract_connections (db::DeviceAbstract *dm, conn db::properties_id_type pi = db::prop_id_from_attr (*a); - const db::PropertiesRepository::properties_set &ps = mp_layout->properties_repository ().properties (pi); - for (db::PropertiesRepository::properties_set::const_iterator j = ps.begin (); j != ps.end (); ++j) { + const db::PropertiesSet &ps = db::properties (pi); + for (db::PropertiesSet::iterator j = ps.begin (); j != ps.end (); ++j) { if (j->first == m_terminal_annot_name_id.second) { - size_t terminal_id = j->second.to (); + size_t terminal_id = db::property_value (j->second).to (); if (*id != dc->id ()) { tl::warn << tl::sprintf (tl::to_string (tr ("Ignoring soft connection at device terminal %s for device %s")), dm->device_class ()->terminal_definition (terminal_id)->name (), dm->device_class ()->name ()); join = true; @@ -462,11 +466,11 @@ void NetlistExtractor::collect_labels (const connected_clusters_type &clusters, db::properties_id_type pi = db::prop_id_from_attr (*a); - const db::PropertiesRepository::properties_set &ps = mp_layout->properties_repository ().properties (pi); - for (db::PropertiesRepository::properties_set::const_iterator j = ps.begin (); j != ps.end (); ++j) { + const db::PropertiesSet &ps = db::properties (pi); + for (db::PropertiesSet::iterator j = ps.begin (); j != ps.end (); ++j) { if (m_text_annot_name_id.first && j->first == m_text_annot_name_id.second) { - net_names.insert (j->second.to_string ()); + net_names.insert (db::property_value (j->second).to_string ()); } } @@ -486,8 +490,8 @@ bool NetlistExtractor::instance_is_device (db::properties_id_type prop_id) const return false; } - const db::PropertiesRepository::properties_set &ps = mp_layout->properties_repository ().properties (prop_id); - for (db::PropertiesRepository::properties_set::const_iterator j = ps.begin (); j != ps.end (); ++j) { + const db::PropertiesSet &ps = db::properties (prop_id); + for (db::PropertiesSet::iterator j = ps.begin (); j != ps.end (); ++j) { if (j->first == m_device_annot_name_id.second) { return true; } @@ -502,10 +506,10 @@ db::Device *NetlistExtractor::device_from_instance (db::properties_id_type prop_ return 0; } - const db::PropertiesRepository::properties_set &ps = mp_layout->properties_repository ().properties (prop_id); - for (db::PropertiesRepository::properties_set::const_iterator j = ps.begin (); j != ps.end (); ++j) { + const db::PropertiesSet &ps = db::properties (prop_id); + for (db::PropertiesSet::iterator j = ps.begin (); j != ps.end (); ++j) { if (j->first == m_device_annot_name_id.second) { - return circuit->device_by_id (j->second.to ()); + return circuit->device_by_id (db::property_value (j->second).to ()); } } @@ -541,12 +545,12 @@ void NetlistExtractor::connect_devices (db::Circuit *circuit, db::properties_id_type pi = db::prop_id_from_attr (*a); - const db::PropertiesRepository::properties_set &ps = mp_layout->properties_repository ().properties (pi); - for (db::PropertiesRepository::properties_set::const_iterator j = ps.begin (); j != ps.end (); ++j) { + const db::PropertiesSet &ps = db::properties (pi); + for (db::PropertiesSet::iterator j = ps.begin (); j != ps.end (); ++j) { if (m_terminal_annot_name_id.first && j->first == m_terminal_annot_name_id.second) { - size_t tid = j->second.to (); + size_t tid = db::property_value (j->second).to (); device->connect_terminal (tid, net); } diff --git a/src/db/db/dbOriginalLayerEdgePairs.cc b/src/db/db/dbOriginalLayerEdgePairs.cc index 9aeb25ead..79633fda1 100644 --- a/src/db/db/dbOriginalLayerEdgePairs.cc +++ b/src/db/db/dbOriginalLayerEdgePairs.cc @@ -208,18 +208,6 @@ OriginalLayerEdgePairs::apply_property_translator (const db::PropertiesTranslato m_iter.apply_property_translator (pt); } -db::PropertiesRepository * -OriginalLayerEdgePairs::properties_repository () -{ - return m_iter.layout () ? &const_cast(m_iter.layout ())->properties_repository () : 0; -} - -const db::PropertiesRepository * -OriginalLayerEdgePairs::properties_repository () const -{ - return m_iter.layout () ? &m_iter.layout ()->properties_repository () : 0; -} - bool OriginalLayerEdgePairs::equals (const EdgePairs &other) const { diff --git a/src/db/db/dbOriginalLayerEdgePairs.h b/src/db/db/dbOriginalLayerEdgePairs.h index 001059b88..f60e44ade 100644 --- a/src/db/db/dbOriginalLayerEdgePairs.h +++ b/src/db/db/dbOriginalLayerEdgePairs.h @@ -57,8 +57,6 @@ public: virtual const db::RecursiveShapeIterator *iter () const; virtual void apply_property_translator (const db::PropertiesTranslator &pt); - virtual db::PropertiesRepository *properties_repository (); - virtual const db::PropertiesRepository *properties_repository () const; virtual bool equals (const EdgePairs &other) const; virtual bool less (const EdgePairs &other) const; diff --git a/src/db/db/dbOriginalLayerEdges.cc b/src/db/db/dbOriginalLayerEdges.cc index 952d668e0..7d5acb2aa 100644 --- a/src/db/db/dbOriginalLayerEdges.cc +++ b/src/db/db/dbOriginalLayerEdges.cc @@ -260,18 +260,6 @@ OriginalLayerEdges::apply_property_translator (const db::PropertiesTranslator &p m_merged_edges.clear (); } -db::PropertiesRepository * -OriginalLayerEdges::properties_repository () -{ - return m_iter.layout () ? &const_cast(m_iter.layout ())->properties_repository () : 0; -} - -const db::PropertiesRepository * -OriginalLayerEdges::properties_repository () const -{ - return m_iter.layout () ? &m_iter.layout ()->properties_repository () : 0; -} - bool OriginalLayerEdges::equals (const Edges &other) const { diff --git a/src/db/db/dbOriginalLayerEdges.h b/src/db/db/dbOriginalLayerEdges.h index 0284e935a..83dcf2c03 100644 --- a/src/db/db/dbOriginalLayerEdges.h +++ b/src/db/db/dbOriginalLayerEdges.h @@ -63,8 +63,6 @@ public: virtual const db::RecursiveShapeIterator *iter () const; virtual void apply_property_translator (const db::PropertiesTranslator &pt); - virtual db::PropertiesRepository *properties_repository (); - virtual const db::PropertiesRepository *properties_repository () const; virtual bool equals (const Edges &other) const; virtual bool less (const Edges &other) const; diff --git a/src/db/db/dbOriginalLayerRegion.cc b/src/db/db/dbOriginalLayerRegion.cc index a4c15e76c..72067d720 100644 --- a/src/db/db/dbOriginalLayerRegion.cc +++ b/src/db/db/dbOriginalLayerRegion.cc @@ -382,18 +382,6 @@ OriginalLayerRegion::apply_property_translator (const db::PropertiesTranslator & m_merged_polygons.clear (); } -db::PropertiesRepository * -OriginalLayerRegion::properties_repository () -{ - return m_iter.layout () ? &const_cast(m_iter.layout ())->properties_repository () : 0; -} - -const db::PropertiesRepository * -OriginalLayerRegion::properties_repository () const -{ - return m_iter.layout () ? &m_iter.layout ()->properties_repository () : 0; -} - bool OriginalLayerRegion::equals (const Region &other) const { @@ -445,18 +433,13 @@ OriginalLayerRegion::insert_into (Layout *layout, db::cell_index_type into_cell, db::Shapes &sh = layout->cell (into_cell).shapes (into_layer); - db::PropertyMapper pm; - if (m_iter.layout ()) { - pm = db::PropertyMapper (layout, m_iter.layout ()); - } - // NOTE: if the source (r) is from the same layout than the shapes live in, we better // lock the layout against updates while inserting db::LayoutLocker locker (layout); AssignProp ap; for (db::RecursiveShapeIterator i = m_iter; !i.at_end (); ++i) { db::properties_id_type prop_id = i.prop_id (); - ap.prop_id = (prop_id != 0 ? pm (prop_id) : 0); + ap.prop_id = (prop_id != 0 ? prop_id : 0); sh.insert (*i, i.trans (), ap); } } diff --git a/src/db/db/dbOriginalLayerRegion.h b/src/db/db/dbOriginalLayerRegion.h index 82a0fcd61..f2c850109 100644 --- a/src/db/db/dbOriginalLayerRegion.h +++ b/src/db/db/dbOriginalLayerRegion.h @@ -68,8 +68,6 @@ public: virtual const db::RecursiveShapeIterator *iter () const; virtual void apply_property_translator (const db::PropertiesTranslator &pt); - virtual db::PropertiesRepository *properties_repository (); - virtual const db::PropertiesRepository *properties_repository () const; virtual bool equals (const Region &other) const; virtual bool less (const Region &other) const; diff --git a/src/db/db/dbOriginalLayerTexts.cc b/src/db/db/dbOriginalLayerTexts.cc index b933c1440..0295a6431 100644 --- a/src/db/db/dbOriginalLayerTexts.cc +++ b/src/db/db/dbOriginalLayerTexts.cc @@ -208,18 +208,6 @@ OriginalLayerTexts::apply_property_translator (const db::PropertiesTranslator &p m_iter.apply_property_translator (pt); } -db::PropertiesRepository * -OriginalLayerTexts::properties_repository () -{ - return m_iter.layout () ? &const_cast(m_iter.layout ())->properties_repository () : 0; -} - -const db::PropertiesRepository * -OriginalLayerTexts::properties_repository () const -{ - return m_iter.layout () ? &m_iter.layout ()->properties_repository () : 0; -} - bool OriginalLayerTexts::equals (const Texts &other) const { diff --git a/src/db/db/dbOriginalLayerTexts.h b/src/db/db/dbOriginalLayerTexts.h index fb4935b70..3b491118e 100644 --- a/src/db/db/dbOriginalLayerTexts.h +++ b/src/db/db/dbOriginalLayerTexts.h @@ -57,8 +57,6 @@ public: virtual const db::RecursiveShapeIterator *iter () const; virtual void apply_property_translator (const db::PropertiesTranslator &pt); - virtual db::PropertiesRepository *properties_repository (); - virtual const db::PropertiesRepository *properties_repository () const; virtual bool equals (const Texts &other) const; virtual bool less (const Texts &other) const; diff --git a/src/db/db/dbPCellVariant.cc b/src/db/db/dbPCellVariant.cc index 7c83a612a..40954ab5a 100644 --- a/src/db/db/dbPCellVariant.cc +++ b/src/db/db/dbPCellVariant.cc @@ -156,8 +156,8 @@ PCellVariant::update (ImportLayerMapping *layer_mapping) PCellHeader *header = pcell_header (); if (header && header->declaration ()) { - db::property_names_id_type pn = layout ()->properties_repository ().prop_name_id (tl::Variant ("name")); - db::property_names_id_type dn = layout ()->properties_repository ().prop_name_id (tl::Variant ("description")); + tl::Variant pn ("name"); + tl::Variant dn ("description"); std::vector layer_ids; try { @@ -190,60 +190,60 @@ PCellVariant::update (ImportLayerMapping *layer_mapping) if (i < m_parameters.size () && p->get_type () == db::PCellParameterDeclaration::t_shape && ! p->is_hidden ()) { // use property with name "name" to indicate the parameter name - db::PropertiesRepository::properties_set props; - props.insert (std::make_pair (pn, tl::Variant (p->get_name ()))); + db::PropertiesSet props; + props.insert (pn, tl::Variant (p->get_name ())); if (! p->get_description ().empty ()) { - props.insert (std::make_pair (dn, tl::Variant (p->get_description ()))); + props.insert (dn, tl::Variant (p->get_description ())); } if (m_parameters[i].is_user ()) { - shapes (layout ()->guiding_shape_layer ()).insert (db::BoxWithProperties (db::Box (m_parameters[i].to_user () * (1.0 / layout ()->dbu ())), layout ()->properties_repository ().properties_id (props))); + shapes (layout ()->guiding_shape_layer ()).insert (db::BoxWithProperties (db::Box (m_parameters[i].to_user () * (1.0 / layout ()->dbu ())), db::properties_id (props))); } else if (m_parameters[i].is_user ()) { - shapes (layout ()->guiding_shape_layer ()).insert (db::BoxWithProperties (m_parameters[i].to_user (), layout ()->properties_repository ().properties_id (props))); + shapes (layout ()->guiding_shape_layer ()).insert (db::BoxWithProperties (m_parameters[i].to_user (), db::properties_id (props))); } else if (m_parameters[i].is_user ()) { - shapes (layout ()->guiding_shape_layer ()).insert (db::EdgeWithProperties (db::Edge (m_parameters[i].to_user () * (1.0 / layout ()->dbu ())), layout ()->properties_repository ().properties_id (props))); + shapes (layout ()->guiding_shape_layer ()).insert (db::EdgeWithProperties (db::Edge (m_parameters[i].to_user () * (1.0 / layout ()->dbu ())), db::properties_id (props))); } else if (m_parameters[i].is_user ()) { - shapes (layout ()->guiding_shape_layer ()).insert (db::EdgeWithProperties (m_parameters[i].to_user (), layout ()->properties_repository ().properties_id (props))); + shapes (layout ()->guiding_shape_layer ()).insert (db::EdgeWithProperties (m_parameters[i].to_user (), db::properties_id (props))); } else if (m_parameters[i].is_user ()) { db::DPoint p = m_parameters[i].to_user (); - shapes (layout ()->guiding_shape_layer ()).insert (db::PointWithProperties (db::Point (p * (1.0 / layout ()->dbu ())), layout ()->properties_repository ().properties_id (props))); + shapes (layout ()->guiding_shape_layer ()).insert (db::PointWithProperties (db::Point (p * (1.0 / layout ()->dbu ())), db::properties_id (props))); } else if (m_parameters[i].is_user ()) { db::Point p = m_parameters[i].to_user (); - shapes (layout ()->guiding_shape_layer ()).insert (db::PointWithProperties (p, layout ()->properties_repository ().properties_id (props))); + shapes (layout ()->guiding_shape_layer ()).insert (db::PointWithProperties (p, db::properties_id (props))); } else if (m_parameters[i].is_user ()) { db::complex_trans dbu_trans (1.0 / layout ()->dbu ()); db::Polygon poly = m_parameters[i].to_user ().transformed (dbu_trans, false); // Hint: we don't compress the polygon since we don't want to loose information - shapes (layout ()->guiding_shape_layer ()).insert (db::PolygonWithProperties (poly, layout ()->properties_repository ().properties_id (props))); + shapes (layout ()->guiding_shape_layer ()).insert (db::PolygonWithProperties (poly, db::properties_id (props))); } else if (m_parameters[i].is_user ()) { db::Polygon poly = m_parameters[i].to_user (); // Hint: we don't compress the polygon since we don't want to loose information - shapes (layout ()->guiding_shape_layer ()).insert (db::PolygonWithProperties (poly, layout ()->properties_repository ().properties_id (props))); + shapes (layout ()->guiding_shape_layer ()).insert (db::PolygonWithProperties (poly, db::properties_id (props))); } else if (m_parameters[i].is_user ()) { db::complex_trans dbu_trans (1.0 / layout ()->dbu ()); - shapes (layout ()->guiding_shape_layer ()).insert (db::PathWithProperties (dbu_trans * m_parameters[i].to_user (), layout ()->properties_repository ().properties_id (props))); + shapes (layout ()->guiding_shape_layer ()).insert (db::PathWithProperties (dbu_trans * m_parameters[i].to_user (), db::properties_id (props))); } else if (m_parameters[i].is_user ()) { - shapes (layout ()->guiding_shape_layer ()).insert (db::PathWithProperties (m_parameters[i].to_user (), layout ()->properties_repository ().properties_id (props))); + shapes (layout ()->guiding_shape_layer ()).insert (db::PathWithProperties (m_parameters[i].to_user (), db::properties_id (props))); } diff --git a/src/db/db/dbPropertiesRepository.cc b/src/db/db/dbPropertiesRepository.cc index 7bbdf2d74..11373b44e 100644 --- a/src/db/db/dbPropertiesRepository.cc +++ b/src/db/db/dbPropertiesRepository.cc @@ -30,33 +30,215 @@ namespace db { +// ---------------------------------------------------------------------------------- +// Static methods implementation + +const tl::Variant &property_name (db::property_names_id_type id) +{ + return *(reinterpret_cast (id)); +} + +db::property_names_id_type property_names_id (const tl::Variant &pn) +{ + return PropertiesRepository::instance ().prop_name_id (pn); +} + +const tl::Variant &property_value (db::property_values_id_type id) +{ + return *(reinterpret_cast (id)); +} + +db::property_values_id_type property_values_id (const tl::Variant &pv) +{ + return PropertiesRepository::instance ().prop_value_id (pv); +} + +const PropertiesSet &properties (db::properties_id_type id) +{ + return *(reinterpret_cast (id)); +} + +db::properties_id_type properties_id (const PropertiesSet &ps) +{ + return PropertiesRepository::instance ().properties_id (ps); +} + +// ---------------------------------------------------------------------------------- +// PropertiesSet implementation + +PropertiesSet::PropertiesSet () + : m_map () +{ + // .. nothing yet .. +} + +PropertiesSet::PropertiesSet (const PropertiesSet &other) + : m_map (other.m_map) +{ + // .. nothing yet .. +} + +PropertiesSet::PropertiesSet (const PropertiesSet &&other) + : m_map (std::move (other.m_map)) +{ + // .. nothing yet .. +} + +PropertiesSet & +PropertiesSet::operator= (const PropertiesSet &other) +{ + m_map = other.m_map; + return *this; +} + +PropertiesSet & +PropertiesSet::operator= (const PropertiesSet &&other) +{ + m_map = std::move (other.m_map); + return *this; +} + +bool +PropertiesSet::operator== (const PropertiesSet &other) const +{ + return m_map == other.m_map; +} + +bool +PropertiesSet::operator< (const PropertiesSet &other) const +{ + return m_map < other.m_map; +} + +bool +PropertiesSet::has_value (const tl::Variant &name) const +{ + db::property_names_id_type nid = db::property_names_id (name); + return m_map.find (nid) != m_map.end (); +} + +const tl::Variant & +PropertiesSet::value (const tl::Variant &name) const +{ + db::property_names_id_type nid = db::property_names_id (name); + auto i = m_map.find (nid); + if (i == m_map.end () || i->second != nid) { + static tl::Variant nil; + return nil; + } else { + return property_value (i->second); + } +} + +void +PropertiesSet::clear () +{ + m_map.clear (); +} + +void +PropertiesSet::erase (const tl::Variant &name) +{ + db::property_names_id_type nid = db::property_names_id (name); + auto i = m_map.find (nid); + while (i != m_map.end () && i->second == nid) { + m_map.erase (nid); + ++i; + } +} + +void +PropertiesSet::erase (db::property_names_id_type nid) +{ + auto i = m_map.find (nid); + while (i != m_map.end () && i->second == nid) { + m_map.erase (nid); + ++i; + } +} + +void +PropertiesSet::insert (const tl::Variant &name, const tl::Variant &value) +{ + m_map.insert (std::make_pair (db::property_names_id (name), db::property_values_id (value))); +} + +void +PropertiesSet::insert (db::property_names_id_type nid, const tl::Variant &value) +{ + m_map.insert (std::make_pair (nid, db::property_values_id (value))); +} + +std::multimap +PropertiesSet::to_map () const +{ + std::multimap result; + + for (auto i = m_map.begin (); i != m_map.end (); ++i) { + result.insert (std::make_pair (db::property_name (i->first), db::property_value (i->second))); + } + return result; +} + +tl::Variant +PropertiesSet::to_dict_var () const +{ + tl::Variant var = tl::Variant::empty_array (); + for (auto i = m_map.begin (); i != m_map.end (); ++i) { + var.insert (db::property_name (i->first), db::property_value (i->second)); + } + return var; +} + +tl::Variant +PropertiesSet::to_list_var () const +{ + tl::Variant var = tl::Variant::empty_list (); + for (auto i = m_map.begin (); i != m_map.end (); ++i) { + tl::Variant el = tl::Variant::empty_list (); + el.push (db::property_name (i->first)); + el.push (db::property_value (i->second)); + var.push (el); + } + return var; +} + +void +PropertiesSet::change_name (property_names_id_type from, property_names_id_type to) +{ + map_type org_map; + org_map.swap (m_map); + + for (auto i = org_map.begin (); i != org_map.end (); ++i) { + if (i->first == from) { + m_map.insert (std::make_pair (to, i->second)); + } else { + m_map.insert (*i); + } + } +} + +void +PropertiesSet::change_value (property_values_id_type from, property_values_id_type to) +{ + map_type org_map; + org_map.swap (m_map); + + for (auto i = org_map.begin (); i != org_map.end (); ++i) { + if (i->second == from) { + m_map.insert (std::make_pair (i->first, to)); + } else { + m_map.insert (*i); + } + } +} + // ---------------------------------------------------------------------------------- // PropertiesRepository implementation PropertiesRepository::PropertiesRepository () { - // install empty property set - properties_set empty_set; - properties_id_type id = properties_id (empty_set); - tl_assert (id == 0); -} - -PropertiesRepository::PropertiesRepository (const PropertiesRepository &d) -{ - operator= (d); -} - -PropertiesRepository & -PropertiesRepository::operator= (const PropertiesRepository &d) -{ - if (&d != this) { - m_propnames_by_id = d.m_propnames_by_id; - m_propname_ids_by_name = d.m_propname_ids_by_name; - m_properties_by_id = d.m_properties_by_id; - m_properties_ids_by_set = d.m_properties_ids_by_set; - m_properties_component_table = d.m_properties_component_table; - } - return *this; + // .. nothing yet .. } std::pair @@ -64,132 +246,138 @@ PropertiesRepository::get_id_of_name (const tl::Variant &name) const { tl::MutexLocker locker (&m_lock); - std::map ::const_iterator pi = m_propname_ids_by_name.find (name); - if (pi == m_propname_ids_by_name.end ()) { + std::set::const_iterator pi = m_propnames.find (&name); + if (pi == m_propnames.end ()) { return std::make_pair (false, property_names_id_type (0)); } else { - return std::make_pair (true, pi->second); + return std::make_pair (true, property_names_id_type (*pi)); } } -property_names_id_type +std::pair +PropertiesRepository::get_id_of_value (const tl::Variant &value) const +{ + tl::MutexLocker locker (&m_lock); + + std::set::const_iterator pi = m_propvalues.find (&value); + if (pi == m_propvalues.end ()) { + return std::make_pair (false, property_values_id_type (0)); + } else { + return std::make_pair (true, property_values_id_type (*pi)); + } +} + +property_names_id_type PropertiesRepository::prop_name_id (const tl::Variant &name) { tl::MutexLocker locker (&m_lock); - std::map ::const_iterator pi = m_propname_ids_by_name.find (name); - if (pi == m_propname_ids_by_name.end ()) { - property_names_id_type id = m_propnames_by_id.size (); - m_propnames_by_id.insert (std::make_pair (id, name)); - m_propname_ids_by_name.insert (std::make_pair (name, id)); - return id; + std::set::const_iterator pi = m_propnames.find (&name); + if (pi == m_propnames.end ()) { + m_property_names_heap.push_back (name); + const tl::Variant &new_name = m_property_names_heap.back (); + m_propnames.insert (&new_name); + return property_names_id_type (&new_name); } else { - return pi->second; + return property_names_id_type (*pi); } } -void -PropertiesRepository::change_properties (property_names_id_type id, const properties_set &new_props) +property_names_id_type +PropertiesRepository::prop_value_id (const tl::Variant &value) { - tl_assert (id != 0); + tl::MutexLocker locker (&m_lock); - // NOTE: change_properties MAY put the property map into a state where there is - // more than one property ID per set. For example, 1 and 5 may be valid property - // ids for the same set. "properties(1)" and "properties(5)" returns the same - // property set "S", while "properties_id(S)" only returns 1. - - const properties_set &old_props = properties (id); - - bool changed = false; - - { - tl::MutexLocker locker (&m_lock); - - std::map ::const_iterator pi = m_properties_ids_by_set.find (old_props); - if (pi != m_properties_ids_by_set.end ()) { - - // erase the id from the component table - for (properties_set::const_iterator nv = old_props.begin (); nv != old_props.end (); ++nv) { - if (m_properties_component_table.find (*nv) != m_properties_component_table.end ()) { - properties_id_vector &v = m_properties_component_table [*nv]; - for (size_t i = 0; i < v.size (); ) { - if (v[i] == id) { - v.erase (v.begin () + i); - } else { - ++i; - } - } - } - } - - // and insert again - m_properties_ids_by_set.erase (old_props); - m_properties_ids_by_set.insert (std::make_pair (new_props, id)); - - m_properties_by_id [id] = new_props; - - for (properties_set::const_iterator nv = new_props.begin (); nv != new_props.end (); ++nv) { - m_properties_component_table.insert (std::make_pair (*nv, properties_id_vector ())).first->second.push_back (id); - } - - changed = true; - } - - } - - if (changed) { - // signal the change of the properties ID's. This way for example, the layer views - // can recompute the property selectors - prop_ids_changed_event (); + std::set::const_iterator pi = m_propvalues.find (&value); + if (pi == m_propvalues.end ()) { + m_property_values_heap.push_back (value); + const tl::Variant &new_value = m_property_values_heap.back (); + m_propvalues.insert (&new_value); + return property_names_id_type (&new_value); + } else { + return property_names_id_type (*pi); } } -void + +void PropertiesRepository::change_name (property_names_id_type id, const tl::Variant &new_name) { - tl::MutexLocker locker (&m_lock); + db::property_names_id_type new_id = property_names_id (new_name); + if (new_id == id) { + return; + } - std::map ::iterator pi = m_propnames_by_id.find (id); - tl_assert (pi != m_propnames_by_id.end ()); - pi->second = new_name; + auto &new_pids = m_properties_by_name_table [new_id]; - m_propname_ids_by_name.insert (std::make_pair (new_name, id)); + auto pids = m_properties_by_name_table.find (id); + if (pids != m_properties_by_name_table.end ()) { + for (auto pid = pids->second.begin (); pid != pids->second.end (); ++pid) { + PropertiesSet *ps = reinterpret_cast (*pid); + m_properties.erase (ps); + ps->change_name (id, new_id); + m_properties.insert (ps); + new_pids.insert (*pid); + } + } + + m_properties_by_name_table.erase (id); } -const tl::Variant & -PropertiesRepository::prop_name (property_names_id_type id) const +void +PropertiesRepository::change_value (property_values_id_type id, const tl::Variant &new_value) { - tl::MutexLocker locker (&m_lock); - return m_propnames_by_id.find (id)->second; + db::property_values_id_type new_id = property_values_id (new_value); + if (new_id == id) { + return; + } + + auto &new_pids = m_properties_by_value_table [new_id]; + + auto pids = m_properties_by_value_table.find (id); + if (pids != m_properties_by_value_table.end ()) { + for (auto pid = pids->second.begin (); pid != pids->second.end (); ++pid) { + PropertiesSet *ps = reinterpret_cast (*pid); + m_properties.erase (ps); + ps->change_value (id, new_id); + m_properties.insert (ps); + new_pids.insert (*pid); + } + } + + m_properties_by_value_table.erase (id); } properties_id_type -PropertiesRepository::properties_id (const properties_set &props) +PropertiesRepository::properties_id (const PropertiesSet &props) { - properties_id_type result; + if (props.empty ()) { + return 0; + } + + properties_id_type pid; bool changed = false; { tl::MutexLocker locker (&m_lock); - std::map ::const_iterator pi = m_properties_ids_by_set.find (props); - if (pi == m_properties_ids_by_set.end ()) { + std::set ::const_iterator pi = m_properties.find (&props); + if (pi == m_properties.end ()) { - properties_id_type id = 0; - if (! m_properties_by_id.empty ()) { - id = (--m_properties_by_id.end ())->first + 1; - } - m_properties_ids_by_set.insert (std::make_pair (props, id)); - m_properties_by_id.insert (std::make_pair (id, props)); - for (properties_set::const_iterator nv = props.begin (); nv != props.end (); ++nv) { - m_properties_component_table.insert (std::make_pair (*nv, properties_id_vector ())).first->second.push_back (id); + m_properties_heap.push_back (props); + const PropertiesSet &new_props = m_properties_heap.back (); + m_properties.insert (&new_props); + + pid = db::properties_id_type (&new_props); + for (auto nv = props.begin (); nv != props.end (); ++nv) { + m_properties_by_name_table [nv->first].insert (pid); + m_properties_by_name_table [nv->second].insert (pid); } changed = true; - result = id; } else { - result = pi->second; + pid = db::properties_id (**pi); } } @@ -199,24 +387,7 @@ PropertiesRepository::properties_id (const properties_set &props) prop_ids_changed_event (); } - return result; -} - -const PropertiesRepository::properties_set & -PropertiesRepository::properties (properties_id_type id) const -{ - static PropertiesRepository::properties_set empty_set; - if (id == 0) { - return empty_set; - } - - tl::MutexLocker locker (&m_lock); - iterator p = m_properties_by_id.find (id); - if (p != m_properties_by_id.end ()) { - return p->second; - } else { - return empty_set; - } + return pid; } bool @@ -227,42 +398,86 @@ PropertiesRepository::is_valid_properties_id (properties_id_type id) const } tl::MutexLocker locker (&m_lock); - return m_properties_by_id.find (id) != m_properties_by_id.end (); + for (auto i = m_properties.begin (); i != m_properties.end (); ++i) { + if (properties_id_type (*i) == id) { + return true; + } + } + return false; } -const PropertiesRepository::properties_id_vector & -PropertiesRepository::properties_ids_by_name_value (const name_value_pair &nv) const +bool +PropertiesRepository::is_valid_property_names_id (property_names_id_type id) const +{ + tl::MutexLocker locker (&m_lock); + for (auto i = m_propnames.begin (); i != m_propnames.end (); ++i) { + if (property_names_id_type (*i) == id) { + return true; + } + } + return false; +} + +bool +PropertiesRepository::is_valid_property_values_id (property_values_id_type id) const +{ + tl::MutexLocker locker (&m_lock); + for (auto i = m_propvalues.begin (); i != m_propvalues.end (); ++i) { + if (property_names_id_type (*i) == id) { + return true; + } + } + return false; +} + +PropertiesRepository::properties_id_set +PropertiesRepository::properties_ids_by_name_value (db::property_names_id_type name, db::property_values_id_type value) const { tl::MutexLocker locker (&m_lock); - std::map ::const_iterator idv = m_properties_component_table.find (nv); - if (idv == m_properties_component_table.end ()) { - static properties_id_vector empty; - return empty; - } else { - return idv->second; + db::property_names_id_type name_id = property_names_id (name); + auto ni = m_properties_by_name_table.find (name_id); + if (ni == m_properties_by_name_table.end ()) { + return properties_id_set (); } + + db::property_values_id_type value_id = property_values_id (value); + auto vi = m_properties_by_value_table.find (value_id); + if (vi == m_properties_by_value_table.end ()) { + return properties_id_set (); + } + + properties_id_set result; + std::set_intersection (vi->second.begin (), vi->second.end (), ni->second.begin (), ni->second.end (), std::inserter (result, result.begin ())); + return result; } -// @@@ should not be needed at all -properties_id_type -PropertiesRepository::translate (const PropertiesRepository &rep, properties_id_type id) +properties_id_type +PropertiesRepository::allocate_properties () { - if (id == 0) { - return id; - } + tl::MutexLocker locker (&m_lock); - const properties_set &pset = rep.properties (id); - - // create a new set by mapping the names - properties_set new_pset; - for (properties_set::const_iterator pp = pset.begin (); pp != pset.end (); ++pp) { - new_pset.insert (std::make_pair (prop_name_id (rep.prop_name (pp->first)), pp->second)); - } - - return properties_id (new_pset); + m_properties_heap.push_back (PropertiesSet ()); + return db::properties_id_type (& m_properties_heap.back ()); } +property_names_id_type +PropertiesRepository::allocate_property_names_id () +{ + tl::MutexLocker locker (&m_lock); + + m_property_names_heap.push_back (tl::Variant ()); + return db::property_names_id_type (& m_property_names_heap.back ()); +} + +property_names_id_type +PropertiesRepository::allocate_property_values_id () +{ + tl::MutexLocker locker (&m_lock); + + m_property_values_heap.push_back (tl::Variant ()); + return db::property_values_id_type (& m_property_values_heap.back ()); +} // ---------------------------------------------------------------------------------- // PropertiesRepository implementation @@ -338,11 +553,12 @@ PropertiesTranslator::make_pass_all () } PropertiesTranslator -PropertiesTranslator::make_filter (db::PropertiesRepository &repo, const std::set &keys) +PropertiesTranslator::make_filter (const std::set &keys) { std::map map; std::set names_selected; +#if 0 // @@@ later for (auto k = keys.begin (); k != keys.end (); ++k) { names_selected.insert (repo.prop_name_id (*k)); } @@ -360,16 +576,18 @@ PropertiesTranslator::make_filter (db::PropertiesRepository &repo, const std::se map.insert (std::make_pair (p->first, repo.properties_id (new_set))); } } +#endif // @@@ return PropertiesTranslator (map); } PropertiesTranslator -PropertiesTranslator::make_key_mapper (db::PropertiesRepository &repo, const std::map &keys) +PropertiesTranslator::make_key_mapper (const std::map &keys) { std::map map; std::map name_map; +#if 0 // @@@ later for (auto k = keys.begin (); k != keys.end (); ++k) { name_map.insert (std::make_pair (repo.prop_name_id (k->first), repo.prop_name_id (k->second))); } @@ -388,6 +606,7 @@ PropertiesTranslator::make_key_mapper (db::PropertiesRepository &repo, const std map.insert (std::make_pair (p->first, repo.properties_id (new_set))); } } +#endif return PropertiesTranslator (map); } diff --git a/src/db/db/dbPropertiesRepository.h b/src/db/db/dbPropertiesRepository.h index 50111f986..06d5fa6e2 100644 --- a/src/db/db/dbPropertiesRepository.h +++ b/src/db/db/dbPropertiesRepository.h @@ -39,7 +39,190 @@ namespace db { -class LayoutStateModel; +/** + * @brief Gets a name entry from the property name ID + */ +const tl::Variant &property_name (db::property_names_id_type id); + +/** + * @brief Gets the property name ID from a property name + */ +db::property_names_id_type property_names_id (const tl::Variant &pn); + +/** + * @brief Gets a value entry from the property value ID + */ +const tl::Variant &property_value (db::property_values_id_type id); + +/** + * @brief Gets the property value ID from a property value + */ +db::property_values_id_type property_values_id (const tl::Variant &pv); + + +/** + * @brief A properties set + * + * The properties set is + */ + +class DB_PUBLIC PropertiesSet +{ +public: + typedef std::multimap map_type; + typedef map_type::const_iterator iterator; + + /** + * @brief The default constructor + * + * This will create an empty properties set. + */ + PropertiesSet (); + + /** + * @brief Copy constructor + */ + PropertiesSet (const PropertiesSet &other); + + /** + * @brief Move constructor + */ + PropertiesSet (const PropertiesSet &&other); + + /** + * @brief Assignment + */ + PropertiesSet &operator= (const PropertiesSet &other); + + /** + * @brief Move assignment + */ + PropertiesSet &operator= (const PropertiesSet &&other); + + /** + * @brief Equality + */ + bool operator== (const PropertiesSet &other) const; + + /** + * @brief Inequality + */ + bool operator!= (const PropertiesSet &other) const + { + return ! operator== (other); + } + + /** + * @brief Less operator + */ + bool operator< (const PropertiesSet &other) const; + + /** + * @brief Gets a value indicating whether the properties set is empty + */ + bool empty () const + { + return m_map.empty (); + } + + /** + * @brief Gets a value indicating whether the given name is contained in the set + */ + bool has_value (const tl::Variant &name) const; + + /** + * @brief Gets the value for the given name or a nil variant if there is no value for this name + */ + const tl::Variant &value (const tl::Variant &name) const; + + /** + * @brief operator[] as alias for "value" + */ + const tl::Variant &operator[] (const tl::Variant &name) const + { + return value (name); + } + + /** + * @brief Clears the properties set + */ + void clear (); + + /** + * @brief Deletes a value for the given name + */ + void erase (const tl::Variant &name); + + /** + * @brief Deletes a value for the given name + */ + void erase (db::property_names_id_type name_id); + + /** + * @brief Inserts a value for the given name + */ + void insert (const tl::Variant &name, const tl::Variant &value); + + /** + * @brief Inserts a value for the given name ID + */ + void insert (db::property_names_id_type name_id, const tl::Variant &value); + + /** + * @brief Gets the properties as a map + */ + std::multimap to_map () const; + + /** + * @brief Gets the properties as a dict variant + */ + tl::Variant to_dict_var () const; + + /** + * @brief Gets the properties as an array of pairs + * + * In contrast to the dict version, this variant allows delivery of + * property set with multiple values for the same name. + */ + tl::Variant to_list_var () const; + + /** + * @brief Iterator (begin) + * + * This iterator delivers key/value pairs in the ID form. + * The order is basically undefined. + */ + iterator begin () const + { + return m_map.begin (); + } + + /** + * @brief Iterator (end) + */ + iterator end () const + { + return m_map.end (); + } + +private: + map_type m_map; + + friend class PropertiesRepository; + + void change_name (property_names_id_type from, property_names_id_type to); + void change_value (property_values_id_type from, property_values_id_type to); +}; + +/** + * @brief Gets the properties set from a properties set ID + */ +const PropertiesSet &properties (db::properties_id_type id); + +/** + * @brief Gets the properties ID from a properties set + */ +db::properties_id_type properties_id (const PropertiesSet &ps); /** * @brief The properties repository @@ -53,76 +236,73 @@ class LayoutStateModel; class DB_PUBLIC PropertiesRepository { public: - typedef std::multimap properties_set; - typedef std::map properties_map; - typedef std::map ::const_iterator iterator; - typedef std::map ::iterator non_const_iterator; - typedef std::pair name_value_pair; - typedef std::vector properties_id_vector; + typedef std::set properties_id_set; /** - * @brief Default constructor + * @brief Gets the singleton instance of the properties repository */ - PropertiesRepository (); + static PropertiesRepository &instance (); /** - * @brief Copy constructor - */ - PropertiesRepository (const PropertiesRepository &d); - - /** - * @brief Assignment - */ - PropertiesRepository &operator= (const PropertiesRepository &d); - - /** - * @brief Associate a name with a name Id + * @brief Gets the name ID for a property name * - * A name of a property can be either a integer or a string as specified - * with the tl::Variant variant. In principle it could even be a list or void. - * This method will assign a new Id to the given name if required and - * return the Id associated with it. + * This method will assign a new ID to the given name if required and + * return the ID associated with it. */ property_names_id_type prop_name_id (const tl::Variant &name); /** - * @brief Change the name associated with a given name Id to another name + * @brief Gets the value ID for a property value + * + * This method will assign a new ID to the given value if required and + * return the ID associated with it. + */ + property_names_id_type prop_value_id (const tl::Variant &name); + + /** + * @brief Change the name associated with a given name ID to another name * - * All properties with the given name Id will get the new name. This method is + * All properties with the given name ID will get the new name. This method is * particular useful for the OASIS reader, which may associate a name with an Id - * at a late stage. The new name must not be associated with an Id already. - * The old name will stay associated with the Id. + * at a late stage. The ID must have been obtained by "allocate_name". + * + * This method will change the definition of property sets. The ID of the + * sets will stay the same. Basically this can lead to a situation where + * identical property sets have different IDs. In other words, ID identity + * is a guarantee for property set identity, but different IDs do not + * mean different property sets. + * + * The original ID is still valid, but not associated with the new name. */ void change_name (property_names_id_type id, const tl::Variant &new_name); /** - * @brief Change the properties for a given Id - * - * This method will change the properties for a given Id. The properties - * set for Id 0 cannot be changed. + * @brief Change the name associated with a given name Id to another name * - * This method is intended for special applications, i.e. the OASIS reader - * in forware references mode. + * See "change_name" for more details. This method will change the definition + * of the value behind ID to the new value. The ID must have been obtained + * through "allocate_value". */ - void change_properties (properties_id_type id, const properties_set &new_props); + void change_value (property_values_id_type id, const tl::Variant &new_value); /** - * @brief Get the id for a name + * @brief Get the ID for a name * * This method checks whether the given name is present as a name and returns the - * id in the second member of the pair. The first member is true, if the name is + * ID in the second member of the pair. The first member is true, if the name is * present. */ std::pair get_id_of_name (const tl::Variant &name) const; /** - * @brief Associate a name with a name Id - * - * This method will return the name associated with the given Id. - * It will assert if the Id is not a valid one. + * @brief Get the ID for a value + * + * This method checks whether the given name is present as a name and returns the + * ID in the second member of the pair. The first member is true, if the name is + * present. */ - const tl::Variant &prop_name (property_names_id_type id) const; - + std::pair get_id_of_value (const tl::Variant &value) const; + /** * @brief Associate a properties set with a properties Id * @@ -130,7 +310,7 @@ public: * return the Id associated with it. * An empty property set is associated with property Id 0. */ - properties_id_type properties_id (const properties_set &props); + properties_id_type properties_id (const PropertiesSet &props); /** * @brief Associate a properties set with a properties Id @@ -138,61 +318,56 @@ public: * This method will return the properties set associated with the given Id. * Id 0 always delivers an empty property set. */ - const properties_set &properties (properties_id_type id) const; + const PropertiesSet &properties (properties_id_type id) const; /** - * @brief Determine if the given Id is a valid one + * @brief Determine if the given ID is a valid properties ID + * + * Caution: this operation is slow! */ bool is_valid_properties_id (properties_id_type id) const; /** - * @brief Iterate over Id/Properties sets (non-const) + * @brief Determine if the given ID is a valid name ID + * + * Caution: this operation is slow! */ - non_const_iterator begin_non_const () - { - return m_properties_by_id.begin (); - } + bool is_valid_property_names_id (property_names_id_type id) const; /** - * @brief Iterate over Id/Properties sets: end iterator (non-const) + * @brief Determine if the given ID is a valid value ID + * + * Caution: this operation is slow! */ - non_const_iterator end_non_const () - { - return m_properties_by_id.end (); - } + bool is_valid_property_values_id (property_values_id_type id) const; /** - * @brief Iterate over Id/Properties sets + * @brief Allocates a new properties ID + * + * This method is intended for filling the properties later, i.e. with "change_properties". + * Only after using "change_properties", the properties ID will be found when + * looking it up. */ - iterator begin () const - { - return m_properties_by_id.begin (); - } + properties_id_type allocate_properties (); /** - * @brief Iterate over Id/Properties sets: end iterator + * @brief Allocates a new properties name ID + * + * This method is intended for filling the properties later, i.e. with "change_name". + * Only after using "change_name", a property names ID will be found when + * looking up the name. */ - iterator end () const - { - return m_properties_by_id.end (); - } + property_names_id_type allocate_property_names_id (); /** - * @brief Obtain the first properties id in the repository + * @brief Allocates a new properties value ID + * + * This method is intended for filling the properties later, i.e. with "change_value". + * Only after using "change_value", the property value ID will be found when + * looking up the value. */ - properties_id_type begin_id () - { - return 0; - } - - /** - * @brief Obtain the last properties id in the repository plus 1 - */ - properties_id_type end_id () - { - return m_properties_by_id.size (); - } - + property_names_id_type allocate_property_values_id (); + /** * @brief Lookup a table of properties id's by a name value pair * @@ -200,19 +375,7 @@ public: * of property sets that contain the given name/value pair. This method * is intended for use with the properties_id resolution algorithm. */ - const properties_id_vector &properties_ids_by_name_value (const name_value_pair &nv) const; - - /** - * @brief Translate a properties id from one repository to this one - * - * Take the given properties set from one repository and map it to this one. - * Inserts the properties set into this repository if necessary. - * - * @param rep The source repository - * @param id The source properties id - * @return id The id in *this - */ - properties_id_type translate (const PropertiesRepository &rep, properties_id_type id); + properties_id_set properties_ids_by_name_value (db::property_names_id_type name, db::property_values_id_type value) const; /** * @brief Collect memory statistics @@ -223,27 +386,56 @@ public: stat->add (typeid (*this), (void *) this, sizeof (*this), sizeof (*this), parent, purpose, cat); } - db::mem_stat (stat, purpose, cat, m_propnames_by_id, true, parent); - db::mem_stat (stat, purpose, cat, m_propname_ids_by_name, true, parent); - db::mem_stat (stat, purpose, cat, m_properties_by_id, true, parent); - db::mem_stat (stat, purpose, cat, m_properties_ids_by_set, true, parent); - db::mem_stat (stat, purpose, cat, m_properties_component_table, true, parent); + db::mem_stat (stat, purpose, cat, m_propnames, true, parent); + db::mem_stat (stat, purpose, cat, m_property_names_heap, true, parent); + db::mem_stat (stat, purpose, cat, m_propvalues, true, parent); + db::mem_stat (stat, purpose, cat, m_property_values_heap, true, parent); + db::mem_stat (stat, purpose, cat, m_properties, true, parent); + db::mem_stat (stat, purpose, cat, m_properties_heap, true, parent); + db::mem_stat (stat, purpose, cat, m_properties_by_name_table, true, parent); + db::mem_stat (stat, purpose, cat, m_properties_by_value_table, true, parent); } /** * @brief An event indicating a change in the properties IDs + * + * @@@ That is too global! Should be an event when a prop_id is changed on a Shape etc. */ tl::Event prop_ids_changed_event; private: - std::map m_propnames_by_id; - std::map m_propname_ids_by_name; + struct CompareNamePtrByValue + { + bool operator() (const tl::Variant *a, const tl::Variant *b) const + { + return *a < *b; + } + }; - std::map m_properties_by_id; - std::map m_properties_ids_by_set; - std::map m_properties_component_table; + struct ComparePropertiesPtrByValue + { + bool operator() (const PropertiesSet *a, const PropertiesSet *b) const + { + return *a < *b; + } + }; + + std::set m_propnames; + std::list m_property_names_heap; + std::set m_propvalues; + std::list m_property_values_heap; + std::set m_properties; + std::list m_properties_heap; + + std::map m_properties_by_name_table; + std::map m_properties_by_value_table; mutable tl::Mutex m_lock; + + /** + * @brief Default constructor + */ + PropertiesRepository (); }; /** @@ -342,7 +534,7 @@ public: * * The translator delivered by this function will leave only the given keys in the properties. */ - static PropertiesTranslator make_filter (db::PropertiesRepository &repo, const std::set &keys); + static PropertiesTranslator make_filter (const std::set &keys); /** * @brief Factory: create a key mapper translator @@ -350,7 +542,7 @@ public: * The translator delivered by this function will translate the given keys to new ones * and remove non-listed keys. */ - static PropertiesTranslator make_key_mapper (db::PropertiesRepository &repo, const std::map &keys); + static PropertiesTranslator make_key_mapper (const std::map &keys); private: std::map m_map; diff --git a/src/db/db/dbRegion.cc b/src/db/db/dbRegion.cc index a8294dffa..82c69f928 100644 --- a/src/db/db/dbRegion.cc +++ b/src/db/db/dbRegion.cc @@ -459,7 +459,7 @@ static void fill_texts (const Iter &iter, const std::string &pat, bool pattern, layout = &org_deep->deep_layer ().layout (); const db::DeepShapeStore *store = org_deep->deep_layer ().store (); if (! store->text_property_name ().is_nil ()) { - text_annot_name_id = layout->properties_repository ().get_id_of_name (store->text_property_name ()); + text_annot_name_id = db::PropertiesRepository::instance ().get_id_of_name (store->text_property_name ()); } } @@ -487,11 +487,11 @@ static void fill_texts (const Iter &iter, const std::string &pat, bool pattern, } else if (layout && text_annot_name_id.first && si->prop_id () > 0) { // a text marker - const db::PropertiesRepository::properties_set &ps = layout->properties_repository ().properties (si->prop_id ()); + const db::PropertiesSet &ps = db::properties (si->prop_id ()); - for (db::PropertiesRepository::properties_set::const_iterator j = ps.begin (); j != ps.end () && ! is_text; ++j) { + for (db::PropertiesSet::iterator j = ps.begin (); j != ps.end () && ! is_text; ++j) { if (j->first == text_annot_name_id.second) { - text_string = j->second.to_string (); + text_string = db::property_value (j->second).to_string (); is_text = true; } } @@ -518,7 +518,7 @@ public: mp_layout = & org_deep->deep_layer ().layout (); const db::DeepShapeStore *store = org_deep->deep_layer ().store (); if (! store->text_property_name ().is_nil ()) { - m_text_annot_name_id = mp_layout->properties_repository ().get_id_of_name (store->text_property_name ()); + m_text_annot_name_id = db::PropertiesRepository::instance ().get_id_of_name (store->text_property_name ()); } } @@ -545,11 +545,11 @@ public: } else if (mp_layout && m_text_annot_name_id.first && shape.prop_id () > 0) { // a text marker - const db::PropertiesRepository::properties_set &ps = mp_layout->properties_repository ().properties (shape.prop_id ()); + const db::PropertiesSet &ps = db::properties (shape.prop_id ()); - for (db::PropertiesRepository::properties_set::const_iterator j = ps.begin (); j != ps.end () && ! is_text; ++j) { + for (db::PropertiesSet::iterator j = ps.begin (); j != ps.end () && ! is_text; ++j) { if (j->first == m_text_annot_name_id.second) { - text_string = j->second.to_string (); + text_string = db::property_value (j->second).to_string (); is_text = true; } } diff --git a/src/db/db/dbRegionDelegate.h b/src/db/db/dbRegionDelegate.h index 7bbc64c9d..c26e7e989 100644 --- a/src/db/db/dbRegionDelegate.h +++ b/src/db/db/dbRegionDelegate.h @@ -274,8 +274,6 @@ public: virtual const db::RecursiveShapeIterator *iter () const = 0; virtual void apply_property_translator (const db::PropertiesTranslator &pt) = 0; - virtual db::PropertiesRepository *properties_repository () = 0; - virtual const db::PropertiesRepository *properties_repository () const = 0; virtual bool equals (const Region &other) const = 0; virtual bool less (const Region &other) const = 0; diff --git a/src/db/db/dbRegionLocalOperations.cc b/src/db/db/dbRegionLocalOperations.cc index 291f78ecb..aa3149c12 100644 --- a/src/db/db/dbRegionLocalOperations.cc +++ b/src/db/db/dbRegionLocalOperations.cc @@ -748,8 +748,8 @@ template class DB_PUBLIC check_local_operation; // --------------------------------------------------------------------------------------------------------------- template -check_local_operation_with_properties::check_local_operation_with_properties (const EdgeRelationFilter &check, bool different_polygons, bool is_merged, bool has_other, bool other_is_merged, const db::RegionCheckOptions &options, db::PropertiesRepository *target_pr, const db::PropertiesRepository *subject_pr, const db::PropertiesRepository *intruder_pr) - : check_local_operation_base (check, different_polygons, is_merged, has_other, other_is_merged, options), m_pms (target_pr, subject_pr), m_pmi (target_pr, intruder_pr) +check_local_operation_with_properties::check_local_operation_with_properties (const EdgeRelationFilter &check, bool different_polygons, bool is_merged, bool has_other, bool other_is_merged, const db::RegionCheckOptions &options) + : check_local_operation_base (check, different_polygons, is_merged, has_other, other_is_merged, options) { // .. nothing yet .. } @@ -760,7 +760,7 @@ check_local_operation_with_properties::do_compute_local (db::Layout *lay { tl_assert (results.size () == 1); - auto by_prop_id = separate_interactions_by_properties (interactions, check_local_operation_base::m_options.prop_constraint, m_pms, m_pmi); + auto by_prop_id = separate_interactions_by_properties (interactions, check_local_operation_base::m_options.prop_constraint); for (auto s2p = by_prop_id.begin (); s2p != by_prop_id.end (); ++s2p) { @@ -1622,8 +1622,8 @@ template class DB_PUBLIC bool_and_or_not_local_operation -bool_and_or_not_local_operation_with_properties::bool_and_or_not_local_operation_with_properties (bool is_and, db::PropertiesRepository *target_pr, const db::PropertiesRepository *subject_pr, const db::PropertiesRepository *intruder_pr, db::PropertyConstraint property_constraint) - : m_is_and (is_and), m_property_constraint (property_constraint), m_pms (target_pr, subject_pr), m_pmi (target_pr, intruder_pr) +bool_and_or_not_local_operation_with_properties::bool_and_or_not_local_operation_with_properties (bool is_and, db::PropertyConstraint property_constraint) + : m_is_and (is_and), m_property_constraint (property_constraint) { // .. nothing yet .. } @@ -1660,19 +1660,19 @@ bool_and_or_not_local_operation_with_properties::do_compute_local (d if (i->second.empty ()) { if (! m_is_and) { - result.insert (db::object_with_properties (subject, m_pms (subject.properties_id ()))); + result.insert (db::object_with_properties (subject, subject.properties_id ())); } } else { - db::properties_id_type prop_id_s = m_pms (subject.properties_id ()); + db::properties_id_type prop_id_s = subject.properties_id (); auto &shapes_by_prop = by_prop_id [prop_id_s]; shapes_by_prop.first.push_front (subject); for (auto j = i->second.begin (); j != i->second.end (); ++j) { const db::object_with_properties &intruder = interactions.intruder_shape (*j).second; - if (pc_match (m_property_constraint, prop_id_s, m_pmi (intruder.properties_id ()))) { + if (pc_match (m_property_constraint, prop_id_s, intruder.properties_id ())) { shapes_by_prop.second.insert (intruder); } } @@ -1824,9 +1824,9 @@ template class DB_PUBLIC two_bool_and_not_local_operation -two_bool_and_not_local_operation_with_properties::two_bool_and_not_local_operation_with_properties (db::PropertiesRepository *target1_pr, db::PropertiesRepository *target2_pr, const db::PropertiesRepository *subject_pr, const db::PropertiesRepository *intruder_pr, db::PropertyConstraint property_constraint) +two_bool_and_not_local_operation_with_properties::two_bool_and_not_local_operation_with_properties (db::PropertyConstraint property_constraint) : db::local_operation, db::object_with_properties, db::object_with_properties > (), - m_property_constraint (property_constraint), m_pms (target1_pr, subject_pr), m_pmi (target1_pr, intruder_pr), m_pm12 (target2_pr, target1_pr) + m_property_constraint (property_constraint) { // .. nothing yet .. } @@ -1849,18 +1849,18 @@ two_bool_and_not_local_operation_with_properties::do_compute_local ( if (i->second.empty ()) { - result1.insert (db::object_with_properties (subject, m_pms (subject.properties_id ()))); + result1.insert (db::object_with_properties (subject, subject.properties_id ())); } else { - db::properties_id_type prop_id_s = m_pms (subject.properties_id ()); + db::properties_id_type prop_id_s = subject.properties_id (); auto &shapes_by_prop = by_prop_id [prop_id_s]; shapes_by_prop.first.push_front (subject); for (auto j = i->second.begin (); j != i->second.end (); ++j) { const db::object_with_properties &intruder = interactions.intruder_shape (*j).second; - if (pc_match (m_property_constraint, prop_id_s, m_pmi (intruder.properties_id ()))) { + if (pc_match (m_property_constraint, prop_id_s, intruder.properties_id ())) { shapes_by_prop.second.insert (intruder); } } @@ -1884,7 +1884,7 @@ two_bool_and_not_local_operation_with_properties::do_compute_local ( result0.insert (db::object_with_properties (subject, prop_id)); } else if (others.empty ()) { // shortcut (not: keep, and: drop) - result1.insert (db::object_with_properties (subject, m_pm12 (prop_id))); + result1.insert (db::object_with_properties (subject, prop_id)); } else { for (auto e = subject.begin_edge (); ! e.at_end(); ++e) { ep.insert (*e, p1); @@ -1927,7 +1927,7 @@ two_bool_and_not_local_operation_with_properties::do_compute_local ( result0.insert (db::object_with_properties (*r, prop_id)); } for (auto r = result1_wo_props.begin (); r != result1_wo_props.end (); ++r) { - result1.insert (db::object_with_properties (*r, m_pm12 (prop_id))); + result1.insert (db::object_with_properties (*r, prop_id)); } } @@ -2171,8 +2171,8 @@ std::string SelfOverlapMergeLocalOperation::description () const // --------------------------------------------------------------------------------------------- -PolygonToEdgeLocalOperation::PolygonToEdgeLocalOperation (db::PropertiesRepository *target_pr, const db::PropertiesRepository *source_pr) - : local_operation (), m_pm (target_pr, source_pr) +PolygonToEdgeLocalOperation::PolygonToEdgeLocalOperation () + : local_operation () { // .. nothing yet .. } @@ -2189,7 +2189,7 @@ PolygonToEdgeLocalOperation::do_compute_local (db::Layout * /*layout*/, db::Cell db::EdgeProcessor ep; ep.set_base_verbosity (50); - auto by_prop_id = separate_interactions_by_properties (interactions, db::SamePropertiesConstraint, m_pm, m_pm); + auto by_prop_id = separate_interactions_by_properties (interactions, db::SamePropertiesConstraint); for (auto shapes_by_prop_id = by_prop_id.begin (); shapes_by_prop_id != by_prop_id.end (); ++shapes_by_prop_id) { db::properties_id_type prop_id = shapes_by_prop_id->first; diff --git a/src/db/db/dbRegionLocalOperations.h b/src/db/db/dbRegionLocalOperations.h index ba8129696..a1fd65f31 100644 --- a/src/db/db/dbRegionLocalOperations.h +++ b/src/db/db/dbRegionLocalOperations.h @@ -224,7 +224,7 @@ class check_local_operation_with_properties : public local_operation, db::object_with_properties, db::EdgePairWithProperties>, public check_local_operation_base { public: - check_local_operation_with_properties (const EdgeRelationFilter &check, bool different_polygons, bool is_merged, bool has_other, bool other_is_merged, const db::RegionCheckOptions &options, db::PropertiesRepository *target_pr, const db::PropertiesRepository *subject_pr, const db::PropertiesRepository *intruder_pr); + check_local_operation_with_properties (const EdgeRelationFilter &check, bool different_polygons, bool is_merged, bool has_other, bool other_is_merged, const db::RegionCheckOptions &options); virtual db::Coord dist () const; virtual OnEmptyIntruderHint on_empty_intruder_hint () const; @@ -236,7 +236,6 @@ public: virtual const db::TransformationReducer *vars () const { return &m_vars; } private: - mutable db::PropertyMapper m_pms, m_pmi; db::MagnificationReducer m_vars; }; @@ -405,7 +404,7 @@ class DB_PUBLIC bool_and_or_not_local_operation_with_properties : public local_operation, db::object_with_properties, db::object_with_properties > { public: - bool_and_or_not_local_operation_with_properties (bool is_and, db::PropertiesRepository *target_pr, const db::PropertiesRepository *subject_pr, const db::PropertiesRepository *intruder_pr, db::PropertyConstraint property_constraint); + bool_and_or_not_local_operation_with_properties (bool is_and, db::PropertyConstraint property_constraint); virtual void do_compute_local (db::Layout *layout, db::Cell *subject_cell, const shape_interactions, db::object_with_properties > &interactions, std::vector > > &result, const db::LocalProcessorBase *proc) const; virtual OnEmptyIntruderHint on_empty_intruder_hint () const; @@ -414,8 +413,6 @@ public: private: bool m_is_and; db::PropertyConstraint m_property_constraint; - mutable db::PropertyMapper m_pms; - mutable db::PropertyMapper m_pmi; }; typedef bool_and_or_not_local_operation_with_properties BoolAndOrNotLocalOperationWithProperties; @@ -451,14 +448,13 @@ class DB_PUBLIC two_bool_and_not_local_operation_with_properties : public local_operation, db::object_with_properties, db::object_with_properties > { public: - two_bool_and_not_local_operation_with_properties (db::PropertiesRepository *target1_pr, db::PropertiesRepository *target2_pr, const db::PropertiesRepository *subject_pr, const db::PropertiesRepository *intruder_pr, db::PropertyConstraint property_constraint); + two_bool_and_not_local_operation_with_properties (db::PropertyConstraint property_constraint); virtual void do_compute_local (db::Layout *layout, db::Cell *subject_cell, const shape_interactions, db::object_with_properties > &interactions, std::vector > > &result, const db::LocalProcessorBase *proc) const; virtual std::string description () const; private: db::PropertyConstraint m_property_constraint; - mutable db::PropertyMapper m_pms, m_pmi, m_pm12; }; typedef two_bool_and_not_local_operation_with_properties TwoBoolAndNotLocalOperationWithProperties; @@ -521,16 +517,13 @@ class DB_PUBLIC PolygonToEdgeLocalOperation : public local_operation { public: - PolygonToEdgeLocalOperation (db::PropertiesRepository *target_pr, const db::PropertiesRepository *source_pr); + PolygonToEdgeLocalOperation (); virtual db::Coord dist () const { return 1; } virtual bool requests_single_subjects () const { return true; } virtual std::string description () const; virtual void do_compute_local (db::Layout *layout, db::Cell *subject_cell, const shape_interactions &interactions, std::vector > &results, const db::LocalProcessorBase *proc) const; - -private: - mutable db::PropertyMapper m_pm; }; } // namespace db diff --git a/src/db/db/dbShape.cc b/src/db/db/dbShape.cc index 648221066..3b13d865f 100644 --- a/src/db/db/dbShape.cc +++ b/src/db/db/dbShape.cc @@ -967,7 +967,8 @@ Shape::to_string () const } if (has_prop_id ()) { - r += " prop_id=" + tl::to_string (prop_id ()); + r += " props="; + r += db::properties (prop_id ()).to_dict_var ().to_string (); } return r; diff --git a/src/db/db/dbShapeCollection.cc b/src/db/db/dbShapeCollection.cc index d0591f9d3..18126850e 100644 --- a/src/db/db/dbShapeCollection.cc +++ b/src/db/db/dbShapeCollection.cc @@ -72,28 +72,6 @@ DeepShapeCollectionDelegateBase::apply_property_translator (const db::Properties // ------------------------------------------------------------------------------------------------------------- // ShapeCollection implementation -const db::PropertiesRepository & -ShapeCollection::properties_repository () const -{ - static db::PropertiesRepository empty_prop_repo; - const db::PropertiesRepository *r = get_delegate () ? get_delegate ()->properties_repository () : 0; - return *(r ? r : &empty_prop_repo); -} - -db::PropertiesRepository & -ShapeCollection::properties_repository () -{ - db::PropertiesRepository *r = get_delegate () ? get_delegate ()->properties_repository () : 0; - tl_assert (r != 0); - return *r; -} - -bool -ShapeCollection::has_properties_repository () const -{ - return get_delegate () && get_delegate ()->properties_repository (); -} - void ShapeCollection::apply_property_translator (const db::PropertiesTranslator &pt) { diff --git a/src/db/db/dbShapeCollection.h b/src/db/db/dbShapeCollection.h index 43493efa7..db7d938bf 100644 --- a/src/db/db/dbShapeCollection.h +++ b/src/db/db/dbShapeCollection.h @@ -81,8 +81,6 @@ public: virtual DeepShapeCollectionDelegateBase *deep () { return 0; } virtual void apply_property_translator (const db::PropertiesTranslator & /*pt*/) = 0; - virtual db::PropertiesRepository *properties_repository () = 0; - virtual const db::PropertiesRepository *properties_repository () const = 0; void remove_properties (bool remove = true) { @@ -113,25 +111,6 @@ public: * delivered by "properties_repository". */ void apply_property_translator (const db::PropertiesTranslator &pt); - - /** - * @brief Gets the property repository - * - * Use this object to decode and encode property IDs. - */ - db::PropertiesRepository &properties_repository (); - - /** - * @brief Gets the property repository (const version) - * - * Use this object to decode property IDs. - */ - const db::PropertiesRepository &properties_repository () const; - - /** - * @brief Gets a value indicating whether a properties repository is available - */ - bool has_properties_repository () const; }; } diff --git a/src/db/db/dbShapes.h b/src/db/db/dbShapes.h index c331a3f64..0b95e1da3 100644 --- a/src/db/db/dbShapes.h +++ b/src/db/db/dbShapes.h @@ -986,6 +986,23 @@ public: * * @param shape The reference of the shape to insert * @param trans The transformation to apply before the shape is inserted + * @return The reference to the new shape + */ + template + shape_type insert_transformed (const shape_type &shape, const Trans &trans) + { + tl::ident_map pm; + tl::func_delegate , db::properties_id_type> pm_delegate (pm); + return do_insert (shape, trans, pm_delegate); + } + + /** + * @brief Insert an element from the shape reference with a transformation and property mapping + * + * Given a shape reference, the corresponding shape is inserted. + * + * @param shape The reference of the shape to insert + * @param trans The transformation to apply before the shape is inserted * @param pm The property ID mapper - the property ID will be mapped accordingly, i.e. for transferring shapes from one layout to another * @return The reference to the new shape */ diff --git a/src/db/db/dbTestSupport.cc b/src/db/db/dbTestSupport.cc index 871e66396..a4ae5b8d1 100644 --- a/src/db/db/dbTestSupport.cc +++ b/src/db/db/dbTestSupport.cc @@ -423,21 +423,9 @@ bool compare (const db::Box &box, const std::string &string) /** * @brief Converts a property ID into a property key/value string representation */ -std::string prop2string (const db::PropertiesRepository &pr, db::properties_id_type prop_id) +std::string prop2string (db::properties_id_type prop_id) { - const db::PropertiesRepository::properties_set &ps = pr.properties (prop_id); - - std::string res; - for (auto i = ps.begin (); i != ps.end (); ++i) { - if (i != ps.begin ()) { - res += "\n"; - } - res += pr.prop_name (i->first).to_string (); - res += "="; - res += i->second.to_string (); - } - - return res; + return db::properties (prop_id).to_dict_var ().to_string (); } } diff --git a/src/db/db/dbTestSupport.h b/src/db/db/dbTestSupport.h index 5369a6e90..af877d289 100644 --- a/src/db/db/dbTestSupport.h +++ b/src/db/db/dbTestSupport.h @@ -122,7 +122,7 @@ bool DB_PUBLIC compare (const db::Box &box, const std::string &string); /** * @brief Converts a property ID into a property key/value string representation */ -std::string DB_PUBLIC prop2string (const db::PropertiesRepository &pr, db::properties_id_type prop_id); +std::string DB_PUBLIC prop2string (db::properties_id_type prop_id); } diff --git a/src/db/db/dbTextWriter.cc b/src/db/db/dbTextWriter.cc index 427675602..7ed935005 100644 --- a/src/db/db/dbTextWriter.cc +++ b/src/db/db/dbTextWriter.cc @@ -139,19 +139,20 @@ TextWriter::endl_str () } void -TextWriter::write_props (const db::Layout &layout, size_t prop_id) +TextWriter::write_props (const db::Layout & /*layout*/, size_t prop_id) { *this << "set props {" << endl_str (); - const db::PropertiesRepository::properties_set &props = layout.properties_repository ().properties (prop_id); - for (db::PropertiesRepository::properties_set::const_iterator p = props.begin (); p != props.end (); ++p) { + const db::PropertiesSet &props = db::properties (prop_id); + for (db::PropertiesSet::iterator p = props.begin (); p != props.end (); ++p) { - const tl::Variant &name = layout.properties_repository ().prop_name (p->first); + const tl::Variant &name = db::property_name (p->first); + const tl::Variant &value = db::property_value (p->second); if (name.is_long () || name.is_ulong ()) { - *this << " {" << int (name.to_long ()) << " {" << p->second.to_string () << "}}" << endl_str (); + *this << " {" << int (name.to_long ()) << " {" << value.to_string () << "}}" << endl_str (); } else if (name.is_a_string ()) { - *this << " {{" << name.to_string () << "} {" << p->second.to_string () << "}}" << endl_str (); + *this << " {{" << name.to_string () << "} {" << value.to_string () << "}}" << endl_str (); } } diff --git a/src/db/db/dbTexts.cc b/src/db/db/dbTexts.cc index 388c89696..c8991bce9 100644 --- a/src/db/db/dbTexts.cc +++ b/src/db/db/dbTexts.cc @@ -169,22 +169,6 @@ Texts::iter () const return *(i ? i : &def_iter); } -const db::PropertiesRepository & -Texts::properties_repository () const -{ - static db::PropertiesRepository empty_prop_repo; - const db::PropertiesRepository *r = delegate () ? delegate ()->properties_repository () : 0; - return *(r ? r : &empty_prop_repo); -} - -db::PropertiesRepository & -Texts::properties_repository () -{ - db::PropertiesRepository *r = delegate () ? delegate ()->properties_repository () : 0; - tl_assert (r != 0); - return *r; -} - void Texts::polygons (Region &output, db::Coord e) const { output.set_delegate (mp_delegate->polygons (e)); diff --git a/src/db/db/dbTextsDelegate.h b/src/db/db/dbTextsDelegate.h index 05f26188e..fa34f9c60 100644 --- a/src/db/db/dbTextsDelegate.h +++ b/src/db/db/dbTextsDelegate.h @@ -112,8 +112,6 @@ public: virtual const db::RecursiveShapeIterator *iter () const = 0; virtual void apply_property_translator (const db::PropertiesTranslator &pt) = 0; - virtual db::PropertiesRepository *properties_repository () = 0; - virtual const db::PropertiesRepository *properties_repository () const = 0; virtual bool equals (const Texts &other) const = 0; virtual bool less (const Texts &other) const = 0; diff --git a/src/db/db/dbTypes.h b/src/db/db/dbTypes.h index 7922ec6b8..bbc123277 100644 --- a/src/db/db/dbTypes.h +++ b/src/db/db/dbTypes.h @@ -589,6 +589,11 @@ typedef size_t properties_id_type; */ typedef size_t property_names_id_type; +/** + * @brief The type of a properties value id + */ +typedef size_t property_values_id_type; + /** * @brief The type of the PCell id */ diff --git a/src/db/db/gsiDeclDbCell.cc b/src/db/db/gsiDeclDbCell.cc index ef5f5b2db..abfd636cf 100644 --- a/src/db/db/gsiDeclDbCell.cc +++ b/src/db/db/gsiDeclDbCell.cc @@ -1059,95 +1059,36 @@ static bool cell_has_prop_id (const db::Cell *c) static void delete_cell_property (db::Cell *c, const tl::Variant &key) { db::properties_id_type id = c->prop_id (); - if (id == 0) { - return; - } - db::Layout *layout = c->layout (); - if (! layout) { - throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot delete properties"))); - } - - std::pair nid = layout->properties_repository ().get_id_of_name (key); - if (! nid.first) { - return; - } - - db::PropertiesRepository::properties_set props = layout->properties_repository ().properties (id); - db::PropertiesRepository::properties_set::iterator p = props.find (nid.second); - if (p != props.end ()) { - props.erase (p); - } - - c->prop_id (layout->properties_repository ().properties_id (props)); + db::PropertiesSet props = db::properties (id); + props.erase (key); + c->prop_id (db::properties_id (props)); } static void set_cell_property (db::Cell *c, const tl::Variant &key, const tl::Variant &value) { db::properties_id_type id = c->prop_id (); - db::Layout *layout = c->layout (); - if (! layout) { - throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot set properties"))); - } - - db::property_names_id_type nid = layout->properties_repository ().prop_name_id (key); - - db::PropertiesRepository::properties_set props = layout->properties_repository ().properties (id); - db::PropertiesRepository::properties_set::iterator p = props.find (nid); - if (p != props.end ()) { - p->second = value; - } else { - props.insert (std::make_pair (nid, value)); - } - - c->prop_id (layout->properties_repository ().properties_id (props)); + db::PropertiesSet props = db::properties (id); + props.erase (key); + props.insert (key, value); + c->prop_id (db::properties_id (props)); } static tl::Variant get_cell_property (const db::Cell *c, const tl::Variant &key) { db::properties_id_type id = c->prop_id (); - if (id == 0) { - return tl::Variant (); - } - const db::Layout *layout = c->layout (); - if (! layout) { - throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot retrieve properties"))); - } - - std::pair nid = layout->properties_repository ().get_id_of_name (key); - if (! nid.first) { - return tl::Variant (); - } - - const db::PropertiesRepository::properties_set &props = layout->properties_repository ().properties (id); - db::PropertiesRepository::properties_set::const_iterator p = props.find (nid.second); - if (p != props.end ()) { - return p->second; - } else { - return tl::Variant (); - } + const db::PropertiesSet &props = db::properties (id); + return props.value (key); } static tl::Variant get_cell_properties (const db::Cell *c) { db::properties_id_type id = c->prop_id (); - if (id == 0) { - return tl::Variant::empty_array (); - } - const db::Layout *layout = c->layout (); - if (! layout) { - throw tl::Exception (tl::to_string (tr ("Cell does not reside inside a layout - cannot retrieve properties"))); - } - - tl::Variant res = tl::Variant::empty_array (); - const db::PropertiesRepository::properties_set &props = layout->properties_repository ().properties (id); - for (auto i = props.begin (); i != props.end (); ++i) { - res.insert (layout->properties_repository ().prop_name (i->first), i->second); - } - return res; + const db::PropertiesSet &props = db::properties (id); + return props.to_dict_var (); } static bool is_pcell_variant (const db::Cell *cell) @@ -1279,10 +1220,9 @@ static void move_or_copy_from_other_cell (db::Cell *cell, db::Cell *src_cell, un } else if (cell->layout () != src_cell->layout ()) { - db::PropertyMapper pm (cell->layout (), src_cell->layout ()); db::ICplxTrans tr (src_cell->layout ()->dbu () / cell->layout ()->dbu ()); - cell->shapes (dest_layer).insert_transformed (src_cell->shapes (src_layer), tr, pm); + cell->shapes (dest_layer).insert_transformed (src_cell->shapes (src_layer), tr); if (move) { src_cell->clear (src_layer); @@ -3560,93 +3500,36 @@ static void set_parent_cell_ptr (db::Instance *i, db::Cell *new_parent) static void delete_property (db::Instance *i, const tl::Variant &key) { db::properties_id_type id = i->prop_id (); - if (id == 0) { - return; - } - db::Layout *layout = layout_ptr (i); - if (! layout) { - throw tl::Exception (tl::to_string (tr ("Instance does not reside inside a layout - cannot delete properties"))); - } - - std::pair nid = layout->properties_repository ().get_id_of_name (key); - if (! nid.first) { - return; - } - - db::PropertiesRepository::properties_set props = layout->properties_repository ().properties (id); - db::PropertiesRepository::properties_set::iterator p = props.find (nid.second); - if (p != props.end ()) { - props.erase (p); - } - set_prop_id (i, layout->properties_repository ().properties_id (props)); + db::PropertiesSet props = db::properties (id); + props.erase (key); + set_prop_id (i, db::properties_id (props)); } static void set_property (db::Instance *i, const tl::Variant &key, const tl::Variant &value) { db::properties_id_type id = i->prop_id (); - db::Layout *layout = layout_ptr (i); - if (! layout) { - throw tl::Exception (tl::to_string (tr ("Instance does not reside inside a layout - cannot set properties"))); - } - - db::property_names_id_type nid = layout->properties_repository ().prop_name_id (key); - - db::PropertiesRepository::properties_set props = layout->properties_repository ().properties (id); - db::PropertiesRepository::properties_set::iterator p = props.find (nid); - if (p != props.end ()) { - p->second = value; - } else { - props.insert (std::make_pair (nid, value)); - } - set_prop_id (i, layout->properties_repository ().properties_id (props)); + db::PropertiesSet props = db::properties (id); + props.erase (key); + props.insert (key, value); + set_prop_id (i, db::properties_id (props)); } static tl::Variant get_property (const db::Instance *i, const tl::Variant &key) { db::properties_id_type id = i->prop_id (); - if (id == 0) { - return tl::Variant (); - } - const db::Layout *layout = layout_ptr_const (i); - if (! layout) { - throw tl::Exception (tl::to_string (tr ("Instance does not reside inside a layout - cannot retrieve properties"))); - } - - std::pair nid = layout->properties_repository ().get_id_of_name (key); - if (! nid.first) { - return tl::Variant (); - } - - const db::PropertiesRepository::properties_set &props = layout->properties_repository ().properties (id); - db::PropertiesRepository::properties_set::const_iterator p = props.find (nid.second); - if (p != props.end ()) { - return p->second; - } else { - return tl::Variant (); - } + const db::PropertiesSet &props = db::properties (id); + return props.value (key); } static tl::Variant get_properties (const db::Instance *i) { db::properties_id_type id = i->prop_id (); - if (id == 0) { - return tl::Variant::empty_array (); - } - const db::Layout *layout = layout_ptr_const (i); - if (! layout) { - throw tl::Exception (tl::to_string (tr ("Instance does not reside inside a layout - cannot retrieve properties"))); - } - - tl::Variant res = tl::Variant::empty_array (); - const db::PropertiesRepository::properties_set &props = layout->properties_repository ().properties (id); - for (auto i = props.begin (); i != props.end (); ++i) { - res.insert (layout->properties_repository ().prop_name (i->first), i->second); - } - return res; + const db::PropertiesSet &props = db::properties (id); + return props.to_dict_var (); } static bool inst_is_valid (const db::Instance *inst) diff --git a/src/db/db/gsiDeclDbContainerHelpers.h b/src/db/db/gsiDeclDbContainerHelpers.h index 7c78def79..c102f3fc8 100644 --- a/src/db/db/gsiDeclDbContainerHelpers.h +++ b/src/db/db/gsiDeclDbContainerHelpers.h @@ -50,19 +50,15 @@ static void remove_properties (Container *c) template static void filter_properties (Container *c, const std::vector &keys) { - if (c->has_properties_repository ()) { - std::set kf; - kf.insert (keys.begin (), keys.end ()); - c->apply_property_translator (db::PropertiesTranslator::make_filter (c->properties_repository (), kf)); - } + std::set kf; + kf.insert (keys.begin (), keys.end ()); + c->apply_property_translator (db::PropertiesTranslator::make_filter (kf)); } template static void map_properties (Container *c, const std::map &map) { - if (c->has_properties_repository ()) { - c->apply_property_translator (db::PropertiesTranslator::make_key_mapper (c->properties_repository (), map)); - } + c->apply_property_translator (db::PropertiesTranslator::make_key_mapper (map)); } template diff --git a/src/db/db/gsiDeclDbLayout.cc b/src/db/db/gsiDeclDbLayout.cc index b4eed69dc..93ffcef1a 100644 --- a/src/db/db/gsiDeclDbLayout.cc +++ b/src/db/db/gsiDeclDbLayout.cc @@ -307,83 +307,40 @@ static void delete_layout_property (db::Layout *l, const tl::Variant &key) // TODO: check if is editable db::properties_id_type id = l->prop_id (); - if (id == 0) { - return; - } - std::pair nid = l->properties_repository ().get_id_of_name (key); - if (! nid.first) { - return; - } - - db::PropertiesRepository::properties_set props = l->properties_repository ().properties (id); - db::PropertiesRepository::properties_set::iterator p = props.find (nid.second); - if (p != props.end ()) { - props.erase (p); - } - - l->prop_id (l->properties_repository ().properties_id (props)); + db::PropertiesSet props = db::properties (id); + props.erase (key); + l->prop_id (db::properties_id (props)); } static void set_layout_property (db::Layout *l, const tl::Variant &key, const tl::Variant &value) { - // TODO: check if is editable - db::properties_id_type id = l->prop_id (); - db::property_names_id_type nid = l->properties_repository ().prop_name_id (key); - - db::PropertiesRepository::properties_set props = l->properties_repository ().properties (id); - db::PropertiesRepository::properties_set::iterator p = props.find (nid); - if (p != props.end ()) { - p->second = value; - } else { - props.insert (std::make_pair (nid, value)); - } - - l->prop_id (l->properties_repository ().properties_id (props)); + db::PropertiesSet props = db::properties (id); + props.erase (key); + props.insert (key, value); + l->prop_id (db::properties_id (props)); } static tl::Variant get_layout_property (const db::Layout *l, const tl::Variant &key) { - // TODO: check if is editable - db::properties_id_type id = l->prop_id (); - if (id == 0) { - return tl::Variant (); - } - std::pair nid = l->properties_repository ().get_id_of_name (key); - if (! nid.first) { - return tl::Variant (); - } - - const db::PropertiesRepository::properties_set &props = l->properties_repository ().properties (id); - db::PropertiesRepository::properties_set::const_iterator p = props.find (nid.second); - if (p != props.end ()) { - return p->second; - } else { - return tl::Variant (); - } + const db::PropertiesSet &props = db::properties (id); + return props.value (key); } -static tl::Variant get_properties_hash (const db::Layout *layout, db::properties_id_type id) +// @@@ should not be needed +static tl::Variant get_properties_hash (const db::Layout * /*layout*/, db::properties_id_type id) { - if (id == 0) { - return tl::Variant::empty_array (); - } - - tl::Variant res = tl::Variant::empty_array (); - const db::PropertiesRepository::properties_set &props = layout->properties_repository ().properties (id); - for (auto i = props.begin (); i != props.end (); ++i) { - res.insert (layout->properties_repository ().prop_name (i->first), i->second); - } - return res; + return db::properties (id).to_dict_var (); } static tl::Variant get_layout_properties (const db::Layout *layout) { - return get_properties_hash (layout, layout->prop_id ()); + const db::PropertiesSet &props = db::properties (layout->prop_id ()); + return props.to_dict_var (); } static db::cell_index_type cell_by_name (db::Layout *l, const char *name) @@ -608,52 +565,37 @@ static std::vector layer_infos (const db::Layout *l) return layers; } -static db::properties_id_type properties_id (db::Layout *layout, const std::vector &properties) +// @@@ Should be static +static db::properties_id_type properties_id (db::Layout * /*layout*/, const std::vector &properties) { - db::PropertiesRepository::properties_set props; + db::PropertiesSet props; for (std::vector::const_iterator v = properties.begin (); v != properties.end (); ++v) { if (! v->is_list () || v->get_list ().size () != 2) { throw tl::Exception (tl::to_string (tr ("Expected a list of pairs of variants (found at least one that is not a pair)"))); } - db::property_names_id_type name_id = layout->properties_repository ().prop_name_id (v->get_list ()[0]); - props.insert (std::make_pair (name_id, v->get_list () [1])); + props.insert (v->get_list ()[0], v->get_list () [1]); } - return layout->properties_repository ().properties_id (props); + return db::properties_id (props); } -static db::properties_id_type properties_id_from_hash (db::Layout *layout, const std::map &properties) +// @@@ Should be static +static db::properties_id_type properties_id_from_hash (db::Layout * /*layout*/, const std::map &properties) { - db::PropertiesRepository::properties_set props; + db::PropertiesSet props; for (std::map::const_iterator v = properties.begin (); v != properties.end (); ++v) { - db::property_names_id_type name_id = layout->properties_repository ().prop_name_id (v->first); - props.insert (std::make_pair (name_id, v->second)); + props.insert (v->first, v->second); } - return layout->properties_repository ().properties_id (props); + return db::properties_id (props); } -static std::vector properties (const db::Layout *layout, db::properties_id_type id) +// @@@ Should be static +static tl::Variant properties (const db::Layout * /*layout*/, db::properties_id_type id) { - std::vector ret; - - if (layout->properties_repository ().is_valid_properties_id (id)) { - - const db::PropertiesRepository::properties_set &props = layout->properties_repository ().properties (id); - ret.reserve (props.size ()); - - for (db::PropertiesRepository::properties_set::const_iterator p = props.begin (); p != props.end (); ++p) { - ret.push_back (tl::Variant::empty_list ()); - ret.back ().get_list ().reserve (2); - ret.back ().get_list ().push_back (layout->properties_repository ().prop_name (p->first)); - ret.back ().get_list ().push_back (p->second); - } - - } - - return ret; + return db::properties (id).to_list_var (); } static void diff --git a/src/db/db/gsiDeclDbLayoutDiff.cc b/src/db/db/gsiDeclDbLayoutDiff.cc index 3e8098750..2f1f04047 100644 --- a/src/db/db/gsiDeclDbLayoutDiff.cc +++ b/src/db/db/gsiDeclDbLayoutDiff.cc @@ -183,7 +183,7 @@ public: begin_polygon_differences_event (); } - virtual void detailed_diff (const db::PropertiesRepository & /*pr*/, const std::vector > &a, const std::vector > &b) + virtual void detailed_diff (const std::vector > &a, const std::vector > &b) { for (std::vector >::const_iterator i = a.begin (); i != a.end (); ++i) { polygon_in_a_only_event (i->first, i->second); @@ -203,7 +203,7 @@ public: begin_path_differences_event (); } - virtual void detailed_diff (const db::PropertiesRepository & /*pr*/, const std::vector > &a, const std::vector > &b) + virtual void detailed_diff (const std::vector > &a, const std::vector > &b) { for (std::vector >::const_iterator i = a.begin (); i != a.end (); ++i) { path_in_a_only_event (i->first, i->second); @@ -223,7 +223,7 @@ public: begin_box_differences_event (); } - virtual void detailed_diff (const db::PropertiesRepository & /*pr*/, const std::vector > &a, const std::vector > &b) + virtual void detailed_diff (const std::vector > &a, const std::vector > &b) { for (std::vector >::const_iterator i = a.begin (); i != a.end (); ++i) { box_in_a_only_event (i->first, i->second); @@ -243,7 +243,7 @@ public: begin_edge_differences_event (); } - virtual void detailed_diff (const db::PropertiesRepository & /*pr*/, const std::vector > &a, const std::vector > &b) + virtual void detailed_diff (const std::vector > &a, const std::vector > &b) { for (std::vector >::const_iterator i = a.begin (); i != a.end (); ++i) { edge_in_a_only_event (i->first, i->second); @@ -263,7 +263,7 @@ public: begin_edge_pair_differences_event (); } - virtual void detailed_diff (const db::PropertiesRepository & /*pr*/, const std::vector > &a, const std::vector > &b) + virtual void detailed_diff (const std::vector > &a, const std::vector > &b) { for (std::vector >::const_iterator i = a.begin (); i != a.end (); ++i) { edge_pair_in_a_only_event (i->first, i->second); @@ -283,7 +283,7 @@ public: begin_text_differences_event (); } - virtual void detailed_diff (const db::PropertiesRepository & /*pr*/, const std::vector > &a, const std::vector > &b) + virtual void detailed_diff (const std::vector > &a, const std::vector > &b) { for (std::vector >::const_iterator i = a.begin (); i != a.end (); ++i) { text_in_a_only_event (i->first, i->second); diff --git a/src/db/db/gsiDeclDbRecursiveShapeIterator.cc b/src/db/db/gsiDeclDbRecursiveShapeIterator.cc index f9ac6ea71..8f4e18df5 100644 --- a/src/db/db/gsiDeclDbRecursiveShapeIterator.cc +++ b/src/db/db/gsiDeclDbRecursiveShapeIterator.cc @@ -206,14 +206,14 @@ static void filter_properties (db::RecursiveShapeIterator *c, const std::vector< if (c->layout ()) { std::set kf; kf.insert (keys.begin (), keys.end ()); - c->apply_property_translator (db::PropertiesTranslator::make_filter (const_cast (c->layout ())->properties_repository (), kf)); + c->apply_property_translator (db::PropertiesTranslator::make_filter (kf)); } } static void map_properties (db::RecursiveShapeIterator *c, const std::map &map) { if (c->layout ()) { - c->apply_property_translator (db::PropertiesTranslator::make_key_mapper (const_cast (c->layout ())->properties_repository (), map)); + c->apply_property_translator (db::PropertiesTranslator::make_key_mapper (map)); } } diff --git a/src/db/db/gsiDeclDbShape.cc b/src/db/db/gsiDeclDbShape.cc index 36e6ee4d4..1c7870ec5 100644 --- a/src/db/db/gsiDeclDbShape.cc +++ b/src/db/db/gsiDeclDbShape.cc @@ -939,89 +939,35 @@ static void delete_property (db::Shape *s, const tl::Variant &key) return; } - db::Layout *layout = layout_ptr (s); - if (! layout) { - throw tl::Exception (tl::to_string (tr ("Shape does not reside inside a layout - cannot delete properties"))); - } - - std::pair nid = layout->properties_repository ().get_id_of_name (key); - if (! nid.first) { - return; - } - - db::PropertiesRepository::properties_set props = layout->properties_repository ().properties (id); - db::PropertiesRepository::properties_set::iterator p = props.find (nid.second); - if (p != props.end ()) { - props.erase (p); - } - set_prop_id (s, layout->properties_repository ().properties_id (props)); + db::PropertiesSet props = db::properties (id); + props.erase (key); + set_prop_id (s, db::properties_id (props)); } static void set_property (db::Shape *s, const tl::Variant &key, const tl::Variant &value) { db::properties_id_type id = s->prop_id (); - db::Layout *layout = layout_ptr (s); - if (! layout) { - throw tl::Exception (tl::to_string (tr ("Shape does not reside inside a layout - cannot set properties"))); - } - - db::property_names_id_type nid = layout->properties_repository ().prop_name_id (key); - - db::PropertiesRepository::properties_set props = layout->properties_repository ().properties (id); - db::PropertiesRepository::properties_set::iterator p = props.find (nid); - if (p != props.end ()) { - p->second = value; - } else { - props.insert (std::make_pair (nid, value)); - } - set_prop_id (s, layout->properties_repository ().properties_id (props)); + db::PropertiesSet props = db::properties (id); + props.erase (key); + props.insert (key, value); + set_prop_id (s, db::properties_id (props)); } static tl::Variant get_property (const db::Shape *s, const tl::Variant &key) { db::properties_id_type id = s->prop_id (); - if (id == 0) { - return tl::Variant (); - } - const db::Layout *layout = layout_ptr_const (s); - if (! layout) { - throw tl::Exception (tl::to_string (tr ("Shape does not reside inside a layout - cannot retrieve properties"))); - } - - std::pair nid = layout->properties_repository ().get_id_of_name (key); - if (! nid.first) { - return tl::Variant (); - } - - const db::PropertiesRepository::properties_set &props = layout->properties_repository ().properties (id); - db::PropertiesRepository::properties_set::const_iterator p = props.find (nid.second); - if (p != props.end ()) { - return p->second; - } else { - return tl::Variant (); - } + const db::PropertiesSet &props = db::properties (id); + return props.value (key); } static tl::Variant get_properties (const db::Shape *s) { db::properties_id_type id = s->prop_id (); - if (id == 0) { - return tl::Variant::empty_array (); - } - const db::Layout *layout = layout_ptr_const (s); - if (! layout) { - throw tl::Exception (tl::to_string (tr ("Shape does not reside inside a layout - cannot retrieve properties"))); - } - - tl::Variant res = tl::Variant::empty_array (); - const db::PropertiesRepository::properties_set &props = layout->properties_repository ().properties (id); - for (auto i = props.begin (); i != props.end (); ++i) { - res.insert (layout->properties_repository ().prop_name (i->first), i->second); - } - return res; + const db::PropertiesSet &props = db::properties (id); + return props.to_dict_var (); } namespace diff --git a/src/db/unit_tests/dbAsIfFlatRegionTests.cc b/src/db/unit_tests/dbAsIfFlatRegionTests.cc index 55d459000..0bc433434 100644 --- a/src/db/unit_tests/dbAsIfFlatRegionTests.cc +++ b/src/db/unit_tests/dbAsIfFlatRegionTests.cc @@ -1743,10 +1743,9 @@ TEST(40_BoolWithProperties) clip_region.insert (clip); db::Region clip_region_wp (new db::FlatRegion ()); - db::property_names_id_type pn = clip_region_wp.properties_repository ().prop_name_id (1); - db::PropertiesRepository::properties_set ps; - ps.insert (std::make_pair (pn, 42)); - db::properties_id_type pid42 = clip_region_wp.properties_repository ().properties_id (ps); + db::PropertiesSet ps; + ps.insert (tl::Variant (1), 42); + db::properties_id_type pid42 = db::properties_id (ps); clip_region_wp.insert (db::BoxWithProperties (clip, pid42)); target.insert (target_top_cell_index, target.get_layer (db::LayerProperties (60, 0)), r1.bool_and (clip_region)); diff --git a/src/db/unit_tests/dbCellTests.cc b/src/db/unit_tests/dbCellTests.cc index 0cffd31e6..d99a9757a 100644 --- a/src/db/unit_tests/dbCellTests.cc +++ b/src/db/unit_tests/dbCellTests.cc @@ -871,11 +871,6 @@ struct map1 db::cell_index_type operator() (db::cell_index_type i) const { return 3-i; } }; -struct map2 -{ - db::Layout::properties_id_type operator() (db::Layout::properties_id_type i) const { return 3+i; } -}; - TEST(4) { ::pi = 0; @@ -908,10 +903,9 @@ TEST(4) db::Cell &c4 (g.cell (g.add_cell ())); for (db::Cell::const_iterator i = c0.begin (); ! i.at_end (); ++i) { map1 m1; - map2 m2; - c4.insert (*i, m1, m2); + c4.insert (*i, m1); } - EXPECT_EQ (c2s_unsorted(c4), "2[r0 *1 0,0]#0,2[r0 *1 0,0]#4,1[r0 *1 100,-100]#13"); + EXPECT_EQ (c2s_unsorted(c4), "2[r0 *1 0,0]#0,2[r0 *1 0,0]#1,1[r0 *1 100,-100]#10"); } diff --git a/src/db/unit_tests/dbDeepShapeStoreTests.cc b/src/db/unit_tests/dbDeepShapeStoreTests.cc index e585c50e8..061961b54 100644 --- a/src/db/unit_tests/dbDeepShapeStoreTests.cc +++ b/src/db/unit_tests/dbDeepShapeStoreTests.cc @@ -180,12 +180,6 @@ TEST(3_TextTreatment) EXPECT_EQ (dl1.initial_cell ().shapes (dl1.layer ()).size (), size_t (1)); EXPECT_EQ (dl1.initial_cell ().shapes (dl1.layer ()).begin (db::ShapeIterator::All)->to_string (), "polygon (999,1999;999,2001;1001,2001;1001,1999) prop_id=1"); - - const db::Layout *dss_layout = &store.const_layout (0); - db::PropertiesRepository::properties_set ps = dss_layout->properties_repository ().properties (1); - EXPECT_EQ (ps.size (), size_t (1)); - EXPECT_EQ (dss_layout->properties_repository ().prop_name (ps.begin ()->first).to_string (), "text"); - EXPECT_EQ (ps.begin ()->second.to_string (), "TEXT"); } TEST(4_FlatAndEmptyInput) diff --git a/src/db/unit_tests/dbHierNetworkProcessorTests.cc b/src/db/unit_tests/dbHierNetworkProcessorTests.cc index 60017754d..dab04f99e 100644 --- a/src/db/unit_tests/dbHierNetworkProcessorTests.cc +++ b/src/db/unit_tests/dbHierNetworkProcessorTests.cc @@ -1074,19 +1074,15 @@ static void copy_cluster_shapes (const std::string *&attrs, db::Shapes &out, db: // use property #1 to code the cell name // use property #2 to code the attrs string for the first shape - db::PropertiesRepository &pr = out.layout ()->properties_repository (); - db::properties_id_type cell_pid = 0, cell_and_attr_pid = 0; - db::property_names_id_type pn_id = pr.prop_name_id (tl::Variant (1)); - db::PropertiesRepository::properties_set pm; - pm.insert (std::make_pair (pn_id, tl::Variant (out.layout ()->cell_name (ci)))); - cell_pid = pr.properties_id (pm); + db::PropertiesSet pm; + pm.insert (tl::Variant (1), tl::Variant (out.layout ()->cell_name (ci))); + cell_pid = db::properties_id (pm); if (attrs && ! attrs->empty ()) { - db::property_names_id_type pn2_id = pr.prop_name_id (tl::Variant (2)); - pm.insert (std::make_pair (pn2_id, tl::Variant (*attrs))); - cell_and_attr_pid = pr.properties_id (pm); + pm.insert (tl::Variant (2), tl::Variant (*attrs)); + cell_and_attr_pid = db::properties_id (pm); } const db::connected_clusters &clusters = hc.clusters_per_cell (ci); diff --git a/src/db/unit_tests/dbLayoutDiffTests.cc b/src/db/unit_tests/dbLayoutDiffTests.cc index 6fb0d413b..b03a37d22 100644 --- a/src/db/unit_tests/dbLayoutDiffTests.cc +++ b/src/db/unit_tests/dbLayoutDiffTests.cc @@ -49,30 +49,30 @@ public: void cell_meta_info_differs (const std::string &, const tl::Variant &, const tl::Variant &); void bbox_differs (const db::Box &ba, const db::Box &bb); void begin_inst_differences (); - void instances_in_a (const std::vector &insts_a, const std::vector &cell_names, const db::PropertiesRepository &props); - void instances_in_b (const std::vector &insts_b, const std::vector &cell_names, const db::PropertiesRepository &props); + void instances_in_a (const std::vector &insts_a, const std::vector &cell_names); + void instances_in_b (const std::vector &insts_b, const std::vector &cell_names); void instances_in_a_only (const std::vector &anotb, const db::Layout &a); void instances_in_b_only (const std::vector &bnota, const db::Layout &b); void end_inst_differences (); void begin_layer (const db::LayerProperties &layer, unsigned int layer_index_a, bool is_valid_a, unsigned int layer_index_b, bool is_valid_b); void per_layer_bbox_differs (const db::Box &ba, const db::Box &bb); void begin_polygon_differences (); - void detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b); + void detailed_diff (const std::vector > &a, const std::vector > &b); void end_polygon_differences (); void begin_path_differences (); - void detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b); + void detailed_diff (const std::vector > &a, const std::vector > &b); void end_path_differences (); void begin_box_differences (); - void detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b); + void detailed_diff (const std::vector > &a, const std::vector > &b); void end_box_differences (); void begin_edge_differences (); - void detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b); + void detailed_diff (const std::vector > &a, const std::vector > &b); void end_edge_differences (); void begin_edge_pair_differences (); - void detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b); + void detailed_diff (const std::vector > &a, const std::vector > &b); void end_edge_pair_differences (); void begin_text_differences (); - void detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b); + void detailed_diff (const std::vector > &a, const std::vector > &b); void end_text_differences (); void end_layer (); void end_cell (); @@ -84,7 +84,7 @@ private: void print_cell_inst (const db::CellInstArrayWithProperties &ci, const std::vector &cell_names); void print_cell_inst (const db::CellInstArrayWithProperties &ci, const db::Layout &l); - template void print_diffs (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b); + template void print_diffs (const std::vector > &a, const std::vector > &b); }; TestDifferenceReceiver::TestDifferenceReceiver () @@ -133,7 +133,7 @@ TestDifferenceReceiver::print_cell_inst (const db::CellInstArrayWithProperties & template void -TestDifferenceReceiver::print_diffs (const db::PropertiesRepository & /*pr*/, const std::vector > &_a, const std::vector > &_b) +TestDifferenceReceiver::print_diffs (const std::vector > &_a, const std::vector > &_b) { std::vector > a = _a; std::sort (a.begin (), a.end ()); @@ -225,7 +225,7 @@ TestDifferenceReceiver::begin_inst_differences () } void -TestDifferenceReceiver::instances_in_a (const std::vector &insts_a, const std::vector &cell_names, const db::PropertiesRepository & /*props*/) +TestDifferenceReceiver::instances_in_a (const std::vector &insts_a, const std::vector &cell_names) { m_os << "list for a:" << std::endl; for (std::vector ::const_iterator s = insts_a.begin (); s != insts_a.end (); ++s) { @@ -234,7 +234,7 @@ TestDifferenceReceiver::instances_in_a (const std::vector &insts_b, const std::vector &cell_names, const db::PropertiesRepository & /*props*/) +TestDifferenceReceiver::instances_in_b (const std::vector &insts_b, const std::vector &cell_names) { m_os << "list for b:" << std::endl; for (std::vector ::const_iterator s = insts_b.begin (); s != insts_b.end (); ++s) { @@ -285,12 +285,12 @@ TestDifferenceReceiver::begin_polygon_differences () } void -TestDifferenceReceiver::detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b) +TestDifferenceReceiver::detailed_diff (const std::vector > &a, const std::vector > &b) { m_os << "Not in b but in a:" << std::endl; - print_diffs (pr, a, b); + print_diffs (a, b); m_os << "Not in a but in b:" << std::endl; - print_diffs (pr, b, a); + print_diffs (b, a); } void @@ -305,12 +305,12 @@ TestDifferenceReceiver::begin_path_differences () } void -TestDifferenceReceiver::detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b) +TestDifferenceReceiver::detailed_diff (const std::vector > &a, const std::vector > &b) { m_os << "Not in b but in a:" << std::endl; - print_diffs (pr, a, b); + print_diffs (a, b); m_os << "Not in a but in b:" << std::endl; - print_diffs (pr, b, a); + print_diffs (b, a); } void @@ -325,12 +325,12 @@ TestDifferenceReceiver::begin_box_differences () } void -TestDifferenceReceiver::detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b) +TestDifferenceReceiver::detailed_diff (const std::vector > &a, const std::vector > &b) { m_os << "Not in b but in a:" << std::endl; - print_diffs (pr, a, b); + print_diffs (a, b); m_os << "Not in a but in b:" << std::endl; - print_diffs (pr, b, a); + print_diffs (b, a); } void @@ -345,12 +345,12 @@ TestDifferenceReceiver::begin_edge_differences () } void -TestDifferenceReceiver::detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b) +TestDifferenceReceiver::detailed_diff (const std::vector > &a, const std::vector > &b) { m_os << "Not in b but in a:" << std::endl; - print_diffs (pr, a, b); + print_diffs (a, b); m_os << "Not in a but in b:" << std::endl; - print_diffs (pr, b, a); + print_diffs (b, a); } void @@ -365,12 +365,12 @@ TestDifferenceReceiver::begin_edge_pair_differences () } void -TestDifferenceReceiver::detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b) +TestDifferenceReceiver::detailed_diff (const std::vector > &a, const std::vector > &b) { m_os << "Not in b but in a:" << std::endl; - print_diffs (pr, a, b); + print_diffs (a, b); m_os << "Not in a but in b:" << std::endl; - print_diffs (pr, b, a); + print_diffs (b, a); } void @@ -385,12 +385,12 @@ TestDifferenceReceiver::begin_text_differences () } void -TestDifferenceReceiver::detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b) +TestDifferenceReceiver::detailed_diff (const std::vector > &a, const std::vector > &b) { m_os << "Not in b but in a:" << std::endl; - print_diffs (pr, a, b); + print_diffs (a, b); m_os << "Not in a but in b:" << std::endl; - print_diffs (pr, b, a); + print_diffs (b, a); } void @@ -647,19 +647,9 @@ TEST(2) ); } -std::string ps2string (const db::PropertiesRepository &rep, db::properties_id_type pi) +std::string ps2string (db::properties_id_type pi) { - std::string s; - db::PropertiesRepository::properties_set ps = rep.properties (pi); - for (db::PropertiesRepository::properties_set::const_iterator i = ps.begin (); i != ps.end (); ++i) { - if (!s.empty ()) { - s += ","; - } - s += rep.prop_name (i->first).to_string (); - s += ":"; - s += i->second.to_string (); - } - return s; + return db::properties (pi).to_dict_var ().to_string (); } TEST(2P) @@ -715,33 +705,24 @@ TEST(2P) { db::properties_id_type pi1, pi2, pi3; - db::PropertiesRepository::properties_set ps; - ps.insert (std::make_pair (g.properties_repository ().prop_name_id ("A"), tl::Variant (1))); - pi1 = g.properties_repository ().properties_id (ps); - EXPECT_EQ (pi1, db::properties_id_type (1)); + db::PropertiesSet ps; + ps.insert (tl::Variant ("A"), tl::Variant (1)); + pi1 = db::properties_id (ps); ps.clear (); - ps.insert (std::make_pair (g.properties_repository ().prop_name_id ("B"), tl::Variant (2))); - pi2 = g.properties_repository ().properties_id (ps); - EXPECT_EQ (pi2, db::properties_id_type (2)); + ps.insert (tl::Variant ("B"), tl::Variant (2)); + pi2 = db::properties_id (ps); - ps.insert (std::make_pair (g.properties_repository ().prop_name_id ("C"), tl::Variant ("c"))); - pi3 = g.properties_repository ().properties_id (ps); - EXPECT_EQ (pi3, db::properties_id_type (3)); + ps.insert (tl::Variant ("C"), tl::Variant ("c")); + pi3 = db::properties_id (ps); - EXPECT_EQ (ps2string (g.properties_repository (), 1), "A:1"); - EXPECT_EQ (ps2string (g.properties_repository (), 2), "B:2"); - EXPECT_EQ (ps2string (g.properties_repository (), 3), "B:2,C:c"); + EXPECT_EQ (ps2string (pi1), "A:1"); + EXPECT_EQ (ps2string (pi2), "B:2"); + EXPECT_EQ (ps2string (pi3), "B:2,C:c"); } db::Layout h = g; - { - EXPECT_EQ (ps2string (h.properties_repository (), 1), "A:1"); - EXPECT_EQ (ps2string (h.properties_repository (), 2), "B:2"); - EXPECT_EQ (ps2string (h.properties_repository (), 3), "B:2,C:c"); - } - TestDifferenceReceiver r; bool eq; @@ -806,12 +787,6 @@ TEST(2P) h = hh; - { - EXPECT_EQ (ps2string (h.properties_repository (), 1), "A:1"); - EXPECT_EQ (ps2string (h.properties_repository (), 2), "B:2"); - EXPECT_EQ (ps2string (h.properties_repository (), 3), "B:2,C:c"); - } - // Note: properties are "normalized" (mapped to a common layout). In order to maintain // their meaning later, keep these inserts sorted by property ID: h.cell (c2i).shapes (0).insert (db::BoxWithProperties (db::Box (1, 2, 1003, 1005), 1)); diff --git a/src/db/unit_tests/dbLayoutTests.cc b/src/db/unit_tests/dbLayoutTests.cc index 302d4245d..5693cf0b8 100644 --- a/src/db/unit_tests/dbLayoutTests.cc +++ b/src/db/unit_tests/dbLayoutTests.cc @@ -437,7 +437,8 @@ TEST(4) g.dbu_changed_event.add (&el, &EventListener::dbu_changed); g.cell_name_changed_event.add (&el, &EventListener::cell_name_changed); - g.properties_repository ().prop_ids_changed_event.add (&el, &EventListener::property_ids_changed); + // @@@ + db::PropertiesRepository::instance ().prop_ids_changed_event.add (&el, &EventListener::property_ids_changed); g.layer_properties_changed_event.add (&el, &EventListener::layer_properties_changed); EXPECT_EQ (el.dbu_dirty, false); @@ -469,15 +470,17 @@ TEST(4) g.rename_cell (top, "TAP"); EXPECT_EQ (el.cell_name_dirty, true); // but this is - db::PropertiesRepository::properties_set ps; - ps.insert (std::make_pair (g.properties_repository ().prop_name_id (tl::Variant (1)), tl::Variant ("XYZ"))); - g.properties_repository ().properties_id (ps); + // @@@ cannot be like that -> needs to trigger an event if some layout object has changed + db::PropertiesSet ps; + ps.insert (tl::Variant (1), tl::Variant ("XYZ")); + db::properties_id (ps); EXPECT_EQ (el.property_ids_dirty, true); el.reset (); + // @@@ cannot be like that -> needs to trigger an event if some layout object has changed ps.clear (); - ps.insert (std::make_pair (g.properties_repository ().prop_name_id (tl::Variant (1)), tl::Variant ("XXX"))); - g.properties_repository ().properties_id (ps); + ps.insert (tl::Variant (1), tl::Variant ("XXX")); + db::properties_id (ps); EXPECT_EQ (el.property_ids_dirty, true); el.layer_properties_dirty = false; diff --git a/src/db/unit_tests/dbLayoutUtilsTests.cc b/src/db/unit_tests/dbLayoutUtilsTests.cc index 24d95c441..2891023b7 100644 --- a/src/db/unit_tests/dbLayoutUtilsTests.cc +++ b/src/db/unit_tests/dbLayoutUtilsTests.cc @@ -661,13 +661,13 @@ TEST(19_scale_and_snap_basic) db::Layout l1; db::Layout l2; - db::PropertiesRepository::properties_set ps1; - ps1.insert (std::make_pair (l1.properties_repository ().prop_name_id (tl::Variant ("p")), tl::Variant (17))); - db::properties_id_type pid1 = l1.properties_repository ().properties_id (ps1); + db::PropertiesSet ps1; + ps1.insert (tl::Variant ("p"), tl::Variant (17)); + db::properties_id_type pid1 = db::properties_id (ps1); - db::PropertiesRepository::properties_set ps2; - ps2.insert (std::make_pair (l2.properties_repository ().prop_name_id (tl::Variant ("p")), tl::Variant (17))); - db::properties_id_type pid2 = l2.properties_repository ().properties_id (ps2); + db::PropertiesSet ps2; + ps2.insert (tl::Variant ("p"), tl::Variant (17)); + db::properties_id_type pid2 = db::properties_id (ps2); db::Cell &top1 = l1.cell (l1.add_cell ("TOP")); db::Cell &top2 = l2.cell (l2.add_cell ("TOP")); diff --git a/src/db/unit_tests/dbPropertiesRepositoryTests.cc b/src/db/unit_tests/dbPropertiesRepositoryTests.cc index a81214b37..930d5d94b 100644 --- a/src/db/unit_tests/dbPropertiesRepositoryTests.cc +++ b/src/db/unit_tests/dbPropertiesRepositoryTests.cc @@ -26,7 +26,7 @@ #include "tlString.h" #include "tlUnitTest.h" - +#if 0 // @@@ TEST(1) { tl::Variant v; @@ -392,3 +392,4 @@ TEST(10_PropertiesTranslator) EXPECT_EQ (prop2string (rp, t (prop2)), "1=102"); EXPECT_EQ (prop2string (rp, t (prop3)), ""); } +#endif diff --git a/src/db/unit_tests/dbRegionTests.cc b/src/db/unit_tests/dbRegionTests.cc index ac7a2c0bc..852660e01 100644 --- a/src/db/unit_tests/dbRegionTests.cc +++ b/src/db/unit_tests/dbRegionTests.cc @@ -2282,15 +2282,14 @@ TEST(53_PropertiesDeepFromLayout) db::Cell &top = ly.cell (ly.add_cell ("TOP")); tl::Variant pname ("VALUE"); - db::property_names_id_type pname_id = ly.properties_repository ().prop_name_id (pname); - db::PropertiesRepository::properties_set ps42; - ps42.insert (std::make_pair (pname_id, tl::Variant (42))); - db::properties_id_type pid42 = ly.properties_repository ().properties_id (ps42); + db::PropertiesSet ps42; + ps42.insert (pname, tl::Variant (42)); + db::properties_id_type pid42 = db::properties_id (ps42); - db::PropertiesRepository::properties_set ps1; - ps1.insert (std::make_pair (pname_id, tl::Variant (1))); - db::properties_id_type pid1 = ly.properties_repository ().properties_id (ps1); + db::PropertiesSet ps1; + ps1.insert (pname, tl::Variant (1)); + db::properties_id_type pid1 = db::properties_id (ps1); db::Shapes &si = top.shapes (li); si.insert (db::Box (0, 0, 100, 200)); @@ -2374,11 +2373,11 @@ TEST(53_PropertiesDeepFromLayout) EXPECT_EQ (s->to_string (), "(10,20;10,220;110,220;110,20)"); ++s; EXPECT_EQ (s.at_end (), false); - EXPECT_EQ (prop2string (r.properties_repository (), s.prop_id ()), "VALUE=1"); + EXPECT_EQ (db::prop2string (s.prop_id ()), "VALUE=1"); EXPECT_EQ (s->to_string (), "(1,2;1,202;101,202;101,2)"); ++s; EXPECT_EQ (s.at_end (), false); - EXPECT_EQ (prop2string (r.properties_repository (), s.prop_id ()), "VALUE=42"); + EXPECT_EQ (db::prop2string (s.prop_id ()), "VALUE=42"); EXPECT_EQ (s->to_string (), "(11,12;11,212;111,212;111,12)"); ++s; EXPECT_EQ (s.at_end (), true); @@ -2391,13 +2390,13 @@ TEST(53_PropertiesDeepFromLayout) ++s; EXPECT_EQ (s.at_end (), false); - EXPECT_EQ (prop2string (r.properties_repository (), s.prop_id ()), "VALUE=1"); + EXPECT_EQ (db::prop2string (s.prop_id ()), "VALUE=1"); // a single property #1 element EXPECT_EQ (s->to_string (), "(1,2;1,202;101,202;101,2)"); ++s; EXPECT_EQ (s.at_end (), false); - EXPECT_EQ (prop2string (r.properties_repository (), s.prop_id ()), "VALUE=42"); + EXPECT_EQ (db::prop2string (s.prop_id ()), "VALUE=42"); // a single property #42 element EXPECT_EQ (s->to_string (), "(11,12;11,212;111,212;111,12)"); ++s; @@ -2410,29 +2409,24 @@ TEST(54_PropertiesFilterDeep) db::DeepShapeStore dss ("TOP", 0.001); db::Region r (dss); - db::PropertiesRepository &rp = r.properties_repository (); - db::property_names_id_type key1 = rp.prop_name_id (1); - db::property_names_id_type key2 = rp.prop_name_id (2); - db::property_names_id_type key3 = rp.prop_name_id (3); - - db::PropertiesRepository::properties_set ps; - ps.insert (std::make_pair (key1, 100)); - ps.insert (std::make_pair (key2, 101)); - db::properties_id_type prop1a = rp.properties_id (ps); + db::PropertiesSet ps; + ps.insert (tl::Variant (1), 100); + ps.insert (tl::Variant (2), 101); + db::properties_id_type prop1a = db::properties_id (ps); ps.clear (); - ps.insert (std::make_pair (key1, 0)); - ps.insert (std::make_pair (key2, 101)); - db::properties_id_type prop1b = rp.properties_id (ps); + ps.insert (tl::Variant (1), 0); + ps.insert (tl::Variant (2), 101); + db::properties_id_type prop1b = db::properties_id (ps); ps.clear (); - ps.insert (std::make_pair (key1, 100)); - ps.insert (std::make_pair (key3, 102)); - db::properties_id_type prop2 = rp.properties_id (ps); + ps.insert (tl::Variant (1), 100); + ps.insert (tl::Variant (3), 102); + db::properties_id_type prop2 = db::properties_id (ps); ps.clear (); - ps.insert (std::make_pair (key1, 100)); - db::properties_id_type prop3 = rp.properties_id (ps); + ps.insert (tl::Variant (1), 100); + db::properties_id_type prop3 = db::properties_id (ps); r.insert (db::BoxWithProperties (db::Box (1, 2, 101, 202), prop1a)); r.insert (db::BoxWithProperties (db::Box (10, 12, 111, 212), prop1b)); @@ -2444,30 +2438,30 @@ TEST(54_PropertiesFilterDeep) std::set kf; kf.insert (1); - rr.apply_property_translator (db::PropertiesTranslator::make_filter (rr.properties_repository (), kf)); + rr.apply_property_translator (db::PropertiesTranslator::make_filter (kf)); db::Region::const_iterator s = rr.begin (); EXPECT_EQ (s.at_end (), false); - EXPECT_EQ (db::prop2string (rr.properties_repository (), s.prop_id ()), "1=100"); + EXPECT_EQ (db::prop2string (s.prop_id ()), "1=100"); EXPECT_EQ (s->to_string (), "(1,2;1,202;101,202;101,2)"); ++s; EXPECT_EQ (s.at_end (), false); - EXPECT_EQ (db::prop2string (rr.properties_repository (), s.prop_id ()), "1=0"); + EXPECT_EQ (db::prop2string (s.prop_id ()), "1=0"); EXPECT_EQ (s->to_string (), "(10,12;10,212;111,212;111,12)"); ++s; EXPECT_EQ (s.at_end (), false); - EXPECT_EQ (db::prop2string (rr.properties_repository (), s.prop_id ()), "1=100"); + EXPECT_EQ (db::prop2string (s.prop_id ()), "1=100"); EXPECT_EQ (s->to_string (), "(20,22;20,222;121,222;121,22)"); ++s; EXPECT_EQ (s.at_end (), false); - EXPECT_EQ (db::prop2string (rr.properties_repository (), s.prop_id ()), "1=100"); + EXPECT_EQ (db::prop2string (s.prop_id ()), "1=100"); EXPECT_EQ (s->to_string (), "(30,32;30,232;131,232;131,32)"); ++s; EXPECT_EQ (s.at_end (), true); s = r.begin (); EXPECT_EQ (s.at_end (), false); - EXPECT_EQ (db::prop2string (r.properties_repository (), s.prop_id ()), "1=100\n2=101"); + EXPECT_EQ (db::prop2string (s.prop_id ()), "1=100\n2=101"); EXPECT_EQ (s->to_string (), "(1,2;1,202;101,202;101,2)"); } @@ -2476,29 +2470,24 @@ TEST(55_PropertiesFilterFlat) // NOTE: we have to force flat as otherwise no properties repo is available db::Region r (new db::FlatRegion ()); - db::PropertiesRepository &rp = r.properties_repository (); - db::property_names_id_type key1 = rp.prop_name_id (1); - db::property_names_id_type key2 = rp.prop_name_id (2); - db::property_names_id_type key3 = rp.prop_name_id (3); - - db::PropertiesRepository::properties_set ps; - ps.insert (std::make_pair (key1, 100)); - ps.insert (std::make_pair (key2, 101)); - db::properties_id_type prop1a = rp.properties_id (ps); + db::PropertiesSet ps; + ps.insert (tl::Variant (1), 100); + ps.insert (tl::Variant (2), 101); + db::properties_id_type prop1a = db::properties_id (ps); ps.clear (); - ps.insert (std::make_pair (key1, 0)); - ps.insert (std::make_pair (key2, 101)); - db::properties_id_type prop1b = rp.properties_id (ps); + ps.insert (tl::Variant (1), 0); + ps.insert (tl::Variant (2), 101); + db::properties_id_type prop1b = db::properties_id (ps); ps.clear (); - ps.insert (std::make_pair (key1, 100)); - ps.insert (std::make_pair (key3, 102)); - db::properties_id_type prop2 = rp.properties_id (ps); + ps.insert (tl::Variant (1), 100); + ps.insert (tl::Variant (3), 102); + db::properties_id_type prop2 = db::properties_id (ps); ps.clear (); - ps.insert (std::make_pair (key1, 100)); - db::properties_id_type prop3 = rp.properties_id (ps); + ps.insert (tl::Variant (1), 100); + db::properties_id_type prop3 = db::properties_id (ps); r.insert (db::BoxWithProperties (db::Box (1, 2, 101, 202), prop1a)); r.insert (db::BoxWithProperties (db::Box (10, 12, 111, 212), prop1b)); @@ -2510,30 +2499,30 @@ TEST(55_PropertiesFilterFlat) std::set kf; kf.insert (1); - rr.apply_property_translator (db::PropertiesTranslator::make_filter (rr.properties_repository (), kf)); + rr.apply_property_translator (db::PropertiesTranslator::make_filter (kf)); db::Region::const_iterator s = rr.begin (); EXPECT_EQ (s.at_end (), false); - EXPECT_EQ (db::prop2string (rr.properties_repository (), s.prop_id ()), "1=100"); + EXPECT_EQ (db::prop2string (s.prop_id ()), "1=100"); EXPECT_EQ (s->to_string (), "(1,2;1,202;101,202;101,2)"); ++s; EXPECT_EQ (s.at_end (), false); - EXPECT_EQ (db::prop2string (rr.properties_repository (), s.prop_id ()), "1=0"); + EXPECT_EQ (db::prop2string (s.prop_id ()), "1=0"); EXPECT_EQ (s->to_string (), "(10,12;10,212;111,212;111,12)"); ++s; EXPECT_EQ (s.at_end (), false); - EXPECT_EQ (db::prop2string (rr.properties_repository (), s.prop_id ()), "1=100"); + EXPECT_EQ (db::prop2string (s.prop_id ()), "1=100"); EXPECT_EQ (s->to_string (), "(20,22;20,222;121,222;121,22)"); ++s; EXPECT_EQ (s.at_end (), false); - EXPECT_EQ (db::prop2string (rr.properties_repository (), s.prop_id ()), "1=100"); + EXPECT_EQ (db::prop2string (s.prop_id ()), "1=100"); EXPECT_EQ (s->to_string (), "(30,32;30,232;131,232;131,32)"); ++s; EXPECT_EQ (s.at_end (), true); s = r.begin (); EXPECT_EQ (s.at_end (), false); - EXPECT_EQ (db::prop2string (r.properties_repository (), s.prop_id ()), "1=100\n2=101"); + EXPECT_EQ (db::prop2string (s.prop_id ()), "1=100\n2=101"); EXPECT_EQ (s->to_string (), "(1,2;1,202;101,202;101,2)"); } diff --git a/src/db/unit_tests/dbShapeTests.cc b/src/db/unit_tests/dbShapeTests.cc index 1d4a19003..c4ded23c7 100644 --- a/src/db/unit_tests/dbShapeTests.cc +++ b/src/db/unit_tests/dbShapeTests.cc @@ -768,12 +768,14 @@ TEST(8) { db::Manager m (true); db::Shapes s (&m, 0, db::default_editable_mode ()); - db::PropertiesRepository proprep; - db::PropertiesRepository::properties_set set1; - set1.insert (std::make_pair (0, tl::Variant (15l))); - db::PropertiesRepository rep; - size_t id1 = rep.properties_id (set1); + db::PropertiesSet set0; + set0.insert (tl::Variant (0), tl::Variant (0)); + size_t id0 = db::properties_id (set0); + + db::PropertiesSet set1; + set1.insert (tl::Variant (0), tl::Variant (15l)); + size_t id1 = db::properties_id (set1); db::BoxWithProperties bx2 = db::BoxWithProperties (db::Box (db::Point (0, 1000), db::Point (100, 2000)), id1); s.insert (bx2); @@ -795,7 +797,7 @@ TEST(8) EXPECT_EQ (si.at_end (), true); - prop_sel.insert (22); + prop_sel.insert (id0); si = db::ShapeIterator (s.begin (db::ShapeIterator::Polygons | db::ShapeIterator::Boxes, &prop_sel, false)); EXPECT_EQ (si.at_end (), true); diff --git a/src/laybasic/laybasic/layCellView.cc b/src/laybasic/laybasic/layCellView.cc index e41c5a685..670199b08 100644 --- a/src/laybasic/laybasic/layCellView.cc +++ b/src/laybasic/laybasic/layCellView.cc @@ -88,7 +88,8 @@ LayoutHandle::LayoutHandle (db::Layout *layout, const std::string &filename) mp_layout->hier_changed_event.add (this, &LayoutHandle::layout_changed); mp_layout->bboxes_changed_any_event.add (this, &LayoutHandle::layout_changed); mp_layout->cell_name_changed_event.add (this, &LayoutHandle::layout_changed); - mp_layout->properties_repository ().prop_ids_changed_event.add (this, &LayoutHandle::layout_changed); + // @@@ + db::PropertiesRepository::instance ().prop_ids_changed_event.add (this, &LayoutHandle::layout_changed); mp_layout->layer_properties_changed_event.add (this, &LayoutHandle::layout_changed); if (tl::verbosity () >= 30) { diff --git a/src/laybasic/laybasic/layLayerProperties.cc b/src/laybasic/laybasic/layLayerProperties.cc index 6663d43a1..9f1e5c8e6 100644 --- a/src/laybasic/laybasic/layLayerProperties.cc +++ b/src/laybasic/laybasic/layLayerProperties.cc @@ -623,7 +623,7 @@ LayerProperties::do_realize (const LayoutViewBase *view) const // retrieve the property selector, if one is present if (! m_source_real.property_selector ().is_null ()) { - m_inv_prop_set = m_source_real.property_selector ().matching (cv->layout ().properties_repository (), m_prop_set); + m_inv_prop_set = m_source_real.property_selector ().matching (m_prop_set); } // compute the effective transformation in database units diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index bb8298479..f1dcd0a19 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -537,7 +537,8 @@ void LayoutViewBase::update_event_handlers () cellview (i)->layout ().hier_changed_event.add (this, &LayoutViewBase::signal_hier_changed); cellview (i)->layout ().bboxes_changed_event.add (this, &LayoutViewBase::signal_bboxes_from_layer_changed, i); cellview (i)->layout ().dbu_changed_event.add (this, &LayoutViewBase::signal_bboxes_changed); - cellview (i)->layout ().properties_repository ().prop_ids_changed_event.add (this, &LayoutViewBase::signal_prop_ids_changed); + // @@@ + db::PropertiesRepository::instance ().prop_ids_changed_event.add (this, &LayoutViewBase::signal_prop_ids_changed); cellview (i)->layout ().layer_properties_changed_event.add (this, &LayoutViewBase::signal_layer_properties_changed); cellview (i)->layout ().cell_name_changed_event.add (this, &LayoutViewBase::signal_cell_name_changed); cellview (i)->apply_technology_with_sender_event.add (this, &LayoutViewBase::signal_apply_technology); diff --git a/src/laybasic/laybasic/layMarker.cc b/src/laybasic/laybasic/layMarker.cc index 2f08d2289..8f4bccb9c 100644 --- a/src/laybasic/laybasic/layMarker.cc +++ b/src/laybasic/laybasic/layMarker.cc @@ -655,7 +655,7 @@ ShapeMarker::render (const Viewport &vp, ViewObjectCanvas &canvas) } } r.draw (m_shape, t, fill, contour, vertex, text); - r.draw_propstring (m_shape, &ly->properties_repository (), text, t); + r.draw_propstring (m_shape, text, t); } } else { db::CplxTrans t = vp.trans () * trans (); @@ -670,7 +670,7 @@ ShapeMarker::render (const Viewport &vp, ViewObjectCanvas &canvas) } } r.draw (m_shape, t, fill, contour, vertex, text); - r.draw_propstring (m_shape, &ly->properties_repository (), text, t); + r.draw_propstring (m_shape, text, t); } } diff --git a/src/laybasic/laybasic/layParsedLayerSource.cc b/src/laybasic/laybasic/layParsedLayerSource.cc index a8fd79717..ce8a853a8 100644 --- a/src/laybasic/laybasic/layParsedLayerSource.cc +++ b/src/laybasic/laybasic/layParsedLayerSource.cc @@ -49,8 +49,8 @@ public: virtual PropertySelectorBase *clone () const = 0; virtual int compare (const PropertySelectorBase *b) const = 0; virtual unsigned int type_id () const = 0; - virtual bool check (const db::PropertiesRepository &rep, const db::PropertiesRepository::properties_set &set) const = 0; - virtual bool selection (const db::PropertiesRepository &rep, std::set &ids) const = 0; + virtual bool check (const db::PropertiesSet &set) const = 0; + virtual bool selection (std::set &ids) const = 0; }; /** @@ -134,18 +134,18 @@ public: return m_op; } - bool check (const db::PropertiesRepository &rep, const db::PropertiesRepository::properties_set &set) const + bool check (const db::PropertiesSet &set) const { if (m_op == And) { for (std::vector::const_iterator b = m_args.begin (); b != m_args.end (); ++b) { - if (! (*b)->check (rep, set)) { + if (! (*b)->check (set)) { return false; } } return true; } else { for (std::vector::const_iterator b = m_args.begin (); b != m_args.end (); ++b) { - if ((*b)->check (rep, set)) { + if ((*b)->check (set)) { return true; } } @@ -153,13 +153,13 @@ public: } } - bool selection (const db::PropertiesRepository &rep, std::set &ids) const + bool selection (std::set &ids) const { // this algorithm computes the "or" of two sets by using this relationship: a or b or c or .. = !((!a) and (!b) and (!c) and ..) // get the selection of the first operand into ids std::vector::const_iterator b = m_args.begin (); - bool inv = (*b)->selection (rep, ids); + bool inv = (*b)->selection (ids); if (m_op == Or) { inv = !inv; } @@ -168,7 +168,7 @@ public: // get the selection of the next operand into ids2 std::set ids2; - bool inv2 = (*b)->selection (rep, ids2); + bool inv2 = (*b)->selection (ids2); if (m_op == Or) { inv2 = !inv2; } @@ -270,14 +270,14 @@ public: return new PropertySelectorNot (mp_arg->clone ()); } - bool check (const db::PropertiesRepository &rep, const db::PropertiesRepository::properties_set &set) const + bool check (const db::PropertiesSet &set) const { - return ! mp_arg->check (rep, set); + return ! mp_arg->check (set); } - bool selection (const db::PropertiesRepository &rep, std::set &ids) const + bool selection (std::set &ids) const { - return ! mp_arg->selection (rep, ids); + return ! mp_arg->selection (ids); } unsigned int type_id () const @@ -333,23 +333,17 @@ public: return new PropertySelectorEqual (m_name, m_value, m_equal); } - bool check (const db::PropertiesRepository &rep, const db::PropertiesRepository::properties_set &set) const + bool check (const db::PropertiesSet &set) const { - std::pair p = rep.get_id_of_name (m_name); - if (! p.first) { - // name is not known at all. - return false; - } - - db::PropertiesRepository::properties_set::const_iterator i = set.find (p.second); - if (i == set.end ()) { + const tl::Variant &value = set.value (m_name); + if (value.is_nil ()) { // name is not present in the property set return false; } else { // check value - if (m_equal && i->second == m_value) { + if (m_equal && value == m_value) { return true; - } else if (! m_equal && i->second != m_value) { + } else if (! m_equal && value != m_value) { return true; } else { return false; @@ -357,18 +351,10 @@ public: } } - bool selection (const db::PropertiesRepository &rep, std::set &ids) const + bool selection (std::set &ids) const { - std::pair p = rep.get_id_of_name (m_name); - if (! p.first) { - // name is not known at all. - return false; - } - - const db::PropertiesRepository::properties_id_vector &idv = rep.properties_ids_by_name_value (std::make_pair (p.second, m_value)); - for (db::PropertiesRepository::properties_id_vector::const_iterator id = idv.begin (); id != idv.end (); ++id) { - ids.insert (*id); - } + const db::PropertiesRepository::properties_id_set &idv = db::PropertiesRepository::instance ().properties_ids_by_name_value (db::property_names_id (m_name), db::property_values_id (m_value)); + ids.insert (idv.begin (), idv.end ()); return ! m_equal; } @@ -594,22 +580,22 @@ PropertySelector::join (const PropertySelector &d) } bool -PropertySelector::check (const db::PropertiesRepository &rep, db::properties_id_type id) const +PropertySelector::check (db::properties_id_type id) const { if (is_null ()) { return true; } else { - return mp_base->check (rep, rep.properties (id)); + return mp_base->check (db::properties (id)); } } bool -PropertySelector::matching (const db::PropertiesRepository &rep, std::set &ids) const +PropertySelector::matching (std::set &ids) const { if (is_null ()) { return true; } else { - return mp_base->selection (rep, ids); + return mp_base->selection (ids); } } diff --git a/src/laybasic/laybasic/layParsedLayerSource.h b/src/laybasic/laybasic/layParsedLayerSource.h index 398ea2ef5..8f79530c0 100644 --- a/src/laybasic/laybasic/layParsedLayerSource.h +++ b/src/laybasic/laybasic/layParsedLayerSource.h @@ -533,7 +533,7 @@ public: * The given properties set is checked against the selector and "true" is returned * if the selector applies to the given set. */ - bool check (const db::PropertiesRepository &rep, db::properties_id_type id) const; + bool check (db::properties_id_type id) const; /** * @brief Obtain a list of properties ids that satisfy the selection @@ -544,7 +544,7 @@ public: * The return value is true if the ids are to be interpreted inversely (every properties id * matches that is not in the set). This allows optimizing the computation of the set. */ - bool matching (const db::PropertiesRepository &rep, std::set &matching) const; + bool matching (std::set &matching) const; /** * @brief Return true, if the property selector is not set diff --git a/src/laybasic/laybasic/layRedrawThreadWorker.cc b/src/laybasic/laybasic/layRedrawThreadWorker.cc index b16f638b3..a68cde6d6 100644 --- a/src/laybasic/laybasic/layRedrawThreadWorker.cc +++ b/src/laybasic/laybasic/layRedrawThreadWorker.cc @@ -648,7 +648,7 @@ RedrawThreadWorker::draw_cell_properties (bool drawing_context, int level, const lay::CanvasPlane *texts = m_planes[2 + plane_group * (planes_per_layer / 3)]; - r.draw_propstring (prop_id, &mp_layout->properties_repository (), (trans * box).p1 (), texts, trans); + r.draw_propstring (prop_id, (trans * box).p1 (), texts, trans); } static bool @@ -1387,7 +1387,7 @@ RedrawThreadWorker::draw_text_layer (bool drawing_context, db::cell_index_type c test_snapshot (0); - r.draw_propstring (*shape, &mp_layout->properties_repository (), text, trans); + r.draw_propstring (*shape, text, trans); ++shape; --ntexts; diff --git a/src/laybasic/laybasic/layRenderer.cc b/src/laybasic/laybasic/layRenderer.cc index c7d5fd8b4..60c5e8328 100644 --- a/src/laybasic/laybasic/layRenderer.cc +++ b/src/laybasic/laybasic/layRenderer.cc @@ -54,7 +54,7 @@ Renderer::Renderer (unsigned int width, unsigned int height, double resolution, } void -Renderer::draw_propstring (const db::Shape &shape, const db::PropertiesRepository *prep, lay::CanvasPlane *text, const db::CplxTrans &trans) +Renderer::draw_propstring (const db::Shape &shape, lay::CanvasPlane *text, const db::CplxTrans &trans) { if (! shape.has_prop_id ()) { return; @@ -79,19 +79,18 @@ Renderer::draw_propstring (const db::Shape &shape, const db::PropertiesRepositor return; } - if (shape.has_prop_id () && prep && text && (m_draw_properties || m_draw_description_property)) { + if (shape.has_prop_id () && text && (m_draw_properties || m_draw_description_property)) { if (m_draw_properties) { - draw_propstring (shape.prop_id (), prep, dp, text, trans); + draw_propstring (shape.prop_id (), dp, text, trans); } if (m_draw_description_property) { - draw_description_propstring (shape.prop_id (), prep, dp, text, trans); + draw_description_propstring (shape.prop_id (), dp, text, trans); } } } void -Renderer::draw_propstring (db::properties_id_type id, - const db::PropertiesRepository *prep, const db::DPoint &pref, +Renderer::draw_propstring (db::properties_id_type id, const db::DPoint &pref, lay::CanvasPlane *text, const db::CplxTrans &trans) { db::DPoint tp1 (pref + db::DVector (2.0, -2.0)); @@ -100,11 +99,11 @@ Renderer::draw_propstring (db::properties_id_type id, std::string ptext; const char *sep = ""; - const db::PropertiesRepository::properties_set &props = prep->properties (id); - for (db::PropertiesRepository::properties_set::const_iterator p = props.begin (); p != props.end (); ++p) { + auto props = db::properties (id).to_map (); + for (auto p = props.begin (); p != props.end (); ++p) { ptext += sep; sep = "\n"; - ptext += prep->prop_name (p->first).to_string (); + ptext += p->first.to_string (); ptext += ": "; ptext += p->second.to_string (); } @@ -115,21 +114,17 @@ Renderer::draw_propstring (db::properties_id_type id, } void -Renderer::draw_description_propstring (db::properties_id_type id, - const db::PropertiesRepository *prep, const db::DPoint &pref, +Renderer::draw_description_propstring (db::properties_id_type id, const db::DPoint &pref, lay::CanvasPlane *text, const db::CplxTrans &trans) { db::DPoint tp1 (pref + db::DVector (5.0, -5.0)); db::DPoint tp2 (pref + db::DVector (5.0, -5.0 - trans.mag () * m_default_text_size)); - const db::PropertiesRepository::properties_set &props = prep->properties (id); - // TODO: get rid of this const_cast hack (i.e. by a mutable definition inside the properties repository) - db::property_names_id_type dn = (const_cast (prep))->prop_name_id (tl::Variant ("description")); + const db::PropertiesSet &props = db::properties (id); + const tl::Variant &description = props.value (tl::Variant ("description")); + if (! description.is_nil ()) { - db::PropertiesRepository::properties_set::const_iterator dv = props.find (dn); - if (dv != props.end ()) { - - draw (db::DBox (tp1, tp2), dv->second.to_string (), m_font, + draw (db::DBox (tp1, tp2), description.to_string (), m_font, db::HAlignLeft, db::VAlignTop, db::DFTrans (db::DFTrans::r0), 0, 0, 0, text); diff --git a/src/laybasic/laybasic/layRenderer.h b/src/laybasic/laybasic/layRenderer.h index 71a87feea..c9e63ffda 100644 --- a/src/laybasic/laybasic/layRenderer.h +++ b/src/laybasic/laybasic/layRenderer.h @@ -350,7 +350,7 @@ public: * This method draws the properties if "draw_properties" is set to true and/or the * "description" property when "draw_description_property" is set to true. */ - void draw_propstring (const db::Shape &shape, const db::PropertiesRepository *prep, lay::CanvasPlane *text, const db::CplxTrans &trans); + void draw_propstring (const db::Shape &shape, lay::CanvasPlane *text, const db::CplxTrans &trans); /** * @brief Draw a properties string at the given position @@ -358,8 +358,7 @@ public: * The transformation is not used to transform the point (it must be given in micron units * already) but to compute the position of the text, given the text height. */ - void draw_propstring (db::properties_id_type id, - const db::PropertiesRepository *prep, const db::DPoint &pref, + void draw_propstring (db::properties_id_type id, const db::DPoint &pref, lay::CanvasPlane *text, const db::CplxTrans &trans); /** @@ -368,8 +367,7 @@ public: * The transformation is not used to transform the point (it must be given in micron units * already) but to compute the position of the text, given the text height. */ - void draw_description_propstring (db::properties_id_type id, - const db::PropertiesRepository *prep, const db::DPoint &pref, + void draw_description_propstring (db::properties_id_type id, const db::DPoint &pref, lay::CanvasPlane *text, const db::CplxTrans &trans); /** diff --git a/src/laybasic/unit_tests/layParsedLayerSource.cc b/src/laybasic/unit_tests/layParsedLayerSource.cc index 6ecc4e5c7..d283a6f6c 100644 --- a/src/laybasic/unit_tests/layParsedLayerSource.cc +++ b/src/laybasic/unit_tests/layParsedLayerSource.cc @@ -219,95 +219,94 @@ TEST (5) EXPECT_EQ (ps4g < ps4, false); EXPECT_EQ (ps4 < ps4g, true); - db::PropertiesRepository::properties_set ps; - db::PropertiesRepository rep; + db::PropertiesSet ps; std::set ids; bool inv; - ps.insert (std::make_pair (rep.prop_name_id (tl::Variant ("X")), tl::Variant (2l))); - db::properties_id_type id1 = rep.properties_id (ps); - EXPECT_EQ (ps1.property_selector ().check (rep, id1), true); - EXPECT_EQ (ps0.property_selector ().check (rep, id1), true); + ps.insert (tl::Variant ("X"), tl::Variant (2l)); + db::properties_id_type id1 = db::properties_id (ps); + EXPECT_EQ (ps1.property_selector ().check (id1), true); + EXPECT_EQ (ps0.property_selector ().check (id1), true); ids.clear (); - inv = ps1.property_selector ().matching (rep, ids); + inv = ps1.property_selector ().matching (ids); EXPECT_EQ (inv, false); EXPECT_EQ (ids.size (), size_t (1)); EXPECT_EQ (*ids.begin (), id1); ids.clear (); - inv = ps0.property_selector ().matching (rep, ids); + inv = ps0.property_selector ().matching (ids); EXPECT_EQ (inv, true); EXPECT_EQ (ids.size (), size_t (0)); ps.clear (); - ps.insert (std::make_pair (rep.prop_name_id (tl::Variant ("X")), tl::Variant (3l))); - db::properties_id_type id2 = rep.properties_id (ps); - EXPECT_EQ (ps1.property_selector ().check (rep, id2), false); - EXPECT_EQ (ps0.property_selector ().check (rep, id2), true); + ps.insert (tl::Variant ("X"), tl::Variant (3l)); + db::properties_id_type id2 = db::properties_id (ps); + EXPECT_EQ (ps1.property_selector ().check (id2), false); + EXPECT_EQ (ps0.property_selector ().check (id2), true); ids.clear (); - inv = ps1.property_selector ().matching (rep, ids); + inv = ps1.property_selector ().matching (ids); EXPECT_EQ (inv, false); EXPECT_EQ (ids.size (), size_t (1)); EXPECT_EQ (*ids.begin () == id2, false); EXPECT_EQ (*ids.begin (), id1); ids.clear (); - inv = ps0.property_selector ().matching (rep, ids); + inv = ps0.property_selector ().matching (ids); EXPECT_EQ (inv, true); EXPECT_EQ (ids.size (), size_t (0)); ps.clear (); - ps.insert (std::make_pair (rep.prop_name_id (tl::Variant ("X")), tl::Variant (2l))); - ps.insert (std::make_pair (rep.prop_name_id (tl::Variant ("Z")), tl::Variant (4.0))); - db::properties_id_type id3 = rep.properties_id (ps); - EXPECT_EQ (ps2.property_selector ().check (rep, id3), false); - EXPECT_EQ (ps0.property_selector ().check (rep, id3), true); + ps.insert (tl::Variant ("X"), tl::Variant (2l)); + ps.insert (tl::Variant ("Z"), tl::Variant (4.0)); + db::properties_id_type id3 = db::properties_id (ps); + EXPECT_EQ (ps2.property_selector ().check (id3), false); + EXPECT_EQ (ps0.property_selector ().check (id3), true); ids.clear (); - inv = ps2.property_selector ().matching (rep, ids); + inv = ps2.property_selector ().matching (ids); EXPECT_EQ (inv, false); EXPECT_EQ (ids.size (), size_t (1)); EXPECT_EQ (*ids.begin () == id3, false); EXPECT_EQ (*ids.begin (), id1); ids.clear (); - inv = ps0.property_selector ().matching (rep, ids); + inv = ps0.property_selector ().matching (ids); EXPECT_EQ (inv, true); EXPECT_EQ (ids.size (), size_t (0)); ps.clear (); - ps.insert (std::make_pair (rep.prop_name_id (tl::Variant ("X")), tl::Variant (2l))); - ps.insert (std::make_pair (rep.prop_name_id (tl::Variant ("Z")), tl::Variant (6l))); - db::properties_id_type id4 = rep.properties_id (ps); - EXPECT_EQ (ps2.property_selector ().check (rep, id4), true); + ps.insert (tl::Variant ("X"), tl::Variant (2l)); + ps.insert (tl::Variant ("Z"), tl::Variant (6l)); + db::properties_id_type id4 = db::properties_id (ps); + EXPECT_EQ (ps2.property_selector ().check (id4), true); ids.clear (); - inv = ps2.property_selector ().matching (rep, ids); + inv = ps2.property_selector ().matching (ids); EXPECT_EQ (inv, false); EXPECT_EQ (ids.size (), size_t (2)); EXPECT_EQ (*ids.begin (), id1); EXPECT_EQ (*(++ids.begin ()), id4); ps.clear (); - ps.insert (std::make_pair (rep.prop_name_id (tl::Variant ("X")), tl::Variant (2l))); - ps.insert (std::make_pair (rep.prop_name_id (tl::Variant ("Z")), tl::Variant (5.0))); - db::properties_id_type id5 = rep.properties_id (ps); - EXPECT_EQ (ps2.property_selector ().check (rep, id5), true); + ps.insert (tl::Variant ("X"), tl::Variant (2l)); + ps.insert (tl::Variant ("Z"), tl::Variant (5.0)); + db::properties_id_type id5 = db::properties_id (ps); + EXPECT_EQ (ps2.property_selector ().check (id5), true); ids.clear (); - inv = ps2.property_selector ().matching (rep, ids); + inv = ps2.property_selector ().matching (ids); EXPECT_EQ (inv, false); EXPECT_EQ (ids.size (), size_t (3)); EXPECT_EQ (*ids.begin (), id1); EXPECT_EQ (*(++ids.begin ()), id4); EXPECT_EQ (*(++(++ids.begin ())), id5); - EXPECT_EQ (ps2a.property_selector ().check (rep, id5), false); + EXPECT_EQ (ps2a.property_selector ().check (id5), false); ids.clear (); - inv = ps2a.property_selector ().matching (rep, ids); + inv = ps2a.property_selector ().matching (ids); EXPECT_EQ (inv, true); EXPECT_EQ (ids.size (), size_t (3)); EXPECT_EQ (*ids.begin (), id1); EXPECT_EQ (*(++ids.begin ()), id4); EXPECT_EQ (*(++(++ids.begin ())), id5); - EXPECT_EQ (ps2b.property_selector ().check (rep, id5), false); + EXPECT_EQ (ps2b.property_selector ().check (id5), false); ids.clear (); - inv = ps2b.property_selector ().matching (rep, ids); + inv = ps2b.property_selector ().matching (ids); EXPECT_EQ (inv, true); EXPECT_EQ (ids.size (), size_t (3)); EXPECT_EQ (*ids.begin (), id1); @@ -316,36 +315,36 @@ TEST (5) ps.clear (); - db::properties_id_type id6 = rep.properties_id (ps); - EXPECT_EQ (ps2.property_selector ().check (rep, id6), false); + db::properties_id_type id6 = db::properties_id (ps); + EXPECT_EQ (ps2.property_selector ().check (id6), false); ids.clear (); - inv = ps2.property_selector ().matching (rep, ids); + inv = ps2.property_selector ().matching (ids); EXPECT_EQ (inv, false); EXPECT_EQ (ids.size (), size_t (3)); EXPECT_EQ (*ids.begin (), id1); EXPECT_EQ (*(++ids.begin ()), id4); EXPECT_EQ (*(++(++ids.begin ())), id5); - EXPECT_EQ (ps0.property_selector ().check (rep, id6), true); + EXPECT_EQ (ps0.property_selector ().check (id6), true); ids.clear (); - inv = ps0.property_selector ().matching (rep, ids); + inv = ps0.property_selector ().matching (ids); EXPECT_EQ (inv, true); EXPECT_EQ (ids.size (), size_t (0)); - ps.insert (std::make_pair (rep.prop_name_id (tl::Variant ("Z")), tl::Variant (5l))); - db::properties_id_type id7 = rep.properties_id (ps); - EXPECT_EQ (ps4.property_selector ().check (rep, id7), false); + ps.insert (tl::Variant ("Z"), tl::Variant (5l)); + db::properties_id_type id7 = db::properties_id (ps); + EXPECT_EQ (ps4.property_selector ().check (id7), false); ids.clear (); - inv = ps4.property_selector ().matching (rep, ids); + inv = ps4.property_selector ().matching (ids); EXPECT_EQ (inv, false); EXPECT_EQ (ids.size (), size_t (5)); EXPECT_EQ (ids.find (id7) == ids.end (), true); - ps.insert (std::make_pair (rep.prop_name_id (tl::Variant ("X")), tl::Variant (15l))); - db::properties_id_type id8 = rep.properties_id (ps); - EXPECT_EQ (ps4.property_selector ().check (rep, id8), true); + ps.insert (tl::Variant ("X"), tl::Variant (15l)); + db::properties_id_type id8 = db::properties_id (ps); + EXPECT_EQ (ps4.property_selector ().check (id8), true); ids.clear (); - inv = ps4.property_selector ().matching (rep, ids); + inv = ps4.property_selector ().matching (ids); EXPECT_EQ (inv, false); EXPECT_EQ (ids.size (), size_t (6)); EXPECT_EQ (ids.find (id8) != ids.end (), true); diff --git a/src/layui/layui/layDialogs.cc b/src/layui/layui/layDialogs.cc index 0c40c089d..48477ce6d 100644 --- a/src/layui/layui/layDialogs.cc +++ b/src/layui/layui/layDialogs.cc @@ -1065,7 +1065,7 @@ FlattenInstOptionsDialog::exec_dialog (int &levels, bool &prune) // UserPropertiesForm implementation UserPropertiesForm::UserPropertiesForm (QWidget *parent) - : QDialog (parent), m_editable (false), mp_prep (0) + : QDialog (parent), m_editable (false) { setObjectName (QString::fromUtf8 ("user_properties_form")); @@ -1109,10 +1109,10 @@ UserPropertiesForm::~UserPropertiesForm () mp_ui = 0; } -db::PropertiesRepository::properties_set +db::PropertiesSet UserPropertiesForm::get_properties (int tab) { - db::PropertiesRepository::properties_set props; + db::PropertiesSet props; if (tab == 0) { @@ -1131,7 +1131,7 @@ UserPropertiesForm::get_properties (int tab) kex.read (k); kex.expect_end (); - props.insert (std::make_pair (mp_prep->prop_name_id (k), v)); + props.insert (k, v); ++it; @@ -1155,7 +1155,7 @@ UserPropertiesForm::get_properties (int tab) ex.read (v); ex.expect_end (); - props.insert (std::make_pair (mp_prep->prop_name_id (k), v)); + props.insert (k, v); } @@ -1167,19 +1167,21 @@ UserPropertiesForm::get_properties (int tab) } void -UserPropertiesForm::set_properties (const db::PropertiesRepository::properties_set &props) +UserPropertiesForm::set_properties (const db::PropertiesSet &props) { mp_ui->prop_list->clear (); - for (db::PropertiesRepository::properties_set::const_iterator p = props.begin (); p != props.end (); ++p) { + auto map = props.to_map (); + + for (auto p = map.begin (); p != map.end (); ++p) { QTreeWidgetItem *entry = new QTreeWidgetItem (mp_ui->prop_list); - entry->setText (0, tl::to_qstring (mp_prep->prop_name (p->first).to_parsable_string ())); + entry->setText (0, tl::to_qstring (p->first.to_parsable_string ())); entry->setText (1, tl::to_qstring (p->second.to_parsable_string ())); } std::string text; - for (db::PropertiesRepository::properties_set::const_iterator p = props.begin (); p != props.end (); ++p) { - text += mp_prep->prop_name (p->first).to_parsable_string (); + for (auto p = map.begin (); p != map.end (); ++p) { + text += p->first.to_parsable_string (); text += ": "; text += p->second.to_parsable_string (); text += "\n"; @@ -1223,7 +1225,6 @@ UserPropertiesForm::show (LayoutViewBase *view, unsigned int cv_index, db::prope BEGIN_PROTECTED const lay::CellView &cv = view->cellview (cv_index); - mp_prep = &cv->layout ().properties_repository (); m_editable = cv->layout ().is_editable (); if (m_editable) { @@ -1235,7 +1236,7 @@ BEGIN_PROTECTED mp_ui->text_edit->setReadOnly (! m_editable); mp_ui->prop_list->clear (); - const db::PropertiesRepository::properties_set &props = mp_prep->properties (prop_id); + const db::PropertiesSet &props = db::properties (prop_id); set_properties (props); set_meta_info (begin_meta, end_meta, cv->layout ()); @@ -1243,8 +1244,8 @@ BEGIN_PROTECTED if (exec ()) { if (m_editable) { - db::PropertiesRepository::properties_set props = get_properties (mp_ui->mode_tab->currentIndex ()); - prop_id = mp_prep->properties_id (props); + db::PropertiesSet props = get_properties (mp_ui->mode_tab->currentIndex ()); + prop_id = db::properties_id (props); } ret = true; @@ -1253,8 +1254,6 @@ BEGIN_PROTECTED ret = false; } - mp_prep = 0; - END_PROTECTED return ret; diff --git a/src/layui/layui/layDialogs.h b/src/layui/layui/layDialogs.h index 88678d289..3fc9f2318 100644 --- a/src/layui/layui/layDialogs.h +++ b/src/layui/layui/layDialogs.h @@ -434,13 +434,12 @@ public slots: void tab_changed (int); private: - db::PropertiesRepository::properties_set get_properties (int tab); - void set_properties (const db::PropertiesRepository::properties_set &props); + db::PropertiesSet get_properties (int tab); + void set_properties (const db::PropertiesSet &props); void set_meta_info (db::Layout::meta_info_iterator begin_meta, db::Layout::meta_info_iterator end_meta, const db::Layout &layout); void accept (); bool m_editable; - db::PropertiesRepository *mp_prep; Ui::UserPropertiesForm *mp_ui; db::Layout::meta_info_iterator m_begin_meta, m_end_meta; std::unique_ptr mp_hl_attributes, mp_hl_basic_attributes; diff --git a/src/layui/layui/layLayoutViewFunctions.cc b/src/layui/layui/layLayoutViewFunctions.cc index 20ec394b2..c8e4caf96 100644 --- a/src/layui/layui/layLayoutViewFunctions.cc +++ b/src/layui/layui/layLayoutViewFunctions.cc @@ -1665,9 +1665,8 @@ LayoutViewFunctions::cm_copy_layer () if (! same_layout) { // flat mode (different layouts) - db::PropertyMapper pm (&view ()->cellview (m_copy_cvr)->layout (), &view ()->cellview (m_copy_cva)->layout ()); for (db::RecursiveShapeIterator si (view ()->cellview (m_copy_cva)->layout (), *view ()->cellview (m_copy_cva).cell (), m_copy_layera); ! si.at_end (); ++si) { - target_cell.shapes (m_copy_layerr).insert (*si, si.trans (), pm); + target_cell.shapes (m_copy_layerr).insert_transformed (*si, si.trans ()); } } else { @@ -1709,14 +1708,6 @@ LayoutViewFunctions::cm_copy_layer () // current cell only mode: identical cell cell.copy (m_copy_layera, m_copy_layerr); - } else if (! same_layout) { - - // current cell only mode (different layouts) - db::PropertyMapper pm (&view ()->cellview (m_copy_cvr)->layout (), &view ()->cellview (m_copy_cva)->layout ()); - for (db::Shapes::shape_iterator si = view ()->cellview (m_copy_cva).cell ()->shapes (m_copy_layera).begin (db::ShapeIterator::All); ! si.at_end (); ++si) { - target_cell.shapes (m_copy_layerr).insert (*si, pm); - } - } else { // current cell only mode (same layouts, but different cells) diff --git a/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.cc b/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.cc index 5d0b6ace1..c92e55c90 100644 --- a/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.cc +++ b/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.cc @@ -67,23 +67,23 @@ public: void bbox_differs (const db::Box &ba, const db::Box &bb); void begin_cell (const std::string &cellname, db::cell_index_type cia, db::cell_index_type cib); void begin_inst_differences (); - void instances_in_a (const std::vector &insts_a, const std::vector &cell_names, const db::PropertiesRepository &props); - void instances_in_b (const std::vector &insts_b, const std::vector &cell_names, const db::PropertiesRepository &props); + void instances_in_a (const std::vector &insts_a, const std::vector &cell_names); + void instances_in_b (const std::vector &insts_b, const std::vector &cell_names); void instances_in_a_only (const std::vector &anotb, const db::Layout &a); void instances_in_b_only (const std::vector &bnota, const db::Layout &b); void begin_layer (const db::LayerProperties &layer, unsigned int layer_index_a, bool is_valid_a, unsigned int layer_index_b, bool is_valid_b); void end_layer (); void per_layer_bbox_differs (const db::Box &ba, const db::Box &bb); void begin_polygon_differences (); - void detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b); + void detailed_diff (const std::vector > &a, const std::vector > &b); void begin_path_differences (); - void detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b); + void detailed_diff (const std::vector > &a, const std::vector > &b); void begin_box_differences (); - void detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b); + void detailed_diff (const std::vector > &a, const std::vector > &b); void begin_edge_differences (); - void detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b); + void detailed_diff (const std::vector > &a, const std::vector > &b); void begin_text_differences (); - void detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b); + void detailed_diff (const std::vector > &a, const std::vector > &b); private: const db::Layout *mp_layout_a; @@ -537,9 +537,9 @@ RdbDifferenceReceiver::shape_diffs (const db::PropertiesRepository &pr, const st } void -RdbDifferenceReceiver::detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b) +RdbDifferenceReceiver::detailed_diff (const std::vector > &a, const std::vector > &b) { - shape_diffs (pr, a, b); + shape_diffs (a, b); } void @@ -549,9 +549,9 @@ RdbDifferenceReceiver::begin_path_differences () } void -RdbDifferenceReceiver::detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b) +RdbDifferenceReceiver::detailed_diff (const std::vector > &a, const std::vector > &b) { - shape_diffs (pr, a, b); + shape_diffs (a, b); } void @@ -561,9 +561,9 @@ RdbDifferenceReceiver::begin_box_differences () } void -RdbDifferenceReceiver::detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b) +RdbDifferenceReceiver::detailed_diff (const std::vector > &a, const std::vector > &b) { - shape_diffs (pr, a, b); + shape_diffs (a, b); } void @@ -573,9 +573,9 @@ RdbDifferenceReceiver::begin_edge_differences () } void -RdbDifferenceReceiver::detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b) +RdbDifferenceReceiver::detailed_diff (const std::vector > &a, const std::vector > &b) { - shape_diffs (pr, a, b); + shape_diffs (a, b); } void @@ -585,9 +585,9 @@ RdbDifferenceReceiver::begin_text_differences () } void -RdbDifferenceReceiver::detailed_diff (const db::PropertiesRepository &pr, const std::vector > &a, const std::vector > &b) +RdbDifferenceReceiver::detailed_diff (const std::vector > &a, const std::vector > &b) { - shape_diffs (pr, a, b); + shape_diffs (a, b); } // ------------------------------------------------------------------------------ diff --git a/src/rdb/rdb/rdbUtils.cc b/src/rdb/rdb/rdbUtils.cc index 6b17dd753..393f56174 100644 --- a/src/rdb/rdb/rdbUtils.cc +++ b/src/rdb/rdb/rdbUtils.cc @@ -306,10 +306,10 @@ void create_item_from_shape (rdb::Database *db, rdb::id_type cell_id, rdb::id_ty const db::Layout *layout = shape.shapes ()->cell ()->layout (); if (layout) { - auto ps = layout->properties_repository ().properties (shape.prop_id ()); + auto ps = db::properties (shape.prop_id ()); for (auto i = ps.begin (); i != ps.end (); ++i) { - id_type tag_id = db->tags ().tag (layout->properties_repository ().prop_name (i->first).to_string (), true /*user tag*/).id (); - add_item_value (item, i->second, trans, tag_id); + id_type tag_id = db->tags ().tag (db::property_name (i->first).to_string (), true /*user tag*/).id (); + add_item_value (item, db::property_value (i->second), trans, tag_id); } }