Audio plugin host https://kx.studio/carla
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.

130 lines
4.3KB

  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. /**
  22. Base DGL Application class.
  23. One application instance is required for creating a window.
  24. There's no single/global application instance in DGL, and multiple windows can share the same app instance.
  25. In standalone mode an application will automatically quit its event-loop when all its windows are closed.
  26. Unless stated otherwise, functions within this class are not thread-safe.
  27. */
  28. class DISTRHO_API Application
  29. {
  30. public:
  31. /**
  32. Constructor.
  33. */
  34. // NOTE: the default value is not yet passed, so we catch where we use this
  35. Application(bool isStandalone = true);
  36. /**
  37. Destructor.
  38. */
  39. virtual ~Application();
  40. /**
  41. Idle function.
  42. This runs the application event-loop once.
  43. */
  44. void idle();
  45. /**
  46. Run the application event-loop until all Windows are closed.
  47. idle() is called at regular intervals.
  48. @note This function is meant for standalones only, *never* call this from plugins.
  49. */
  50. void exec(uint idleTimeInMs = 30);
  51. /**
  52. Quit the application.
  53. This stops the event-loop and closes all Windows.
  54. This function is thread-safe.
  55. */
  56. void quit();
  57. /**
  58. Check if the application is about to quit.
  59. Returning true means there's no event-loop running at the moment (or it's just about to stop).
  60. This function is thread-safe.
  61. */
  62. bool isQuitting() const noexcept;
  63. /**
  64. Check if the application is standalone, otherwise running as a module or plugin.
  65. This function is thread-safe.
  66. */
  67. bool isStandalone() const noexcept;
  68. /**
  69. Return the time in seconds.
  70. This is a monotonically increasing clock with high resolution.@n
  71. The returned time is only useful to compare against other times returned by this function,
  72. its absolute value has no meaning.
  73. */
  74. double getTime() const;
  75. /**
  76. Add a callback function to be triggered on every idle cycle.
  77. You can add more than one, and remove them at anytime with removeIdleCallback().
  78. Idle callbacks trigger right after OS event handling and Window idle events (within the same cycle).
  79. There are no guarantees in terms of timing, use Window::addIdleCallback for time-relative callbacks.
  80. */
  81. void addIdleCallback(IdleCallback* callback);
  82. /**
  83. Remove an idle callback previously added via addIdleCallback().
  84. */
  85. void removeIdleCallback(IdleCallback* callback);
  86. /**
  87. Set the class name of the application.
  88. This is a stable identifier for the application, used as the window class/instance name on X11 and Windows.
  89. It is not displayed to the user, but can be used in scripts and by window managers,
  90. so it should be the same for every instance of the application, but different from other applications.
  91. Plugins created with DPF have their class name automatically set based on DGL_NAMESPACE and plugin name.
  92. */
  93. void setClassName(const char* name);
  94. private:
  95. struct PrivateData;
  96. PrivateData* const pData;
  97. friend class PluginApplication;
  98. friend class Window;
  99. DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Application)
  100. };
  101. // --------------------------------------------------------------------------------------------------------------------
  102. END_NAMESPACE_DGL
  103. #endif // DGL_APP_HPP_INCLUDED