wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
ItemWithId.h
Go to the documentation of this file.
1// Copyright 2015 - 2026, GIBIS-UNIFESP and the wiRedPanda contributors
2// SPDX-License-Identifier: GPL-3.0-or-later
3
7
8#pragma once
9
10#include <QtGlobal>
11
13
31{
32public:
34 ItemWithId() = default;
35
37 virtual ~ItemWithId();
38
40 int id() const { return m_id; }
41
46 void setId(const int id) { m_id = id; }
47
48private:
49 friend class SceneItemRegistry;
50
53 void setRegistry(SceneItemRegistry *registry) { m_registry = registry; }
54
55 Q_DISABLE_COPY(ItemWithId)
56
57 int m_id = -1;
58 SceneItemRegistry *m_registry = nullptr;
59};
Base class providing a unique integer identifier for circuit items.
Definition ItemWithId.h:31
ItemWithId()=default
Constructs a new ItemWithId with an unassigned ID of -1.
void setId(const int id)
Sets the identifier to id.
Definition ItemWithId.h:46
friend class SceneItemRegistry
Definition ItemWithId.h:49
int id() const
Returns the unique integer identifier of this item, or -1 if unassigned.
Definition ItemWithId.h:40
virtual ~ItemWithId()
Self-unregisters from the current SceneItemRegistry, if any.
Definition ItemWithId.cpp:8
Owns the id↔item bookkeeping for a Scene: the id-to-item map and the monotonically increasing last-as...