| 89 | } |
| 90 | |
| 91 | struct ReferenceCountItem |
| 92 | { |
| 93 | ///Item entries: |
| 94 | ReferenceCountItem(uint id, uint target) : m_id(id) |
| 95 | , m_targetId(target) |
| 96 | { |
| 97 | } |
| 98 | |
| 99 | ReferenceCountItem& operator=(const ReferenceCountItem& rhs) = delete; |
| 100 | |
| 101 | //Every item has to implement this function, and return a valid hash. |
| 102 | //Must be exactly the same hash value as ReferenceCountItemRequest::hash() has returned while creating the item. |
| 103 | unsigned int hash() const |
| 104 | { |
| 105 | return KDevHash() << m_id << m_targetId; |
| 106 | } |
| 107 | |
| 108 | //Every item has to implement this function, and return the complete size this item takes in memory. |
| 109 | //Must be exactly the same value as ReferenceCountItemRequest::itemSize() has returned while creating the item. |
| 110 | unsigned short int itemSize() const |
| 111 | { |
| 112 | return sizeof(ReferenceCountItem); |
| 113 | } |
| 114 | |
| 115 | uint m_id; |
| 116 | uint m_targetId; |
| 117 | |
| 118 | ///Request entries: |
| 119 | enum { |
| 120 | AverageSize = 8 |
| 121 | }; |
| 122 | |
| 123 | void createItem(ReferenceCountItem* item) const |
| 124 | { |
| 125 | * item = *this; |
| 126 | } |
| 127 | static void destroy(ReferenceCountItem* /*item*/, AbstractItemRepository&) |
| 128 | { |
| 129 | } |
| 130 | |
| 131 | static bool persistent(const ReferenceCountItem*) |
| 132 | { |
| 133 | return true; |
| 134 | } |
| 135 | |
| 136 | bool equals(const ReferenceCountItem* item) const |
| 137 | { |
| 138 | return m_id == item->m_id && m_targetId == item->m_targetId; |
| 139 | } |
| 140 | }; |
| 141 | |
| 142 | static RepositoryManager<ItemRepository<ReferenceCountItem, ReferenceCountItem, false, true, |
| 143 | sizeof(ReferenceCountItem)>, false>& references() |