LeechCraft
0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
introspectable.h
Go to the documentation of this file.
1
/**********************************************************************
2
* LeechCraft - modular cross-platform feature rich internet client.
3
* Copyright (C) 2006-2014 Georg Rudoy
4
*
5
* Distributed under the Boost Software License, Version 1.0.
6
* (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7
**********************************************************************/
8
9
#pragma once
10
11
#include <functional>
12
#include <QHash>
13
#include <QMetaType>
14
#include <QVariantMap>
15
#include "
xpcconfig.h
"
16
17
namespace
LC::Util
18
{
19
using
Introspect_f
= std::function<
QVariantMap
(
QVariant
)>;
20
21
class
UTIL_XPC_API
Introspectable
22
{
23
QHash<int, Introspect_f> Intros_;
24
25
Introspectable
() =
default
;
26
public
:
27
Introspectable
(
const
Introspectable
&) =
delete
;
28
Introspectable
& operator= (
const
Introspectable
&) =
delete
;
29
30
static
Introspectable
& Instance ();
31
32
template
<
typename
T,
typename
U>
33
void
Register
(
const
U& intro)
34
{
35
if
constexpr
(std::is_invocable_v<U, QVariant>)
36
{
37
const
auto
id
= qMetaTypeId<T> ();
38
Intros_ [id] = intro;
39
}
40
else
41
Register<T> ([intro] (
const
QVariant& var) {
return
std::invoke (intro, var.value<T> ()); });
42
}
43
44
template
<
typename
T>
45
QVariantMap operator() (
const
T& t)
const
46
{
47
return
(*
this
) (QVariant::fromValue<T> (t));
48
}
49
50
QVariantMap operator() (
const
QVariant&)
const
;
51
};
52
}
LC::Util::Introspectable
Definition
introspectable.h:22
LC::Util::Introspectable::Introspectable
Introspectable(const Introspectable &)=delete
LC::Util::Introspectable::Register
void Register(const U &intro)
Definition
introspectable.h:33
LC::Util
Definition
icoreproxy.h:34
LC::Util::Introspect_f
std::function< QVariantMap(QVariant)> Introspect_f
Definition
introspectable.h:19
LC::Util::Filter
Container< T > Filter(const Container< T > &c, F f)
Definition
prelude.h:118
xpcconfig.h
UTIL_XPC_API
#define UTIL_XPC_API
Definition
xpcconfig.h:16
src
util
xpc
introspectable.h
Generated by
1.10.0