OpenShot Audio Library | OpenShotAudio  0.3.1
juce_ApplicationBase.h
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2017 - ROLI Ltd.
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 
23 namespace juce
24 {
25 
26 //==============================================================================
84 class JUCE_API JUCEApplicationBase
85 {
86 protected:
87  //==============================================================================
89 
90 public:
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 
206  virtual void memoryWarningReceived() { jassertfalse; }
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 
298 private:
299  //==============================================================================
300  static JUCEApplicationBase* appInstance;
301  int appReturnValue = 0;
302  bool stillInitialising = true;
303 
304  struct MultipleInstanceHandler;
305  std::unique_ptr<MultipleInstanceHandler> multipleInstanceHandler;
306 
307  JUCE_DECLARE_NON_COPYABLE (JUCEApplicationBase)
308 };
309 
310 
311 //==============================================================================
312 #if JUCE_CATCH_UNHANDLED_EXCEPTIONS || defined (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
static JUCEApplicationBase * getInstance() noexcept
int getApplicationReturnValue() const noexcept
bool isInitialising() const noexcept
static bool isStandaloneApp() noexcept