router: introduce ITEM::UNIQ_ID

It's a globally unique identifier for each PNS::ITEM, used as a reliable hash key (pointers are NOT unique)
This commit is contained in:
Tomasz Wlostowski 2024-10-24 14:25:48 +02:00
parent f77f63cf2d
commit 3453592fc3
8 changed files with 35 additions and 9 deletions

View File

@ -326,4 +326,10 @@ const NODE* ITEM::OwningNode() const
return static_cast<const NODE*>( Owner() );
}
LINKED_ITEM::UNIQ_ID LINKED_ITEM::genNextUid()
{
static UNIQ_ID uidCount = 0; // fixme: make atomic
return uidCount++;
}
} // namespace PNS

View File

@ -108,7 +108,8 @@ public:
VIA_T = 32,
DIFF_PAIR_T = 64,
HOLE_T = 128,
ANY_T = 0xffff
ANY_T = 0xffff,
LINKED_ITEM_MASK_T = SOLID_T | SEGMENT_T | ARC_T | VIA_T | HOLE_T
};
ITEM( PnsKind aKind )

View File

@ -138,7 +138,7 @@ int LINE::Marker() const
SEGMENT* SEGMENT::Clone() const
{
SEGMENT* s = new SEGMENT;
SEGMENT* s = new SEGMENT( *this );
s->m_seg = m_seg;
s->m_net = m_net;

View File

@ -30,9 +30,21 @@ class LINKED_ITEM : public ITEM
{
public:
LINKED_ITEM( PnsKind aKind ) : ITEM( aKind )
typedef uint64_t UNIQ_ID;
LINKED_ITEM( PnsKind aKind ) :
ITEM( aKind )
{
m_uid = genNextUid();
}
LINKED_ITEM( const LINKED_ITEM& aOther ) :
ITEM( aOther ),
m_uid( aOther.m_uid )
{}
UNIQ_ID Uid() const { return m_uid; }
virtual void SetWidth( int aWidth )
{};
@ -40,6 +52,11 @@ public:
{
return 0;
}
private:
static UNIQ_ID genNextUid();
protected:
UNIQ_ID m_uid;
};
} // namespace PNS

View File

@ -59,6 +59,12 @@ public:
m_rank = aParentLine.Rank();
}
explicit SEGMENT( const LINKED_ITEM& aParent ) :
LINKED_ITEM( aParent )
{
assert( aParent.Kind() == SEGMENT_T );
}
static inline bool ClassOf( const ITEM* aItem )
{
return aItem && SEGMENT_T == aItem->Kind();

View File

@ -159,6 +159,7 @@ VIA* VIA::Clone() const
{
VIA* v = new VIA();
v->m_uid = m_uid; // fixme: oop
v->SetNet( Net() );
v->SetLayers( Layers() );
v->m_pos = m_pos;

View File

@ -117,6 +117,7 @@ public:
m_viaType = aB.m_viaType;
m_isFree = aB.m_isFree;
m_isVirtual = aB.m_isVirtual;
m_uid = aB.m_uid;
return *this;
}

View File

@ -44,12 +44,6 @@ NODE::OPT_OBSTACLE WALKAROUND::nearestObstacle( const LINE& aPath )
COLLISION_SEARCH_OPTIONS opts;
opts.m_kindMask = m_itemMask;
if( ! m_restrictedSet.empty() )
opts.m_restrictedSet = &m_restrictedSet;
else
opts.m_restrictedSet = nullptr;
opts.m_useClearanceEpsilon = false;
NODE::OPT_OBSTACLE obs = m_world->NearestObstacle( &aPath, opts );