LeechCraft 0.6.70-17609-g3dde4097dd
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
defaulthookproxy.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 <QMap>
12#include "xpcconfig.h"
13#include "interfaces/iinfo.h"
15
16namespace LC::Util
17{
26 {
27 bool Cancelled_ = false;
28 QVariant ReturnValue_;
29
30 QMap<QByteArray, QVariant> Name2NewVal_;
31 public:
34 DefaultHookProxy () = default;
35
44
49 void CancelDefault () override;
50
60 bool IsCancelled () const;
61
64 const QVariant& GetReturnValue () const override;
65
68 void SetReturnValue (const QVariant&) override;
69
81 template<typename T>
82 void FillValue (const QByteArray& name, T& val)
83 {
84 if (!Name2NewVal_.contains (name))
85 return;
86
87 const QVariant& newVal = Name2NewVal_ [name];
88 if (!newVal.isValid ())
89 return;
90
91 val = newVal.value<T> ();
92 }
93
96 QVariant GetValue (const QByteArray&) const override;
97
100 void SetValue (const QByteArray&, const QVariant&) override;
101 };
102
103 using DefaultHookProxy_ptr = std::shared_ptr<DefaultHookProxy>;
104}
Class for hook-based communication between plugins.
Definition ihookproxy.h:54
void FillValue(const QByteArray &name, T &val)
Fills the value of the given parameter set by SetValue().
void SetReturnValue(const QVariant &) override
Reimplemented from IHookProxy::SetReturnValue().
bool IsCancelled() const
Returns whether the default implementation is canceled.
const QVariant & GetReturnValue() const override
Reimplemented from IHookProxy::GetReturnValue().
DefaultHookProxy()=default
Creates a new hook proxy.
void CancelDefault() override
Reimplemented from IHookProxy::CancelDefault().
Definition anutil.h:15
std::shared_ptr< DefaultHookProxy > DefaultHookProxy_ptr
#define UTIL_XPC_API
Definition xpcconfig.h:16