C++ (Qt)struct MyClass {... const CDrawList & GetDrawList( const CPolygonList * poly ) { CDrawList & list = m_hash[poly]; if (list.IsEmpty()) poly->BuildDrawList(list, ...); return list; }...};
C++ (Qt)struct CMaterialSet {... const CDrawList & GetDrawList( const CPolygonList * poly ) {// выбрасываем трупики auto it = m_hash.begin(); while (it != m_hash.end()) if (it.value().m_LivePtr.isNull()) // бобик сдох ? it = m_hash.erase(it); else ++it; // кешируем данные CDrawPair & p = m_hash[poly]; p.m_LivePtr = poly->GetLivePtr(); // QWeakPointer = QSharedPointer if (p.m_list.IsEmpty()) poly->BuildDrawList(p.m_list, this->m_indices); return p.m_list; }...};
C++ (Qt)const CDrawList & GetDrawList( const CPolygonList * poly ){... CDrawPair & p = m_hash[poly];--> p.m_LivePtr = poly->GetLivePtr(); // QWeakPointer = QSharedPointer if (p.m_list.IsEmpty())--> poly->BuildDrawList(p.m_list, this->m_indices);...}
C++ (Qt)const CDrawList & GetDrawList( const std::weak_ptr<const CPolygonList>& poly_carrier ){ std::shared_ptr<const CPolygonList> poly_lifetime_locker = poly_carrier.lock(); if (!poly_lifetime_locker) return ???; const CPolygonList& poly_object = *poly_lifetime_locker; CDrawList & list = m_hash[poly_object.id()]; if (list.IsEmpty()) poly_object.BuildDrawList(list, ...); return list;}
C++ (Qt)const CDrawList & GetDrawList( const std::weak_ptr<const CPolygonList>& poly_carrier ){ std::shared_ptr<const CPolygonList> poly_lifetime_locker = poly_carrier.lock();.. CDrawList & list = m_hash[poly_object.id()];