comparison base/ById.cpp @ 1761:ee7fd2c01d87 by-id

Work on management of alignment-related models
author Chris Cannam
date Fri, 12 Jul 2019 13:57:42 +0100
parents b679bae1627b
children 4fec4527e50e
comparison
equal deleted inserted replaced
1760:9945ad04c174 1761:ee7fd2c01d87
68 int add(std::shared_ptr<WithId> item) { 68 int add(std::shared_ptr<WithId> item) {
69 int id = item->getUntypedId(); 69 int id = item->getUntypedId();
70 if (id == IdAlloc::NO_ID) { 70 if (id == IdAlloc::NO_ID) {
71 throw std::logic_error("item id should never be NO_ID"); 71 throw std::logic_error("item id should never be NO_ID");
72 } 72 }
73 SVCERR << "ById::add(#" << id << ") of type "
74 << typeid(*item.get()).name() << endl;
73 QMutexLocker locker(&m_mutex); 75 QMutexLocker locker(&m_mutex);
74 if (m_items.find(id) != m_items.end()) { 76 if (m_items.find(id) != m_items.end()) {
75 SVCERR << "ById::add: item with id " << id 77 SVCERR << "ById::add: item with id " << id
76 << " is already recorded (existing item type is " 78 << " is already recorded (existing item type is "
77 << typeid(*m_items.find(id)->second.get()).name() 79 << typeid(*m_items.find(id)->second.get()).name()
85 87
86 void release(int id) { 88 void release(int id) {
87 if (id == IdAlloc::NO_ID) { 89 if (id == IdAlloc::NO_ID) {
88 return; 90 return;
89 } 91 }
90 SVCERR << "ById::release(" << id << ")" << endl; 92 SVCERR << "ById::release(#" << id << ")" << endl;
91 QMutexLocker locker(&m_mutex); 93 QMutexLocker locker(&m_mutex);
92 if (m_items.find(id) == m_items.end()) { 94 if (m_items.find(id) == m_items.end()) {
93 SVCERR << "ById::release: unknown item id " << id << endl; 95 SVCERR << "ById::release: unknown item id " << id << endl;
94 throw std::logic_error("unknown item id in release"); 96 throw std::logic_error("unknown item id in release");
95 } 97 }