language/duchain
instantiationinformation.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef INSTANTIATIONINFORMATION_H
00020 #define INSTANTIATIONINFORMATION_H
00021
00022 #include "../languageexport.h"
00023 #include "types/abstracttype.h"
00024 #include "types/indexedtype.h"
00025 #include "appendedlist.h"
00026 #include "referencecounting.h"
00027
00028 namespace KDevelop {
00029 class IndexedInstantiationInformation;
00030 class InstantiationInformation;
00031 class QualifiedIdentifier;
00032
00033 KDEVPLATFORMLANGUAGE_EXPORT DECLARE_LIST_MEMBER_HASH(InstantiationInformation, templateParameters, IndexedType)
00034
00035 class KDEVPLATFORMLANGUAGE_EXPORT IndexedInstantiationInformation : public ReferenceCountManager {
00036 public:
00037 IndexedInstantiationInformation();
00038 explicit IndexedInstantiationInformation(uint index);
00039 IndexedInstantiationInformation(const IndexedInstantiationInformation& rhs);
00040 IndexedInstantiationInformation& operator=(const IndexedInstantiationInformation& rhs);
00041 ~IndexedInstantiationInformation();
00042
00043 const InstantiationInformation& information() const;
00044
00045 uint hash() const {
00046 return m_index * 73;
00047 }
00048
00049
00050 uint index() const {
00051 return m_index;
00052 }
00053
00054 bool operator==(const IndexedInstantiationInformation& rhs) const {
00055 return m_index == rhs.m_index;
00056 }
00057
00058
00059 bool isValid() const;
00060
00061 private:
00062 uint m_index;
00063 };
00064
00065 class KDEVPLATFORMLANGUAGE_EXPORT InstantiationInformation {
00066 public:
00067
00068 InstantiationInformation();
00070 InstantiationInformation(const InstantiationInformation& rhs, bool dynamic = true);
00071
00072 ~InstantiationInformation();
00073
00074 InstantiationInformation& operator=(const InstantiationInformation& rhs);
00075
00076 bool operator==(const InstantiationInformation& rhs) const;
00077
00078 uint hash() const;
00079
00080 bool isValid() const {
00081 return previousInstantiationInformation.index() || templateParametersSize();
00082 }
00083
00084 bool persistent() const {
00085 return (bool)m_refCount;
00086 }
00087
00092 QualifiedIdentifier applyToIdentifier(const QualifiedIdentifier& id) const;
00093
00095 QString toString(bool local = false) const;
00096
00098 void addTemplateParameter(AbstractType::Ptr type);
00099
00101 IndexedInstantiationInformation previousInstantiationInformation;
00102
00103 START_APPENDED_LISTS(InstantiationInformation)
00104
00105 static size_t classSize() {
00106 return sizeof(InstantiationInformation);
00107 }
00108
00109 short unsigned int itemSize() const {
00110 return dynamicSize();
00111 }
00112
00114 APPENDED_LIST_FIRST(InstantiationInformation, IndexedType, templateParameters);
00115
00116 END_APPENDED_LISTS(InstantiationInformation, templateParameters);
00117
00118 IndexedInstantiationInformation indexed() const;
00119 private:
00120 friend class IndexedInstantiationInformation;
00121 uint m_refCount;
00122 };
00123
00124 inline uint qHash(const IndexedInstantiationInformation& info) {
00125 return info.hash();
00126 }
00127 inline uint qHash(const InstantiationInformation& info) {
00128 return info.hash();
00129 }
00130 }
00131
00132 #endif // INSTANTIATIONINFORMATION_H