Maintaining data_id during modification of layer inside device extractor -> this way, the name-to-layer link is maintained inside the DRC engine

This commit is contained in:
Matthias Koefferlein 2026-05-07 00:09:16 +02:00
parent 9630bff240
commit 838b2409b0
10 changed files with 49 additions and 18 deletions

View File

@ -107,7 +107,7 @@ void
EdgePairs::convert_to_deep (const db::DeepLayer &layer)
{
tl_assert (mp_delegate->deep () == 0);
set_delegate (new db::DeepEdgePairs (layer));
set_delegate (copy_data_id (new db::DeepEdgePairs (layer)));
}
void

View File

@ -118,7 +118,7 @@ void
Edges::convert_to_deep (const db::DeepLayer &layer)
{
tl_assert (mp_delegate->deep () == 0);
set_delegate (new db::DeepEdges (layer));
set_delegate (copy_data_id (new db::DeepEdges (layer)));
}
const db::RecursiveShapeIterator &

View File

@ -136,7 +136,7 @@ void
Region::convert_to_deep (const db::DeepLayer &layer)
{
tl_assert (mp_delegate->deep () == 0);
set_delegate (new db::DeepRegion (layer));
set_delegate (copy_data_id (new db::DeepRegion (layer)));
}
void

View File

@ -75,7 +75,12 @@ class DB_PUBLIC ShapeCollectionDelegateBase
: public tl::UniqueId
{
public:
ShapeCollectionDelegateBase () { }
ShapeCollectionDelegateBase ()
: m_data_id (tl::id_of (this))
{
// .. nothing yet ..
}
virtual ~ShapeCollectionDelegateBase () { }
virtual DeepShapeCollectionDelegateBase *deep () { return 0; }
@ -88,6 +93,22 @@ public:
apply_property_translator (db::PropertiesTranslator::make_remove_all ());
}
}
tl::id_type data_id () const
{
return m_data_id;
}
private:
friend class ShapeCollection;
tl::id_type m_data_id;
// used for conversion to deep
void set_data_id (tl::id_type data_id)
{
m_data_id = data_id;
}
};
/**
@ -116,6 +137,14 @@ public:
* delivered by "properties_repository".
*/
void apply_property_translator (const db::PropertiesTranslator &pt);
protected:
template <class Delegate>
Delegate *copy_data_id (Delegate *dlg)
{
dlg->set_data_id (get_delegate ()->data_id ());
return dlg;
}
};
}

View File

@ -103,7 +103,7 @@ void
Texts::convert_to_deep (const db::DeepLayer &layer)
{
tl_assert (mp_delegate->deep () == 0);
set_delegate (new db::DeepTexts (layer));
set_delegate (copy_data_id (new db::DeepTexts (layer)));
}
void

View File

@ -630,9 +630,9 @@ static bool is_deep (const db::EdgePairs *ep)
return dynamic_cast<const db::DeepEdgePairs *> (ep->delegate ()) != 0;
}
static size_t id (const db::EdgePairs *ep)
static size_t data_id (const db::EdgePairs *ep)
{
return tl::id_of (ep->delegate ());
return ep->delegate ()->data_id ();
}
static db::EdgePairs filtered (const db::EdgePairs *r, const gsi::EdgePairFilterBase *f)
@ -1114,7 +1114,7 @@ Class<db::EdgePairs> decl_EdgePairs (decl_dbShapeCollection, "db", "EdgePairs",
"\n"
"This method has been added in version 0.26."
) +
method_ext ("data_id", &id,
method_ext ("data_id", &data_id,
"@brief Returns the data ID (a unique identifier for the underlying data storage)\n"
"\n"
"This method has been added in version 0.26."

View File

@ -892,9 +892,9 @@ static db::Edges *new_texts_as_dots2 (const db::RecursiveShapeIterator &si, db::
return new db::Edges (db::Region (si).texts_as_dots (pat, pattern, dss));
}
static size_t id (const db::Edges *e)
static size_t data_id (const db::Edges *e)
{
return tl::id_of (e->delegate ());
return e->delegate ()->data_id ();
}
static std::vector<db::Edges> andnot_with_edges (const db::Edges *r, const db::Edges &other)
@ -2572,7 +2572,7 @@ Class<db::Edges> decl_Edges (decl_dbShapeCollection, "db", "Edges",
"\n"
"This method has been added in version 0.26."
) +
method_ext ("data_id", &id,
method_ext ("data_id", &data_id,
"@brief Returns the data ID (a unique identifier for the underlying data storage)\n"
"\n"
"This method has been added in version 0.26."

View File

@ -1288,9 +1288,9 @@ static bool is_deep (const db::Region *region)
return dynamic_cast<const db::DeepRegion *> (region->delegate ()) != 0;
}
static size_t id (const db::Region *r)
static size_t data_id (const db::Region *r)
{
return tl::id_of (r->delegate ());
return r->delegate ()->data_id ();
}
@ -4214,7 +4214,7 @@ Class<db::Region> decl_Region (decl_dbShapeCollection, "db", "Region",
"\n"
"This method has been added in version 0.26."
) +
method_ext ("data_id", &id,
method_ext ("data_id", &data_id,
"@brief Returns the data ID (a unique identifier for the underlying data storage)\n"
"\n"
"This method has been added in version 0.26."

View File

@ -477,9 +477,9 @@ static bool is_deep (const db::Texts *t)
return dynamic_cast<const db::DeepTexts *> (t->delegate ()) != 0;
}
static size_t id (const db::Texts *t)
static size_t data_id (const db::Texts *t)
{
return tl::id_of (t->delegate ());
return t->delegate ()->data_id ();
}
static db::Texts filtered (const db::Texts *r, const gsi::TextFilterBase *f)
@ -686,7 +686,7 @@ Class<db::Texts> decl_Texts (decl_dbShapeCollection, "db", "Texts",
method_ext ("is_deep?", &is_deep,
"@brief Returns true if the edge pair collection is a deep (hierarchical) one\n"
) +
method_ext ("data_id", &id,
method_ext ("data_id", &data_id,
"@brief Returns the data ID (a unique identifier for the underlying data storage)\n"
) +
method ("+|join", &db::Texts::operator+, gsi::arg ("other"),

View File

@ -323,7 +323,9 @@ module DRC
#
# If layers are not named, they will be given a name made from the
# \name_prefix and an incremental number when the layer is used for the
# first time.
# first time. As the default name prefix is "l", you may can name conflicts
# with auto-named layers, if you register explicit layer names like "l5".
# Consider changing the name prefix in that case to some prefix you are not using.
#
# \name can only be used once on a layer and the layer names must be
# unique (not taken by another layer).