File indexing completed on 2024-06-16 04:23:17
0001 /* 0002 SPDX-FileCopyrightText: 2007-2009 David Nolden <david.nolden.kdevelop@art-master.de> 0003 0004 SPDX-License-Identifier: LGPL-2.0-only 0005 */ 0006 0007 #include "indexedtype.h" 0008 0009 #include "typerepository.h" 0010 #include <serialization/referencecounting.h> 0011 0012 namespace KDevelop { 0013 IndexedType::IndexedType(const AbstractType* type) 0014 : m_index(TypeRepository::indexForType(type)) 0015 { 0016 if (m_index && shouldDoDUChainReferenceCounting(this)) 0017 TypeRepository::increaseReferenceCount(m_index, this); 0018 } 0019 0020 IndexedType::IndexedType(uint index) : m_index(index) 0021 { 0022 if (m_index && shouldDoDUChainReferenceCounting(this)) 0023 TypeRepository::increaseReferenceCount(m_index, this); 0024 } 0025 0026 IndexedType::IndexedType(const IndexedType& rhs) : m_index(rhs.m_index) 0027 { 0028 if (m_index && shouldDoDUChainReferenceCounting(this)) 0029 TypeRepository::increaseReferenceCount(m_index, this); 0030 } 0031 0032 IndexedType::~IndexedType() 0033 { 0034 if (m_index && shouldDoDUChainReferenceCounting(this)) 0035 TypeRepository::decreaseReferenceCount(m_index, this); 0036 } 0037 0038 IndexedType& IndexedType::operator=(const IndexedType& rhs) 0039 { 0040 if (m_index && shouldDoDUChainReferenceCounting(this)) 0041 TypeRepository::decreaseReferenceCount(m_index, this); 0042 0043 m_index = rhs.m_index; 0044 0045 if (m_index && shouldDoDUChainReferenceCounting(this)) 0046 TypeRepository::increaseReferenceCount(m_index, this); 0047 0048 return *this; 0049 } 0050 0051 AbstractType::Ptr IndexedType::abstractType() const 0052 { 0053 if (!m_index) 0054 return AbstractType::Ptr(); 0055 return TypeRepository::typeForIndex(m_index); 0056 } 0057 }