wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
ItemWithId Class Reference

Base class providing a unique integer identifier for circuit items. More...

#include <ItemWithId.h>

Inheritance diagram for ItemWithId:
[legend]

Public Member Functions

int id () const
 Returns the unique integer identifier of this item, or -1 if unassigned.
 ItemWithId ()=default
 Constructs a new ItemWithId with an unassigned ID of -1.
void setId (const int id)
 Sets the identifier to id.
virtual ~ItemWithId ()
 Self-unregisters from the current SceneItemRegistry, if any.

Friends

class SceneItemRegistry

Detailed Description

Base class providing a unique integer identifier for circuit items.

Every graphic element and connection inherits from ItemWithId to obtain a stable numeric ID managed by the owning Scene. IDs start as -1 (unassigned) and are set to a positive value when the item is added to a Scene via Scene::addItem(). The ID is used for undo/redo serialization and cross-reference during load/save.

Also self-unregisters from whichever SceneItemRegistry it is currently registered with, on ANY destruction path — including Qt's own parent-child cascade-delete, which bypasses Scene::removeItem's override. This structurally prevents a stale id->item registry entry from ever outliving the item (the WIREDPANDA-HC bug family).

Definition at line 30 of file ItemWithId.h.

Constructor & Destructor Documentation

◆ ItemWithId()

ItemWithId::ItemWithId ( )
default

Constructs a new ItemWithId with an unassigned ID of -1.

◆ ~ItemWithId()

ItemWithId::~ItemWithId ( )
virtual

Self-unregisters from the current SceneItemRegistry, if any.

Definition at line 8 of file ItemWithId.cpp.

Member Function Documentation

◆ id()

◆ setId()

void ItemWithId::setId ( const int id)
inline

Sets the identifier to id.

Parameters
idNew identifier value.

Definition at line 46 of file ItemWithId.h.

References id().

Referenced by SceneItemRegistry::updateItemId().

◆ SceneItemRegistry

friend class SceneItemRegistry
friend

Definition at line 49 of file ItemWithId.h.

References SceneItemRegistry.

Referenced by SceneItemRegistry.


The documentation for this class was generated from the following files: