language/duchain
indexedtype.h
00001 /* This file is part of KDevelop 00002 Copyright 2007-2009 David Nolden <david.nolden.kdevelop@art-master.de> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #ifndef INDEXEDTYPE_H 00020 #define INDEXEDTYPE_H 00021 00022 #include "abstracttype.h" 00023 #include <language/duchain/referencecounting.h> 00024 00025 namespace KDevelop 00026 { 00027 00037 class KDEVPLATFORMLANGUAGE_EXPORT IndexedType : public ReferenceCountManager { 00038 public: 00040 IndexedType(const IndexedType& rhs); 00041 explicit IndexedType(uint index = 0); 00042 00043 ~IndexedType(); 00044 00045 IndexedType& operator=(const IndexedType& rhs); 00046 00052 AbstractType::Ptr abstractType() const; 00053 00059 template<class T> 00060 TypePtr<T> type() const { return TypePtr<T>::dynamicCast(abstractType()); } 00061 00063 bool isValid() const { 00064 return (bool)m_index; 00065 } 00066 00068 operator bool() const { 00069 return (bool)m_index; 00070 } 00071 00073 bool operator==(const IndexedType& rhs) const { 00074 return m_index == rhs.m_index; 00075 } 00076 00078 bool operator!=(const IndexedType& rhs) const { 00079 return m_index != rhs.m_index; 00080 } 00081 00083 uint hash() const { 00084 return m_index>>1; 00085 } 00086 00088 uint index() const { 00089 return m_index; 00090 } 00091 00092 private: 00094 uint m_index; 00095 }; 00096 00097 } 00098 00099 #endif 00100 00101 // kate: space-indent on; indent-width 2; tab-width 4; replace-tabs on; auto-insert-doxygen on
KDE 4.4 API Reference