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.

context.hpp 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #pragma once
  2. #include <common.hpp>
  3. namespace rack {
  4. namespace history {
  5. struct State;
  6. } // namespace history
  7. namespace engine {
  8. struct Engine;
  9. } // namespace engine
  10. namespace window {
  11. struct Window;
  12. } // namespace window
  13. namespace patch {
  14. struct Manager;
  15. } // namespace patch
  16. namespace widget {
  17. struct EventState;
  18. } // namespace widget
  19. namespace app {
  20. struct Scene;
  21. } // namespace app
  22. /** Rack instance state
  23. */
  24. struct Context {
  25. widget::EventState* event = NULL;
  26. app::Scene* scene = NULL;
  27. engine::Engine* engine = NULL;
  28. window::Window* window = NULL;
  29. history::State* history = NULL;
  30. patch::Manager* patch = NULL;
  31. ~Context();
  32. };
  33. /** Returns the global Context pointer */
  34. Context* contextGet();
  35. /** Sets the context for this thread.
  36. You must set the context when preparing each thread if the code uses the APP macro in that thread.
  37. */
  38. void contextSet(Context* context);
  39. /** Deprecated. Use contextGet() or the APP macro to get the current Context. */
  40. DEPRECATED inline Context* appGet() {
  41. return contextGet();
  42. }
  43. /** Accesses the global Context pointer. Just an alias for contextGet(). */
  44. #define APP rack::contextGet()
  45. } // namespace rack