• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdevelop API Reference
  • KDE Home
  • Contact Us
 

kdevplatform/language/duchain

  • sources
  • kfour-appscomplete
  • kdevelop
  • kdevplatform
  • language
  • duchain
  • types
indexedtype.h
Go to the documentation of this file.
1 /* This file is part of KDevelop
2  Copyright 2007-2009 David Nolden <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef KDEVPLATFORM_INDEXEDTYPE_H
20 #define KDEVPLATFORM_INDEXEDTYPE_H
21 
22 #include "abstracttype.h"
23 
24 #include <serialization/referencecounting.h>
25 
26 namespace KDevelop {
36 class KDEVPLATFORMLANGUAGE_EXPORT IndexedType
37  : public ReferenceCountManager
38 {
39 public:
40  IndexedType(const IndexedType& rhs);
41  explicit IndexedType(const AbstractType::Ptr& type);
42  explicit IndexedType(uint index = 0);
43 
44  ~IndexedType();
45 
46  IndexedType& operator=(const IndexedType& rhs);
47 
53  AbstractType::Ptr abstractType() const;
54 
60  template <class T>
61  TypePtr<T> type() const { return TypePtr<T>::dynamicCast(abstractType()); }
62 
64  bool isValid() const
65  {
66  return ( bool )m_index;
67  }
68 
70  operator bool() const {
71  return ( bool )m_index;
72  }
73 
75  bool operator==(const IndexedType& rhs) const
76  {
77  return m_index == rhs.m_index;
78  }
79 
81  bool operator!=(const IndexedType& rhs) const
82  {
83  return m_index != rhs.m_index;
84  }
85 
88  bool operator<(const IndexedType& rhs) const
89  {
90  return m_index < rhs.m_index;
91  }
92 
94  uint hash() const
95  {
96  return m_index >> 1;
97  }
98 
100  uint index() const
101  {
102  return m_index;
103  }
104 
105 private:
107  uint m_index;
108 };
109 
110 inline uint qHash(const IndexedType& type)
111 {
112  return type.hash();
113 }
114 }
115 
116 Q_DECLARE_TYPEINFO(KDevelop::IndexedType, Q_MOVABLE_TYPE);
117 
118 #endif
KDevelop::IndexedType::type
TypePtr< T > type() const
Access the type, dynamically casted to the type you provide.
Definition: indexedtype.h:61
KDevelop::IndexedType::isValid
bool isValid() const
Determine if the type is valid.
Definition: indexedtype.h:64
KDevelop::TypePtr::dynamicCast
static TypePtr< T > dynamicCast(const TypePtr< U > &o)
Convert TypePtr to TypePtr<T>, using a dynamic_cast.
Definition: typepointer.h:88
KDevelop::IndexedType::operator==
bool operator==(const IndexedType &rhs) const
Equivalence operator.
Definition: indexedtype.h:75
KDevelop::TypePtr< AbstractType >
KDevelop::IndexedType::hash
uint hash() const
Access the type's hash value.
Definition: indexedtype.h:94
KDevelop::IndexedType::operator!=
bool operator!=(const IndexedType &rhs) const
Not equal operator.
Definition: indexedtype.h:81
KDevelop::IndexedType::operator<
bool operator<(const IndexedType &rhs) const
Less than operator,.
Definition: indexedtype.h:88
KDevelop::IndexedType::index
uint index() const
Access the type's index.
Definition: indexedtype.h:100
Q_DECLARE_TYPEINFO
Q_DECLARE_TYPEINFO(KDevelop::IndexedType, Q_MOVABLE_TYPE)
KDevelop::qHash
uint qHash(const KDevelop::DeclarationId &id)
Definition: declarationid.h:205
ReferenceCountManager
abstracttype.h
KDevelop::IndexedType
Indexed type pointer.
Definition: indexedtype.h:36
KDevelop
Definition: abstractfunctiondeclaration.cpp:27
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Jan 20 2021 23:38:35 by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kdevplatform/language/duchain

Skip menu "kdevplatform/language/duchain"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdevelop API Reference

Skip menu "kdevelop API Reference"
  • kdevplatform
  •   debugger
  •   documentation
  •   interfaces
  •   language
  •     assistant
  •     backgroundparser
  •     checks
  •     classmodel
  •     codecompletion
  •     codegen
  •     duchain
  •     editor
  •     highlighting
  •     interfaces
  •     util
  •   outputview
  •   project
  •   serialization
  •   shell
  •   sublime
  •   tests
  •   util
  •   vcs

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal