File indexing completed on 2024-05-12 04:42:42
0001 /* 0002 SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KPUBLICTRANSPORT_DATATYPES_H 0008 #define KPUBLICTRANSPORT_DATATYPES_H 0009 0010 #include "kpublictransport_export.h" 0011 0012 #include <QMetaType> 0013 #include <QSharedDataPointer> 0014 0015 #include <type_traits> 0016 0017 class QVariant; 0018 0019 namespace KPublicTransport { 0020 namespace Internal { 0021 template <typename T> 0022 struct parameter_type 0023 { 0024 using type = typename std::conditional<std::is_fundamental<T>::value || std::is_enum<T>::value, T, const T&>::type; 0025 }; 0026 } 0027 } 0028 0029 #define KPUBLICTRANSPORT_GADGET(Class) \ 0030 Q_GADGET \ 0031 public: \ 0032 Class(); \ 0033 Class(Class&&) noexcept; \ 0034 Class(const Class&); \ 0035 ~Class(); \ 0036 Class& operator=(Class&&) noexcept; \ 0037 Class& operator=(const Class&); \ 0038 operator QVariant () const; \ 0039 private: \ 0040 friend class Class ## Private; \ 0041 QExplicitlySharedDataPointer<Class ## Private> d; 0042 0043 #define KPUBLICTRANSPORT_PROPERTY(Type, Getter, Setter) \ 0044 public: \ 0045 Q_PROPERTY(Type Getter READ Getter WRITE Setter) \ 0046 Type Getter() const; \ 0047 void Setter(KPublicTransport::Internal::parameter_type<Type>::type value); \ 0048 0049 0050 #endif