| Home · All Classes · All Namespaces · Modules · Functions · Files

feature.h

    00001
    00023 #ifndef _TelepathyQt_feature_h_HEADER_GUARD_
    00024 #define _TelepathyQt_feature_h_HEADER_GUARD_
    00025
    00026 #ifndef IN_TP_QT_HEADER
    00027 #error IN_TP_QT_HEADER
    00028 #endif
    00029
    00030 #include <TelepathyQt/Global>
    00031
    00032 #include <QMetaType>
    00033 #include <QPair>
    00034 #include <QSet>
    00035 #include <QSharedDataPointer>
    00036 #include <QString>
    00037
    00038 namespace Tp
    00039 {
    00040
    00041 class TP_QT_EXPORT Feature : public QPair<QString, uint>
    00042 {
    00043 public:
    00044     Feature();
    00045     Feature(const QString &className, uint id, bool critical = false);
    00046     Feature(const Feature &other);
    00047     ~Feature();
    00048
    00049     bool isValid() const { return mPriv.constData() != 0; }
    00050
    00051     Feature &operator=(const Feature &other);
    00052
    00053     bool isCritical() const;
    00054
    00055 private:
    00056     struct Private;
    00057     friend struct Private;
    00058     QSharedDataPointer<Private> mPriv;
    00059 };
    00060
    00061 class TP_QT_EXPORT Features : public QSet<Feature>
    00062 {
    00063 public:
    00064     Features() { }
    00065     Features(const Feature &feature) { insert(feature); }
    00066     Features(const QSet<Feature> &s) : QSet<Feature>(s) { }
    00067 };
    00068
    00069 inline Features operator|(const Feature &feature1, const Feature &feature2)
    00070 {
    00071     return Features() << feature1 << feature2;
    00072 }
    00073
    00074 inline Features operator|(const Features &features, const Feature &feature)
    00075 {
    00076     return Features(features) << feature;
    00077 }
    00078
    00079 inline uint qHash(const Features &features)
    00080 {
    00081     int ret = 0;
    00082     Q_FOREACH (const Feature &feature, features) {
    00083         int h = qHash(feature);
    00084         ret ^= h;
    00085     }
    00086     return ret;
    00087 }
    00088
    00089 } // Tp
    00090
    00091 Q_DECLARE_METATYPE(Tp::Feature);
    00092 Q_DECLARE_METATYPE(Tp::Features);
    00093
    00094 #endif