File indexing completed on 2024-06-16 04:23:16

0001 /*
0002     SPDX-FileCopyrightText: 2006 Roberto Raggi <roberto@kdevelop.org>
0003     SPDX-FileCopyrightText: 2006-2008 Hamish Rodda <rodda@kde.org>
0004     SPDX-FileCopyrightText: 2007-2008 David Nolden <david.nolden.kdevelop@art-master.de>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-only
0007 */
0008 
0009 #ifndef KDEVPLATFORM_DELAYEDTYPE_H
0010 #define KDEVPLATFORM_DELAYEDTYPE_H
0011 
0012 #include "abstracttype.h"
0013 #include "../identifier.h"
0014 
0015 namespace KDevelop {
0016 class DelayedTypeData;
0017 
0018 /**
0019  * \short A type which has not yet been resolved.
0020  *
0021  * Delayed types can be used for any types that cannot be resolved in the moment they are encountered.
0022  * They can be used for example in template-classes, or to store the names of unresolved types.
0023  * In a template-class, many types can not be evaluated at the time they are used, because they depend on unknown template-parameters.
0024  * Delayed types store the way the type would be searched, and can be used to find the type once the template-paremeters have values.
0025  * */
0026 class KDEVPLATFORMLANGUAGE_EXPORT DelayedType
0027     : public KDevelop::AbstractType
0028 {
0029 public:
0030     using Ptr = TypePtr<DelayedType>;
0031 
0032     /// An enumeration of
0033     enum Kind : quint8 {
0034         Delayed /**< The type should be resolved later. This is the default. */,
0035         Unresolved /**< The type could not be resolved */
0036     };
0037 
0038     /// Default constructor
0039     DelayedType();
0040     /// Copy constructor. \param rhs type to copy
0041     DelayedType(const DelayedType& rhs);
0042     /// Constructor using raw data. \param data internal data.
0043     explicit DelayedType(DelayedTypeData& data);
0044     /// Destructor
0045     ~DelayedType() override;
0046 
0047     DelayedType& operator=(const DelayedType& rhs) = delete;
0048 
0049     /**
0050      * Access the type identifier which this type represents.
0051      *
0052      * \returns the type identifier.
0053      */
0054     KDevelop::IndexedTypeIdentifier identifier() const;
0055 
0056     /**
0057      * Set the type identifier which this type represents.
0058      *
0059      * \param identifier the type identifier.
0060      */
0061     void setIdentifier(const KDevelop::IndexedTypeIdentifier& identifier);
0062 
0063     QString toString() const override;
0064 
0065     AbstractType* clone() const override;
0066 
0067     bool equals(const AbstractType* rhs) const override;
0068 
0069     Kind kind() const;
0070     void setKind(Kind kind);
0071 
0072     uint hash() const override;
0073 
0074     WhichType whichType() const override;
0075 
0076     enum {
0077         Identity = 8
0078     };
0079 
0080     using Data = DelayedTypeData;
0081 
0082 protected:
0083     void accept0 (KDevelop::TypeVisitor* v) const override;
0084     TYPE_DECLARE_DATA(DelayedType)
0085 };
0086 }
0087 
0088 #endif