Akonadi

supertrait.h
1/*
2 SPDX-FileCopyrightText: 2009 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9namespace Akonadi
10{
11namespace Internal
12{
13template<typename T>
14struct check_type {
15 using type = void;
16};
17}
18
19/**
20 @internal
21 @see SuperClass
22*/
23template<typename Super, typename = void>
25 using Type = Super;
26};
27
28template<typename Class>
29struct SuperClassTrait<Class, typename Internal::check_type<typename Class::SuperClass>::type> {
30 using Type = typename Class::SuperClass;
31};
32
33/**
34 Type trait to provide information about a base class for a given class.
35 Used eg. for the Akonadi payload mechanism.
36
37 To provide base class introspection for own types, extend this trait as follows:
38 @code
39 namespace Akonadi
40 {
41 template <> struct SuperClass<MyClass> : public SuperClassTrait<MyBaseClass>{};
42 }
43 @endcode
44
45 Alternatively, define a typedef "SuperClass" in your type, pointing to the base class.
46 This avoids having to include this header file if that's inconvenient from a dependency
47 point of view.
48*/
49template<typename Class>
50struct SuperClass : public SuperClassTrait<Class> {
51};
52}
Helper integration between Akonadi and Qt.
Type trait to provide information about a base class for a given class.
Definition supertrait.h:50
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:38 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.