The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

88 lines
3.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. The code included in this file is provided under the terms of the ISC license
  8. http://www.isc.org/downloads/software-support-policy/isc-license. Permission
  9. To use, copy, modify, and/or distribute this software for any purpose with or
  10. without fee is hereby granted provided that the above copyright notice and
  11. this permission notice appear in all copies.
  12. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  13. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  14. DISCLAIMED.
  15. ==============================================================================
  16. */
  17. namespace juce
  18. {
  19. /** Base class for an entity that provides access to a blocks topology.
  20. @tags{Blocks}
  21. */
  22. class TopologySource
  23. {
  24. public:
  25. //==============================================================================
  26. /** Destructor. */
  27. virtual ~TopologySource() = default;
  28. /** Returns the current topology that this object manages. */
  29. virtual BlockTopology getCurrentTopology() const = 0;
  30. /** Sets the TopologySource as active, occupying the midi port and trying to connect to the block devices */
  31. virtual void setActive (bool shouldBeActive) = 0;
  32. /** Returns true, if the TopologySource is currently trying to connect the block devices */
  33. virtual bool isActive() const = 0;
  34. /** Returns true if the topology is locked externally.*/
  35. virtual bool isLockedFromOutside() const = 0;
  36. //==============================================================================
  37. /** Used to receive callbacks for topology changes */
  38. struct Listener
  39. {
  40. virtual ~Listener() = default;
  41. /** Called for any change in topology - devices changed, connections changed, etc. */
  42. virtual void topologyChanged() {}
  43. /** Called when a new block is added to the topology. */
  44. virtual void blockAdded (const Block::Ptr) {}
  45. /** Called when a block is removed from the topology. */
  46. virtual void blockRemoved (const Block::Ptr) {}
  47. /** Called when a known block is updated.
  48. This could be because details have been received asynchronously. E.g. Block name.
  49. */
  50. virtual void blockUpdated (const Block::Ptr) {}
  51. };
  52. void addListener (Listener* l) { listeners.add (l); }
  53. void removeListener (Listener* l) { listeners.remove (l); }
  54. /** Invoke this to force touches-off on all physical devices. */
  55. virtual void cancelAllActiveTouches() noexcept {}
  56. /** Gets blocks from the current topology. */
  57. Block::Array getBlocks() const { return getCurrentTopology().blocks; }
  58. /**Gets a block with given uid from the current topology*/
  59. Block::Ptr getBlockWithUID (Block::UID uid) const { return getCurrentTopology().getBlockWithUID (uid); }
  60. protected:
  61. //==============================================================================
  62. ListenerList<Listener> listeners;
  63. };
  64. } // namespace juce