JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_ApplicationBase.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26//==============================================================================
84class JUCE_API JUCEApplicationBase
85{
86protected:
87 //==============================================================================
89
90public:
92 virtual ~JUCEApplicationBase();
93
94 //==============================================================================
96 static JUCEApplicationBase* getInstance() noexcept { return appInstance; }
97
98 //==============================================================================
100 virtual const String getApplicationName() = 0;
101
103 virtual const String getApplicationVersion() = 0;
104
116 virtual bool moreThanOneInstanceAllowed() = 0;
117
137 virtual void initialise (const String& commandLineParameters) = 0;
138
139 /* Called to allow the application to clear up before exiting.
140
141 After JUCEApplication::quit() has been called, the event-dispatch loop will
142 terminate, and this method will get called to allow the app to sort itself
143 out.
144
145 Be careful that nothing happens in this method that might rely on messages
146 being sent, or any kind of window activity, because the message loop is no
147 longer running at this point.
148
149 @see DeletedAtShutdown
150 */
151 virtual void shutdown() = 0;
152
160 virtual void anotherInstanceStarted (const String& commandLine) = 0;
161
174 virtual void systemRequestedQuit() = 0;
175
179 virtual void suspended() = 0;
180
184 virtual void resumed() = 0;
185
194 virtual void unhandledException (const std::exception*,
195 const String& sourceFilename,
196 int lineNumber) = 0;
197
207
208 //==============================================================================
219 virtual bool backButtonPressed() { return false; }
220
221 //==============================================================================
235 static void quit();
236
237 //==============================================================================
241 static StringArray JUCE_CALLTYPE getCommandLineParameterArray();
242
246 static String JUCE_CALLTYPE getCommandLineParameters();
247
248 //==============================================================================
257 void setApplicationReturnValue (int newReturnValue) noexcept;
258
262 int getApplicationReturnValue() const noexcept { return appReturnValue; }
263
264 //==============================================================================
267 static bool isStandaloneApp() noexcept { return createInstance != nullptr; }
268
275 bool isInitialising() const noexcept { return stillInitialising; }
276
277
278 //==============================================================================
279 #ifndef DOXYGEN
280 // The following methods are for internal use only...
281 static int main();
282 static int main (int argc, const char* argv[]);
283
284 static void appWillTerminateByForce();
285 using CreateInstanceFunction = JUCEApplicationBase* (*)();
286 static CreateInstanceFunction createInstance;
287
288 #if JUCE_IOS
289 static void* iOSCustomDelegate;
290 #endif
291
292 virtual bool initialiseApp();
293 int shutdownApp();
294 static void JUCE_CALLTYPE sendUnhandledException (const std::exception*, const char* sourceFile, int lineNumber);
295 bool sendCommandLineToPreexistingInstance();
296 #endif
297
298private:
299 //==============================================================================
300 static JUCEApplicationBase* appInstance;
301 int appReturnValue = 0;
302 bool stillInitialising = true;
303
304 struct MultipleInstanceHandler;
305 std::unique_ptr<MultipleInstanceHandler> multipleInstanceHandler;
306
308};
309
310
311//==============================================================================
312#if JUCE_CATCH_UNHANDLED_EXCEPTIONS || DOXYGEN
313
318 #define JUCE_TRY try
319
324 #define JUCE_CATCH_EXCEPTION \
325 catch (const std::exception& e) { juce::JUCEApplicationBase::sendUnhandledException (&e, __FILE__, __LINE__); } \
326 catch (...) { juce::JUCEApplicationBase::sendUnhandledException (nullptr, __FILE__, __LINE__); }
327
328#else
329 #define JUCE_TRY
330 #define JUCE_CATCH_EXCEPTION
331#endif
332
333} // namespace juce
Abstract base class for application classes.
bool isInitialising() const noexcept
Returns true if the application hasn't yet completed its initialise() method and entered the main eve...
virtual void systemRequestedQuit()=0
Called when the operating system is trying to close the application.
virtual void initialise(const String &commandLineParameters)=0
Called when the application starts.
virtual const String getApplicationName()=0
Returns the application's name.
virtual void memoryWarningReceived()
Called by the operating system to indicate that you should reduce your memory footprint.
virtual void suspended()=0
This method is called when the application is being put into background mode by the operating system.
virtual void resumed()=0
This method is called when the application is being woken from background mode by the operating syste...
virtual void anotherInstanceStarted(const String &commandLine)=0
Indicates that the user has tried to start up another instance of the app.
virtual bool backButtonPressed()
This will be called when the back button on a device is pressed.
static JUCEApplicationBase * getInstance() noexcept
Returns the global instance of the application object that's running.
virtual const String getApplicationVersion()=0
Returns the application's version number.
static bool isStandaloneApp() noexcept
Returns true if this executable is running as an app (as opposed to being a plugin or other kind of s...
virtual void unhandledException(const std::exception *, const String &sourceFilename, int lineNumber)=0
If any unhandled exceptions make it through to the message dispatch loop, this callback will be trigg...
virtual bool moreThanOneInstanceAllowed()=0
Checks whether multiple instances of the app are allowed.
int getApplicationReturnValue() const noexcept
Returns the value that has been set as the application's exit code.
A special array for holding a list of strings.
The JUCE String class!
Definition juce_String.h:53
#define JUCE_DECLARE_NON_COPYABLE(className)
This is a shorthand macro for deleting a class's copy constructor and copy assignment operator.
#define jassertfalse
This will always cause an assertion failure.
#define JUCE_CALLTYPE
This macro defines the C calling convention used as the standard for JUCE calls.
JUCE Namespace.
shutdown