DISTRHO Plugin Framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.8KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef DGL_APP_HPP_INCLUDED
  17. #define DGL_APP_HPP_INCLUDED
  18. #include "Base.hpp"
  19. START_NAMESPACE_DGL
  20. // --------------------------------------------------------------------------------------------------------------------
  21. // Forward class names
  22. class Window;
  23. // --------------------------------------------------------------------------------------------------------------------
  24. /**
  25. Base DGL Application class.
  26. One application instance is required for creating a window.
  27. There's no single/global application instance in DGL, and multiple windows can share the same app instance.
  28. In standalone mode an application will automatically quit its event-loop when all its windows are closed.
  29. */
  30. class Application
  31. {
  32. public:
  33. /**
  34. Constructor.
  35. */
  36. // NOTE: the default value is not yet passed, so we catch where we use this
  37. Application(bool isStandalone /* = true */);
  38. /**
  39. Destructor.
  40. */
  41. virtual ~Application();
  42. /**
  43. Idle function.
  44. This runs the application event-loop once.
  45. */
  46. void idle();
  47. /**
  48. Run the application event-loop until all Windows are closed.
  49. idle() is called at regular intervals.
  50. @note This function is meant for standalones only, *never* call this from plugins.
  51. */
  52. void exec(uint idleTimeInMs = 10);
  53. /**
  54. Quit the application.
  55. This stops the event-loop and closes all Windows.
  56. @note This function is meant for standalones only, *never* call this from plugins.
  57. */
  58. void quit();
  59. /**
  60. Check if the application is about to quit.
  61. Returning true means there's no event-loop running at the moment (or it's just about to stop).
  62. */
  63. bool isQuiting() const noexcept;
  64. private:
  65. struct PrivateData;
  66. PrivateData* const pData;
  67. friend class Window;
  68. DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Application)
  69. };
  70. // --------------------------------------------------------------------------------------------------------------------
  71. END_NAMESPACE_DGL
  72. #endif // DGL_APP_HPP_INCLUDED