OpenShot Library | OpenShotAudio 0.2.2
juce_CallbackMessage.h
1
2/** @weakgroup juce_events-messages
3 * @{
4 */
5/*
6 ==============================================================================
7
8 This file is part of the JUCE library.
9 Copyright (c) 2017 - ROLI Ltd.
10
11 JUCE is an open source library subject to commercial or open-source
12 licensing.
13
14 The code included in this file is provided under the terms of the ISC license
15 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
16 To use, copy, modify, and/or distribute this software for any purpose with or
17 without fee is hereby granted provided that the above copyright notice and
18 this permission notice appear in all copies.
19
20 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
21 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
22 DISCLAIMED.
23
24 ==============================================================================
25*/
26
27namespace juce
28{
29
30//==============================================================================
31/**
32 A message that invokes a callback method when it gets delivered.
33
34 You can use this class to fire off actions that you want to be performed later
35 on the message thread.
36
37 To use it, create a subclass of CallbackMessage which implements the messageCallback()
38 method, then call post() to dispatch it. The event thread will then invoke your
39 messageCallback() method later on, and will automatically delete the message object
40 afterwards.
41
42 Always create a new instance of a CallbackMessage on the heap, as it will be
43 deleted automatically after the message has been delivered.
44
45 Note that this class was essential back in the days before C++11, but in modern
46 times you may prefer to use MessageManager::callAsync() with a lambda.
47
48 @see MessageManager::callAsync, MessageListener, ActionListener, ChangeListener
49
50 @tags{Events}
51*/
53{
54public:
55 //==============================================================================
56 CallbackMessage() = default;
57
58 /** Destructor. */
59 ~CallbackMessage() override = default;
60
61 //==============================================================================
62 /** Called when the message is delivered.
63
64 You should implement this method and make it do whatever action you want
65 to perform.
66
67 Note that like all other messages, this object will be deleted immediately
68 after this method has been invoked.
69 */
70 virtual void messageCallback() override = 0;
71
72private:
73 // Avoid the leak-detector because for plugins, the host can unload our DLL with undelivered
74 // messages still in the system event queue. These aren't harmful, but can cause annoying assertions.
75 JUCE_DECLARE_NON_COPYABLE (CallbackMessage)
76};
77
78} // namespace juce
79
80/** @}*/
A message that invokes a callback method when it gets delivered.
virtual void messageCallback() override=0
Called when the message is delivered.
~CallbackMessage() override=default
Destructor.
Internal class used as the base class for all message objects.
#define JUCE_API
This macro is added to all JUCE public class declarations.