WIP: property management for flat shape containers

This commit is contained in:
Matthias Koefferlein 2023-01-15 13:34:47 +01:00
parent 33b5723068
commit 9f633b813d
53 changed files with 389 additions and 146 deletions

View File

@ -260,7 +260,7 @@ AsIfFlatEdgePairs::second_edges () const
EdgePairsDelegate *
AsIfFlatEdgePairs::add (const EdgePairs &other) const
{
FlatEdgePairs *other_flat = dynamic_cast<FlatEdgePairs *> (other.delegate ());
const FlatEdgePairs *other_flat = dynamic_cast<const FlatEdgePairs *> (other.delegate ());
if (other_flat) {
std::unique_ptr<FlatEdgePairs> new_edge_pairs (new FlatEdgePairs (*other_flat));

View File

@ -876,7 +876,7 @@ AsIfFlatEdges::edge_region_op (const Region &other, db::EdgePolygonOp::mode_t mo
EdgesDelegate *
AsIfFlatEdges::add (const Edges &other) const
{
FlatEdges *other_flat = dynamic_cast<FlatEdges *> (other.delegate ());
const FlatEdges *other_flat = dynamic_cast<const FlatEdges *> (other.delegate ());
if (other_flat) {
std::unique_ptr<FlatEdges> new_edges (new FlatEdges (*other_flat));

View File

@ -1728,7 +1728,7 @@ AsIfFlatRegion::or_with (const Region &other) const
RegionDelegate *
AsIfFlatRegion::add (const Region &other) const
{
FlatRegion *other_flat = dynamic_cast<FlatRegion *> (other.delegate ());
const FlatRegion *other_flat = dynamic_cast<const FlatRegion *> (other.delegate ());
if (other_flat) {
std::unique_ptr<FlatRegion> new_region (new FlatRegion (*other_flat));

View File

@ -216,7 +216,7 @@ AsIfFlatTexts::edges () const
TextsDelegate *
AsIfFlatTexts::add (const Texts &other) const
{
FlatTexts *other_flat = dynamic_cast<FlatTexts *> (other.delegate ());
const FlatTexts *other_flat = dynamic_cast<const FlatTexts *> (other.delegate ());
if (other_flat) {
std::unique_ptr<FlatTexts> new_texts (new FlatTexts (*other_flat));

View File

@ -314,9 +314,14 @@ const db::RecursiveShapeIterator *DeepEdgePairs::iter () const
return 0;
}
const db::Layout *DeepEdgePairs::layout () const
db::PropertiesRepository *DeepEdgePairs::properties_repository ()
{
return &deep_layer ().layout ();
return &deep_layer ().layout ().properties_repository ();
}
const db::PropertiesRepository *DeepEdgePairs::properties_repository () const
{
return &deep_layer ().layout ().properties_repository ();
}
EdgePairsDelegate *

View File

@ -72,7 +72,8 @@ public:
virtual const db::EdgePair *nth (size_t n) const;
virtual bool has_valid_edge_pairs () const;
virtual const db::RecursiveShapeIterator *iter () const;
virtual const db::Layout *layout () const;
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;

View File

@ -448,10 +448,14 @@ DeepEdges::iter () const
return 0;
}
const db::Layout *
DeepEdges::layout () const
db::PropertiesRepository *DeepEdges::properties_repository ()
{
return &deep_layer ().layout ();
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

View File

@ -80,7 +80,8 @@ public:
virtual bool has_valid_merged_edges () const;
virtual const db::RecursiveShapeIterator *iter () const;
virtual const db::Layout *layout () const;
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;

View File

@ -475,10 +475,14 @@ DeepRegion::iter () const
return 0;
}
const db::Layout *
DeepRegion::layout () const
db::PropertiesRepository *DeepRegion::properties_repository ()
{
return &deep_layer ().layout ();
return &deep_layer ().layout ().properties_repository ();
}
const db::PropertiesRepository *DeepRegion::properties_repository () const
{
return &deep_layer ().layout ().properties_repository ();
}
bool

View File

@ -79,7 +79,8 @@ public:
virtual bool has_valid_merged_polygons () const;
virtual const db::RecursiveShapeIterator *iter () const;
virtual const db::Layout *layout () const;
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;

View File

@ -50,7 +50,7 @@ DeepLayer::DeepLayer ()
DeepLayer::DeepLayer (const Region &region)
: mp_store (), m_layout (0), m_layer (0)
{
const db::DeepRegion *dr = dynamic_cast<db::DeepRegion *> (region.delegate ());
const db::DeepRegion *dr = dynamic_cast<const db::DeepRegion *> (region.delegate ());
tl_assert (dr != 0);
*this = dr->deep_layer ();
}
@ -58,7 +58,7 @@ DeepLayer::DeepLayer (const Region &region)
DeepLayer::DeepLayer (const Texts &texts)
: mp_store (), m_layout (0), m_layer (0)
{
const db::DeepTexts *dr = dynamic_cast<db::DeepTexts *> (texts.delegate ());
const db::DeepTexts *dr = dynamic_cast<const db::DeepTexts *> (texts.delegate ());
tl_assert (dr != 0);
*this = dr->deep_layer ();
}
@ -66,7 +66,7 @@ DeepLayer::DeepLayer (const Texts &texts)
DeepLayer::DeepLayer (const Edges &edges)
: mp_store (), m_layout (0), m_layer (0)
{
const db::DeepEdges *dr = dynamic_cast<db::DeepEdges *> (edges.delegate ());
const db::DeepEdges *dr = dynamic_cast<const db::DeepEdges *> (edges.delegate ());
tl_assert (dr != 0);
*this = dr->deep_layer ();
}
@ -74,7 +74,7 @@ DeepLayer::DeepLayer (const Edges &edges)
DeepLayer::DeepLayer (const EdgePairs &edge_pairs)
: mp_store (), m_layout (0), m_layer (0)
{
const db::DeepEdgePairs *dr = dynamic_cast<db::DeepEdgePairs *> (edge_pairs.delegate ());
const db::DeepEdgePairs *dr = dynamic_cast<const db::DeepEdgePairs *> (edge_pairs.delegate ());
tl_assert (dr != 0);
*this = dr->deep_layer ();
}

View File

@ -338,9 +338,14 @@ const db::RecursiveShapeIterator *DeepTexts::iter () const
return 0;
}
const db::Layout *DeepTexts::layout () const
db::PropertiesRepository *DeepTexts::properties_repository ()
{
return &deep_layer ().layout ();
return &deep_layer ().layout ().properties_repository ();
}
const db::PropertiesRepository *DeepTexts::properties_repository () const
{
return &deep_layer ().layout ().properties_repository ();
}
TextsDelegate *

View File

@ -73,7 +73,8 @@ public:
virtual const db::Text *nth (size_t n) const;
virtual bool has_valid_texts () const;
virtual const db::RecursiveShapeIterator *iter () const;
virtual const db::Layout *layout () const;
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;

View File

@ -153,10 +153,20 @@ EdgePairs::iter () const
return *(i ? i : &def_iter);
}
const db::Layout *
EdgePairs::layout () const
const db::PropertiesRepository &
EdgePairs::properties_repository () const
{
return mp_delegate ? mp_delegate->layout () : 0;
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;
}
void EdgePairs::processed (Region &output, const EdgePairToPolygonProcessorBase &filter) const

View File

@ -251,7 +251,15 @@ public:
/**
* @brief Gets the underlying delegate object
*/
EdgePairsDelegate *delegate () const
const EdgePairsDelegate *delegate () const
{
return mp_delegate;
}
/**
* @brief Gets the underlying delegate object
*/
EdgePairsDelegate *delegate ()
{
return mp_delegate;
}
@ -499,12 +507,18 @@ public:
const db::RecursiveShapeIterator &iter () const;
/**
* @brief Gets the source layout for the polygons
* @brief Gets the property repository
*
* Use this layout to decode property IDs. This layout may be null, in which case the
* source layout is outside the scope of this region.
* Use this object to decode property IDs.
*/
const db::Layout *layout () const;
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

View File

@ -205,7 +205,8 @@ public:
virtual bool has_valid_edge_pairs () const = 0;
virtual const db::RecursiveShapeIterator *iter () const = 0;
virtual const db::Layout *layout () const = 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;

View File

@ -112,10 +112,20 @@ Edges::iter () const
return *(i ? i : &def_iter);
}
const db::Layout *
Edges::layout () const
const db::PropertiesRepository &
Edges::properties_repository () const
{
return mp_delegate ? mp_delegate->layout () : 0;
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

View File

@ -269,7 +269,15 @@ public:
/**
* @brief Gets the underlying delegate object
*/
EdgesDelegate *delegate () const
const EdgesDelegate *delegate () const
{
return mp_delegate;
}
/**
* @brief Gets the underlying delegate object
*/
EdgesDelegate *delegate ()
{
return mp_delegate;
}
@ -1471,12 +1479,18 @@ public:
const db::RecursiveShapeIterator &iter () const;
/**
* @brief Gets the source layout for the polygons
* @brief Gets the property repository
*
* Use this layout to decode property IDs. This layout may be null, in which case the
* source layout is outside the scope of this region.
* Use this object to decode property IDs.
*/
const db::Layout *layout () const;
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

View File

@ -340,7 +340,8 @@ public:
virtual bool has_valid_merged_edges () const = 0;
virtual const db::RecursiveShapeIterator *iter () const = 0;
virtual const db::Layout *layout () const = 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;

View File

@ -73,7 +73,8 @@ public:
virtual bool has_valid_edge_pairs () const { return true; }
virtual const db::RecursiveShapeIterator *iter () const { return 0; }
virtual const db::Layout *layout () const { return 0; }
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;

View File

@ -122,7 +122,8 @@ public:
virtual bool has_valid_merged_edges () const { return true; }
virtual const db::RecursiveShapeIterator *iter () const { return 0; }
virtual const db::Layout *layout () const { return 0; }
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;

View File

@ -141,7 +141,8 @@ public:
virtual db::properties_id_type nth_prop_id (size_t) const { tl_assert (false); }
virtual const db::RecursiveShapeIterator *iter () const { return 0; }
virtual const db::Layout *layout () const { return 0; }
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;

View File

@ -71,7 +71,8 @@ public:
virtual bool has_valid_texts () const { return true; }
virtual const db::RecursiveShapeIterator *iter () const { return 0; }
virtual const db::Layout *layout () const { return 0; }
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;

View File

@ -32,7 +32,7 @@ namespace db
// FlatEdgePairs implementation
FlatEdgePairs::FlatEdgePairs ()
: MutableEdgePairs (), mp_edge_pairs (new db::Shapes (false))
: MutableEdgePairs (), mp_edge_pairs (new db::Shapes (false)), mp_properties_repository (new db::PropertiesRepository ())
{
// .. nothing yet ..
}
@ -43,13 +43,13 @@ FlatEdgePairs::~FlatEdgePairs ()
}
FlatEdgePairs::FlatEdgePairs (const FlatEdgePairs &other)
: MutableEdgePairs (other), mp_edge_pairs (other.mp_edge_pairs)
: MutableEdgePairs (other), mp_edge_pairs (other.mp_edge_pairs), mp_properties_repository (other.mp_properties_repository)
{
// .. nothing yet ..
}
FlatEdgePairs::FlatEdgePairs (const db::Shapes &edge_pairs)
: MutableEdgePairs (), mp_edge_pairs (new db::Shapes (edge_pairs))
: MutableEdgePairs (), mp_edge_pairs (new db::Shapes (edge_pairs)), mp_properties_repository (new db::PropertiesRepository ())
{
// .. nothing yet ..
}
@ -121,7 +121,7 @@ EdgePairsDelegate *FlatEdgePairs::add (const EdgePairs &other) const
std::unique_ptr<FlatEdgePairs> new_edge_pairs (new FlatEdgePairs (*this));
new_edge_pairs->invalidate_cache ();
FlatEdgePairs *other_flat = dynamic_cast<FlatEdgePairs *> (other.delegate ());
const FlatEdgePairs *other_flat = dynamic_cast<const FlatEdgePairs *> (other.delegate ());
if (other_flat) {
new_edge_pairs->raw_edge_pairs ().insert (other_flat->raw_edge_pairs ().get_layer<db::EdgePair, db::unstable_layer_tag> ().begin (), other_flat->raw_edge_pairs ().get_layer<db::EdgePair, db::unstable_layer_tag> ().end ());
@ -150,7 +150,7 @@ EdgePairsDelegate *FlatEdgePairs::add_in_place (const EdgePairs &other)
db::Shapes &ep = *mp_edge_pairs;
FlatEdgePairs *other_flat = dynamic_cast<FlatEdgePairs *> (other.delegate ());
const FlatEdgePairs *other_flat = dynamic_cast<const FlatEdgePairs *> (other.delegate ());
if (other_flat) {
ep.insert (other_flat->raw_edge_pairs ().get_layer<db::EdgePair, db::unstable_layer_tag> ().begin (), other_flat->raw_edge_pairs ().get_layer<db::EdgePair, db::unstable_layer_tag> ().end ());
@ -188,9 +188,14 @@ const db::RecursiveShapeIterator *FlatEdgePairs::iter () const
return 0;
}
const db::Layout *FlatEdgePairs::layout () const
db::PropertiesRepository *FlatEdgePairs::properties_repository ()
{
return 0;
return mp_properties_repository.get_non_const ();
}
const db::PropertiesRepository *FlatEdgePairs::properties_repository () const
{
return mp_properties_repository.get_const ();
}
void

View File

@ -78,7 +78,8 @@ public:
virtual bool has_valid_edge_pairs () const;
virtual const db::RecursiveShapeIterator *iter () const;
virtual const db::Layout *layout () const;
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;
@ -120,6 +121,7 @@ private:
FlatEdgePairs &operator= (const FlatEdgePairs &other);
mutable tl::copy_on_write_ptr<db::Shapes> mp_edge_pairs;
mutable tl::copy_on_write_ptr<db::PropertiesRepository> mp_properties_repository;
template <class Trans>
void transform_generic (const Trans &trans)

View File

@ -33,7 +33,7 @@ namespace db
// FlatEdges implementation
FlatEdges::FlatEdges ()
: MutableEdges (), mp_edges (new db::Shapes (false)), mp_merged_edges (new db::Shapes (false))
: MutableEdges (), mp_edges (new db::Shapes (false)), mp_merged_edges (new db::Shapes (false)), mp_properties_repository (new db::PropertiesRepository ())
{
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)
: MutableEdges (other), mp_edges (other.mp_edges), mp_merged_edges (other.mp_merged_edges), mp_properties_repository (other.mp_properties_repository)
{
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))
: MutableEdges (), mp_edges (new db::Shapes (edges)), mp_merged_edges (new db::Shapes (false)), mp_properties_repository (new db::PropertiesRepository ())
{
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))
: MutableEdges (), mp_edges (new db::Shapes (false)), mp_merged_edges (new db::Shapes (false)), mp_properties_repository (new db::PropertiesRepository ())
{
init ();
@ -245,7 +245,7 @@ EdgesDelegate *FlatEdges::add (const Edges &other) const
new_region->invalidate_cache ();
new_region->set_is_merged (false);
FlatEdges *other_flat = dynamic_cast<FlatEdges *> (other.delegate ());
const FlatEdges *other_flat = dynamic_cast<const FlatEdges *> (other.delegate ());
if (other_flat) {
new_region->raw_edges ().insert (other_flat->raw_edges ().get_layer<db::Edge, db::unstable_layer_tag> ().begin (), other_flat->raw_edges ().get_layer<db::Edge, db::unstable_layer_tag> ().end ());
@ -275,7 +275,7 @@ EdgesDelegate *FlatEdges::add_in_place (const Edges &other)
db::Shapes &e = *mp_edges;
FlatEdges *other_flat = dynamic_cast<FlatEdges *> (other.delegate ());
const FlatEdges *other_flat = dynamic_cast<const FlatEdges *> (other.delegate ());
if (other_flat) {
e.insert (other_flat->raw_edges ().get_layer<db::Edge, db::unstable_layer_tag> ().begin (), other_flat->raw_edges ().get_layer<db::Edge, db::unstable_layer_tag> ().end ());
@ -318,9 +318,14 @@ const db::RecursiveShapeIterator *FlatEdges::iter () const
return 0;
}
const db::Layout *FlatEdges::layout () const
db::PropertiesRepository *FlatEdges::properties_repository ()
{
return 0;
return mp_properties_repository.get_non_const ();
}
const db::PropertiesRepository *FlatEdges::properties_repository () const
{
return mp_properties_repository.get_const ();
}
void

View File

@ -91,7 +91,8 @@ public:
virtual bool has_valid_merged_edges () const;
virtual const db::RecursiveShapeIterator *iter () const;
virtual const db::Layout *layout () const;
virtual db::PropertiesRepository *properties_repository ();
virtual const db::PropertiesRepository *properties_repository () const;
void do_insert (const db::Edge &edge);
@ -133,6 +134,7 @@ private:
mutable tl::copy_on_write_ptr<db::Shapes> mp_edges;
mutable tl::copy_on_write_ptr<db::Shapes> mp_merged_edges;
mutable bool m_merged_edges_valid;
mutable tl::copy_on_write_ptr<db::PropertiesRepository> mp_properties_repository;
void init ();
void ensure_merged_edges_valid () const;

View File

@ -34,7 +34,7 @@ namespace db
// FlatRegion implementation
FlatRegion::FlatRegion ()
: MutableRegion (), mp_polygons (new db::Shapes (false)), mp_merged_polygons (new db::Shapes (false))
: MutableRegion (), mp_polygons (new db::Shapes (false)), mp_merged_polygons (new db::Shapes (false)), mp_properties_repository (new db::PropertiesRepository ())
{
init ();
}
@ -45,7 +45,7 @@ FlatRegion::~FlatRegion ()
}
FlatRegion::FlatRegion (const FlatRegion &other)
: MutableRegion (other), mp_polygons (other.mp_polygons), mp_merged_polygons (other.mp_merged_polygons)
: MutableRegion (other), mp_polygons (other.mp_polygons), mp_merged_polygons (other.mp_merged_polygons), mp_properties_repository (other.mp_properties_repository)
{
init ();
@ -54,7 +54,7 @@ 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))
: MutableRegion (), mp_polygons (new db::Shapes (polygons)), mp_merged_polygons (new db::Shapes (false)), mp_properties_repository (new db::PropertiesRepository ())
{
init ();
@ -62,7 +62,7 @@ FlatRegion::FlatRegion (const db::Shapes &polygons, bool is_merged)
}
FlatRegion::FlatRegion (bool is_merged)
: MutableRegion (), mp_polygons (new db::Shapes (false)), mp_merged_polygons (new db::Shapes (false))
: MutableRegion (), mp_polygons (new db::Shapes (false)), mp_merged_polygons (new db::Shapes (false)), mp_properties_repository (new db::PropertiesRepository ())
{
init ();
@ -285,7 +285,7 @@ RegionDelegate *FlatRegion::add (const Region &other) const
new_region->invalidate_cache ();
new_region->set_is_merged (false);
FlatRegion *other_flat = dynamic_cast<FlatRegion *> (other.delegate ());
const FlatRegion *other_flat = dynamic_cast<const FlatRegion *> (other.delegate ());
if (other_flat) {
new_region->raw_polygons ().insert (other_flat->raw_polygons ().get_layer<db::Polygon, db::unstable_layer_tag> ().begin (), other_flat->raw_polygons ().get_layer<db::Polygon, db::unstable_layer_tag> ().end ());
@ -315,7 +315,7 @@ RegionDelegate *FlatRegion::add_in_place (const Region &other)
db::Shapes &polygons = *mp_polygons;
FlatRegion *other_flat = dynamic_cast<FlatRegion *> (other.delegate ());
const FlatRegion *other_flat = dynamic_cast<const FlatRegion *> (other.delegate ());
if (other_flat) {
polygons.insert (other_flat->raw_polygons ().get_layer<db::Polygon, db::unstable_layer_tag> ().begin (), other_flat->raw_polygons ().get_layer<db::Polygon, db::unstable_layer_tag> ().end ());
@ -397,9 +397,14 @@ const db::RecursiveShapeIterator *FlatRegion::iter () const
return 0;
}
const db::Layout *FlatRegion::layout () const
db::PropertiesRepository *FlatRegion::properties_repository ()
{
return 0;
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

View File

@ -97,7 +97,8 @@ public:
virtual bool has_valid_merged_polygons () const;
virtual const db::RecursiveShapeIterator *iter () const;
virtual const db::Layout *layout () const;
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);
@ -143,6 +144,7 @@ private:
mutable tl::copy_on_write_ptr<db::Shapes> mp_polygons;
mutable tl::copy_on_write_ptr<db::Shapes> mp_merged_polygons;
mutable bool m_merged_polygons_valid;
mutable tl::copy_on_write_ptr<db::PropertiesRepository> mp_properties_repository;
void init ();
void ensure_merged_polygons_valid () const;

View File

@ -32,7 +32,7 @@ namespace db
// FlatTexts implementation
FlatTexts::FlatTexts ()
: MutableTexts (), mp_texts (new db::Shapes (false))
: MutableTexts (), mp_texts (new db::Shapes (false)), mp_properties_repository (new db::PropertiesRepository ())
{
// .. nothing yet ..
}
@ -43,13 +43,13 @@ FlatTexts::~FlatTexts ()
}
FlatTexts::FlatTexts (const FlatTexts &other)
: MutableTexts (other), mp_texts (other.mp_texts)
: MutableTexts (other), mp_texts (other.mp_texts), mp_properties_repository (other.mp_properties_repository)
{
// .. nothing yet ..
}
FlatTexts::FlatTexts (const db::Shapes &texts)
: MutableTexts (), mp_texts (new db::Shapes (texts))
: MutableTexts (), mp_texts (new db::Shapes (texts)), mp_properties_repository (new db::PropertiesRepository ())
{
// .. nothing yet ..
}
@ -121,7 +121,7 @@ TextsDelegate *FlatTexts::add (const Texts &other) const
std::unique_ptr<FlatTexts> new_texts (new FlatTexts (*this));
new_texts->invalidate_cache ();
FlatTexts *other_flat = dynamic_cast<FlatTexts *> (other.delegate ());
const FlatTexts *other_flat = dynamic_cast<const FlatTexts *> (other.delegate ());
if (other_flat) {
new_texts->raw_texts ().insert (other_flat->raw_texts ().get_layer<db::Text, db::unstable_layer_tag> ().begin (), other_flat->raw_texts ().get_layer<db::Text, db::unstable_layer_tag> ().end ());
@ -150,7 +150,7 @@ TextsDelegate *FlatTexts::add_in_place (const Texts &other)
db::Shapes &texts = *mp_texts;
FlatTexts *other_flat = dynamic_cast<FlatTexts *> (other.delegate ());
const FlatTexts *other_flat = dynamic_cast<const FlatTexts *> (other.delegate ());
if (other_flat) {
texts.insert (other_flat->raw_texts ().get_layer<db::Text, db::unstable_layer_tag> ().begin (), other_flat->raw_texts ().get_layer<db::Text, db::unstable_layer_tag> ().end ());
@ -188,9 +188,14 @@ const db::RecursiveShapeIterator *FlatTexts::iter () const
return 0;
}
const db::Layout *FlatTexts::layout () const
db::PropertiesRepository *FlatTexts::properties_repository ()
{
return 0;
return mp_properties_repository.get_non_const ();
}
const db::PropertiesRepository *FlatTexts::properties_repository () const
{
return mp_properties_repository.get_const ();
}
void

View File

@ -79,7 +79,8 @@ public:
virtual bool has_valid_texts () const;
virtual const db::RecursiveShapeIterator *iter () const;
virtual const db::Layout *layout () const;
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;
@ -121,6 +122,7 @@ private:
FlatTexts &operator= (const FlatTexts &other);
mutable tl::copy_on_write_ptr<db::Shapes> mp_texts;
mutable tl::copy_on_write_ptr<db::PropertiesRepository> mp_properties_repository;
template <class Trans>
void transform_generic (const Trans &trans)

View File

@ -61,6 +61,12 @@ DirectLayerMapping::map_layer (const LayerProperties &lprops)
// PropertyMapper implementation
PropertyMapper::PropertyMapper (db::Layout &target, const db::Layout &source)
: mp_target (&target.properties_repository ()), mp_source (&source.properties_repository ())
{
// .. nothing yet ..
}
PropertyMapper::PropertyMapper (db::PropertiesRepository &target, const db::PropertiesRepository &source)
: mp_target (&target), mp_source (&source)
{
// .. nothing yet ..
@ -83,6 +89,18 @@ PropertyMapper::PropertyMapper ()
*/
void
PropertyMapper::set_source (const db::Layout &source)
{
if (&source.properties_repository () != mp_source) {
m_prop_id_map.clear ();
mp_source = &source.properties_repository ();
}
}
/**
* @brief Specify the source property repository
*/
void
PropertyMapper::set_source (const db::PropertiesRepository &source)
{
if (&source != mp_source) {
m_prop_id_map.clear ();
@ -95,6 +113,18 @@ PropertyMapper::set_source (const db::Layout &source)
*/
void
PropertyMapper::set_target (db::Layout &target)
{
if (&target.properties_repository () != mp_target) {
m_prop_id_map.clear ();
mp_target = &target.properties_repository ();
}
}
/**
* @brief Specify the target property repository
*/
void
PropertyMapper::set_target (db::PropertiesRepository &target)
{
if (&target != mp_target) {
m_prop_id_map.clear ();
@ -118,7 +148,7 @@ PropertyMapper::operator() (db::Layout::properties_id_type source_id)
std::map <db::Layout::properties_id_type, db::Layout::properties_id_type>::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->properties_repository ().translate (mp_source->properties_repository (), source_id);
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 {

View File

@ -82,6 +82,14 @@ public:
*/
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
*
@ -95,19 +103,29 @@ public:
*/
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::Layout *mp_target;
const db::Layout *mp_source;
db::PropertiesRepository *mp_target;
const db::PropertiesRepository *mp_source;
std::map <db::Layout::properties_id_type, db::Layout::properties_id_type> m_prop_id_map;
};

View File

@ -202,10 +202,16 @@ OriginalLayerEdgePairs::iter () const
return &m_iter;
}
const db::Layout *
OriginalLayerEdgePairs::layout () const
db::PropertiesRepository *
OriginalLayerEdgePairs::properties_repository ()
{
return m_iter.layout ();
return m_iter.layout () ? &const_cast<db::Layout * >(m_iter.layout ())->properties_repository () : 0;
}
const db::PropertiesRepository *
OriginalLayerEdgePairs::properties_repository () const
{
return m_iter.layout () ? &m_iter.layout ()->properties_repository () : 0;
}
bool

View File

@ -56,7 +56,8 @@ public:
virtual bool has_valid_edge_pairs () const;
virtual const db::RecursiveShapeIterator *iter () const;
virtual const db::Layout *layout () const;
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;

View File

@ -251,10 +251,16 @@ OriginalLayerEdges::iter () const
return &m_iter;
}
const db::Layout *
OriginalLayerEdges::layout () const
db::PropertiesRepository *
OriginalLayerEdges::properties_repository ()
{
return m_iter.layout ();
return m_iter.layout () ? &const_cast<db::Layout * >(m_iter.layout ())->properties_repository () : 0;
}
const db::PropertiesRepository *
OriginalLayerEdges::properties_repository () const
{
return m_iter.layout () ? &m_iter.layout ()->properties_repository () : 0;
}
bool

View File

@ -62,7 +62,8 @@ public:
virtual bool has_valid_merged_edges () const;
virtual const db::RecursiveShapeIterator *iter () const;
virtual const db::Layout *layout () const;
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;

View File

@ -369,10 +369,16 @@ OriginalLayerRegion::iter () const
return &m_iter;
}
const db::Layout *
OriginalLayerRegion::layout () const
db::PropertiesRepository *
OriginalLayerRegion::properties_repository ()
{
return m_iter.layout ();
return m_iter.layout () ? &const_cast<db::Layout * >(m_iter.layout ())->properties_repository () : 0;
}
const db::PropertiesRepository *
OriginalLayerRegion::properties_repository () const
{
return m_iter.layout () ? &m_iter.layout ()->properties_repository () : 0;
}
bool

View File

@ -67,7 +67,8 @@ public:
virtual bool has_valid_merged_polygons () const;
virtual const db::RecursiveShapeIterator *iter () const;
virtual const db::Layout *layout () const;
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;

View File

@ -202,10 +202,16 @@ OriginalLayerTexts::iter () const
return &m_iter;
}
const db::Layout *
OriginalLayerTexts::layout () const
db::PropertiesRepository *
OriginalLayerTexts::properties_repository ()
{
return m_iter.layout ();
return m_iter.layout () ? &const_cast<db::Layout * >(m_iter.layout ())->properties_repository () : 0;
}
const db::PropertiesRepository *
OriginalLayerTexts::properties_repository () const
{
return m_iter.layout () ? &m_iter.layout ()->properties_repository () : 0;
}
bool

View File

@ -56,7 +56,8 @@ public:
virtual bool has_valid_texts () const;
virtual const db::RecursiveShapeIterator *iter () const;
virtual const db::Layout *layout () const;
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;

View File

@ -42,6 +42,12 @@ PropertiesRepository::PropertiesRepository (db::LayoutStateModel *state_model)
tl_assert (id == 0);
}
PropertiesRepository::PropertiesRepository (const PropertiesRepository &d)
: mp_state_model (0)
{
operator= (d);
}
PropertiesRepository &
PropertiesRepository::operator= (const PropertiesRepository &d)
{

View File

@ -63,6 +63,11 @@ public:
*/
PropertiesRepository (db::LayoutStateModel *state_model = 0);
/**
* @brief Copy constructor
*/
PropertiesRepository (const PropertiesRepository &d);
/**
* @brief Assignment
*/
@ -232,8 +237,6 @@ private:
std::map <name_value_pair, properties_id_vector> m_properties_component_table;
db::LayoutStateModel *mp_state_model;
PropertiesRepository (const PropertiesRepository &d);
};
/**

View File

@ -109,10 +109,20 @@ Region::iter () const
return *(i ? i : &def_iter);
}
const db::Layout *
Region::layout () const
const db::PropertiesRepository &
Region::properties_repository () const
{
return mp_delegate ? mp_delegate->layout () : 0;
static db::PropertiesRepository empty_prop_repo;
const db::PropertiesRepository *r = delegate () ? delegate ()->properties_repository () : 0;
return *(r ? r : &empty_prop_repo);
}
db::PropertiesRepository &
Region::properties_repository ()
{
db::PropertiesRepository *r = delegate () ? delegate ()->properties_repository () : 0;
tl_assert (r != 0);
return *r;
}
void

View File

@ -298,7 +298,15 @@ public:
/**
* @brief Gets the underlying delegate object
*/
RegionDelegate *delegate () const
const RegionDelegate *delegate () const
{
return mp_delegate;
}
/**
* @brief Gets the underlying delegate object
*/
RegionDelegate *delegate ()
{
return mp_delegate;
}
@ -1757,12 +1765,18 @@ public:
const db::RecursiveShapeIterator &iter () const;
/**
* @brief Gets the source layout for the polygons
* @brief Gets the property repository
*
* Use this layout to decode property IDs. This layout may be null, in which case the
* source layout is outside the scope of this region.
* Use this object to decode property IDs.
*/
const db::Layout *layout () const;
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

View File

@ -316,7 +316,8 @@ public:
virtual bool has_valid_merged_polygons () const = 0;
virtual const db::RecursiveShapeIterator *iter () const = 0;
virtual const db::Layout *layout () const = 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;

View File

@ -419,4 +419,24 @@ bool compare (const db::Box &box, const std::string &string)
return box.to_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)
{
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;
}
}

View File

@ -37,6 +37,7 @@ namespace tl
namespace db
{
class PropertiesRepository;
class Layout;
class Cell;
class LayerMap;
@ -117,6 +118,11 @@ bool DB_PUBLIC compare (const db::Texts &texts, const std::string &string);
*/
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);
}
#endif

View File

@ -150,10 +150,20 @@ Texts::iter () const
return *(i ? i : &def_iter);
}
const db::Layout *
Texts::layout () const
const db::PropertiesRepository &
Texts::properties_repository () const
{
return mp_delegate ? mp_delegate->layout () : 0;
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

View File

@ -248,7 +248,15 @@ public:
/**
* @brief Gets the underlying delegate object
*/
TextsDelegate *delegate () const
const TextsDelegate *delegate () const
{
return mp_delegate;
}
/**
* @brief Gets the underlying delegate object
*/
TextsDelegate *delegate ()
{
return mp_delegate;
}
@ -525,12 +533,18 @@ public:
const db::RecursiveShapeIterator &iter () const;
/**
* @brief Gets the source layout for the polygons
* @brief Gets the property repository
*
* Use this layout to decode property IDs. This layout may be null, in which case the
* source layout is outside the scope of this region.
* Use this object to decode property IDs.
*/
const db::Layout *layout () const;
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

View File

@ -102,7 +102,8 @@ public:
virtual bool has_valid_texts () const = 0;
virtual const db::RecursiveShapeIterator *iter () const = 0;
virtual const db::Layout *layout () const = 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;

View File

@ -2254,28 +2254,6 @@ TEST(52_PropertiesDeep)
EXPECT_EQ (s.at_end (), true);
}
// TODO: should go somewhere central
static std::string prop2string (const db::Layout *layout, db::properties_id_type prop_id)
{
if (! layout) {
return std::string ("(no layout)");
}
const db::PropertiesRepository::properties_set &ps = layout->properties_repository ().properties (prop_id);
std::string res;
for (auto i = ps.begin (); i != ps.end (); ++i) {
if (i != ps.begin ()) {
res += "\n";
}
res += layout->properties_repository ().prop_name (i->first).to_string ();
res += "=";
res += i->second.to_string ();
}
return res;
}
TEST(53_PropertiesDeepFromLayout)
{
db::DeepShapeStore dss;
@ -2377,11 +2355,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.layout (), s.prop_id ()), "VALUE=1");
EXPECT_EQ (prop2string (r.properties_repository (), 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.layout (), s.prop_id ()), "VALUE=42");
EXPECT_EQ (prop2string (r.properties_repository (), 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);
@ -2394,13 +2372,13 @@ TEST(53_PropertiesDeepFromLayout)
++s;
EXPECT_EQ (s.at_end (), false);
EXPECT_EQ (prop2string (r.layout (), s.prop_id ()), "VALUE=1");
EXPECT_EQ (prop2string (r.properties_repository (), 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.layout (), s.prop_id ()), "VALUE=42");
EXPECT_EQ (prop2string (r.properties_repository (), s.prop_id ()), "VALUE=42");
// a single property #42 element
EXPECT_EQ (s->to_string (), "(11,12;11,212;111,212;111,12)");
++s;

View File

@ -661,7 +661,7 @@ D25ViewWidget::entry (const db::Region &data, double dbu, double zstart, double
{
// try to establish a default color from the region's origin if required
const db::RecursiveShapeIterator *iter = 0;
const db::OriginalLayerRegion *original = dynamic_cast<db::OriginalLayerRegion *> (data.delegate ());
const db::OriginalLayerRegion *original = dynamic_cast<const db::OriginalLayerRegion *> (data.delegate ());
if (original) {
iter = original->iter ();
}
@ -677,7 +677,7 @@ D25ViewWidget::entry (const db::Edges &data, double dbu, double zstart, double z
{
// try to establish a default color from the region's origin if required
const db::RecursiveShapeIterator *iter = 0;
const db::OriginalLayerEdges *original = dynamic_cast<db::OriginalLayerEdges *> (data.delegate ());
const db::OriginalLayerEdges *original = dynamic_cast<const db::OriginalLayerEdges *> (data.delegate ());
if (original) {
iter = original->iter ();
}
@ -693,7 +693,7 @@ D25ViewWidget::entry (const db::EdgePairs &data, double dbu, double zstart, doub
{
// try to establish a default color from the region's origin if required
const db::RecursiveShapeIterator *iter = 0;
const db::OriginalLayerEdgePairs *original = dynamic_cast<db::OriginalLayerEdgePairs *> (data.delegate ());
const db::OriginalLayerEdgePairs *original = dynamic_cast<const db::OriginalLayerEdgePairs *> (data.delegate ());
if (original) {
iter = original->iter ();
}