Merge pull request #25808 from CastagnaIT/fix_url_parse
[xbmc.git] / xbmc / interfaces / legacy / CallbackHandler.h
blob223c74ad28b1b8196c9bb6abac7868b4dc148ba2
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "AddonClass.h"
12 #include "CallbackFunction.h"
14 namespace XBMCAddon
16 /**
17 * This is the abstraction representing different ways to handle
18 * the execution of callbacks. Different language bindings may
19 * have different requirements.
21 class CallbackHandler : public AddonClass
23 protected:
24 inline CallbackHandler() = default;
26 public:
27 virtual void invokeCallback(Callback* cb) = 0;
30 /**
31 * This class is primarily for Python support (hence the "Retarded"
32 * prefix). Python (et. al. Retarded languages) require that
33 * the context within which a callback executes is under the control
34 * of the language. Therefore, this handler is used to queue
35 * messages over to a language controlled thread for eventual
36 * execution.
38 * @todo Allow a cross thread synchronous execution.
39 * Fix the stupid means of calling the clearPendingCalls by passing
40 * userData which is specific to the handler/language type.
42 class RetardedAsyncCallbackHandler : public CallbackHandler
44 protected:
45 inline RetardedAsyncCallbackHandler() = default;
46 public:
48 ~RetardedAsyncCallbackHandler() override;
50 void invokeCallback(Callback* cb) override;
51 static void makePendingCalls();
52 static void clearPendingCalls(void* userData);
54 virtual bool isStateOk(AddonClass* obj) = 0;
55 virtual bool shouldRemoveCallback(AddonClass* obj, void* userData) = 0;