[beast: 3/8] BSE: move Bus methods connect_bus(), disconnect_bus(), disconnect_track() to bseapi.idl



commit 54488c7c09934e384a92fd67e7156892ad65d4e9
Author: Tim Janik <timj gnu org>
Date:   Thu Sep 17 12:47:50 2015 +0200

    BSE: move Bus methods connect_bus(), disconnect_bus(), disconnect_track() to bseapi.idl

 bse/Makefile.am |    2 +-
 bse/bseapi.idl  |    6 +-
 bse/bsebus.cc   |   87 +++++++++++++++++++++++++++++++++++----
 bse/bsebus.hh   |   11 +++--
 bse/bsebus.proc |  122 -------------------------------------------------------
 5 files changed, 90 insertions(+), 138 deletions(-)
---
diff --git a/bse/Makefile.am b/bse/Makefile.am
index 3247128..a5dde2f 100644
--- a/bse/Makefile.am
+++ b/bse/Makefile.am
@@ -117,7 +117,7 @@ idl_dummy_files = $(strip   \
 bse_proc_sources = $(strip \
        bsecategories.proc      bsecontainer.proc       bsedatapocket.proc      bseeditablesample.proc  \
        bsejanitor.proc                                 bseparasite.proc        bseprocedure.proc       
bseproject.proc \
-                               bsesong.proc            bsebus.proc             bsesource.proc          
bsesnet.proc \
+                               bsesong.proc                                    bsesource.proc          
bsesnet.proc \
        bsetrack.proc           bseitem.proc            bsewave.proc            bsewaveosc.proc         
bsewaverepo.proc \
 )
 bse_proc_gen_sources = $(bse_proc_sources:.proc=.genprc.cc)
diff --git a/bse/bseapi.idl b/bse/bseapi.idl
index 14509d6..c7eb91c 100644
--- a/bse/bseapi.idl
+++ b/bse/bseapi.idl
@@ -508,10 +508,10 @@ sequence PartLinkSeq {
 /// Interface for effect stacks and per-track audio signal routing to the master output.
 interface Bus : SubSynth {
   ErrorType ensure_output    ();            ///< Ensure that a bus has an output connection.
-  // ErrorType connect_bus      (Bus bus);     ///< Add a bus to the input list of a bus.
+  ErrorType connect_bus      (Bus bus);     ///< Add a bus to the input list of a bus.
   ErrorType connect_track    (Track track); ///< Add a track to the input list of a bus.
-  // ErrorType disconnect_bus   (Bus bus);     ///< Remove a bus from the input list of a bus.
-  // ErrorType disconnect_track (Track track); ///< Remove a track from the input list of a bus.
+  ErrorType disconnect_bus   (Bus bus);     ///< Remove a bus from the input list of a bus.
+  ErrorType disconnect_track (Track track); ///< Remove a track from the input list of a bus.
   // ItemSeq   inputs        = Object ("Input Signals", "Synthesis signals (from tracks and busses) used as 
bus input", GUI ":item-sequence");
   // ItemSeq   outputs       = Object ("Output Signals", "Mixer busses used as output for synthesis 
signals", GUI ":item-sequence");
   // CSynth    snet          = Object ("SNet", "Synthesis network used internally to implement effect 
stack", READWRITE ":skip-undo");
diff --git a/bse/bsebus.cc b/bse/bsebus.cc
index 9e519b5..209b7be 100644
--- a/bse/bsebus.cc
+++ b/bse/bsebus.cc
@@ -940,30 +940,101 @@ BusImpl::ensure_output ()
   if (BSE_IS_SONG (parent) && !self->bus_outputs)
     {
       BseSong *song = BSE_SONG (parent);
-      BseBus *master = bse_song_find_master (song);
-      if (master && self != master)
+      BseBus *masterp = bse_song_find_master (song);
+      if (masterp && self != masterp)
         {
-          error = bse_bus_connect (master, BSE_ITEM (self));
+          BusImpl &master = *masterp->as<BusImpl*>();
+          error = bse_bus_connect (masterp, self);
           if (!error)
-            bse_item_push_undo_proc (master, "disconnect-bus", self);
+            {
+              // an undo lambda is needed for wrapping object argument references
+              UndoDescriptor<BusImpl> bus_descriptor = master.undo_descriptor (*this);
+              auto lambda = [bus_descriptor] (BusImpl &master, BseUndoStack *ustack) -> ErrorType {
+                BusImpl &bus = master.undo_resolve (bus_descriptor);
+                return master.disconnect_bus (bus);
+              };
+              master.push_undo ("Ensure Output", master, lambda);
+            }
         }
     }
   return error;
 }
 
 ErrorType
+BusImpl::connect_bus (BusIface &busi)
+{
+  BseBus *self = as<BseBus*>();
+  BusImpl &bus = dynamic_cast<BusImpl&> (busi);
+  if (!this->parent() || this->parent() != bus.parent())
+    return ERROR_SOURCE_PARENT_MISMATCH;
+
+  ErrorType error = bse_bus_connect (self, bus.as<BseItem*>());
+  if (!error)
+    {
+      // an undo lambda is needed for wrapping object argument references
+      UndoDescriptor<BusImpl> bus_descriptor = undo_descriptor (bus);
+      auto lambda = [bus_descriptor] (BusImpl &self, BseUndoStack *ustack) -> ErrorType {
+        return self.disconnect_bus (self.undo_resolve (bus_descriptor));
+      };
+      push_undo ("Connect Bus", *this, lambda);
+    }
+  return error;
+}
+
+ErrorType
 BusImpl::connect_track (TrackIface &tracki)
 {
   BseBus *self = as<BseBus*>();
   TrackImpl &track = dynamic_cast<TrackImpl&> (tracki);
-
   if (!this->parent() || this->parent() != track.parent())
     return ERROR_SOURCE_PARENT_MISMATCH;
 
-  BseItem *track_item = track.as<BseItem*>();
-  ErrorType error = bse_bus_connect (self, track_item);
+  ErrorType error = bse_bus_connect (self, track.as<BseItem*>());
   if (!error)
-    bse_item_push_undo_proc (self, "disconnect-track", track_item);
+    {
+      // an undo lambda is needed for wrapping object argument references
+      UndoDescriptor<TrackImpl> track_descriptor = undo_descriptor (track);
+      auto lambda = [track_descriptor] (BusImpl &self, BseUndoStack *ustack) -> ErrorType {
+        return self.disconnect_track (self.undo_resolve (track_descriptor));
+      };
+      push_undo ("Connect Track", *this, lambda);
+    }
+  return error;
+}
+
+ErrorType
+BusImpl::disconnect_bus (BusIface &busi)
+{
+  BseBus *self = as<BseBus*>();
+  BusImpl &bus = dynamic_cast<BusImpl&> (busi);
+  ErrorType error = bse_bus_disconnect (self, busi.as<BseItem*>());
+  if (!error)
+    {
+      // an undo lambda is needed for wrapping object argument references
+      UndoDescriptor<BusImpl> bus_descriptor = undo_descriptor (bus);
+      auto lambda = [bus_descriptor] (BusImpl &self, BseUndoStack *ustack) -> ErrorType {
+        return self.connect_bus (self.undo_resolve (bus_descriptor));
+      };
+      push_undo ("Remove Bus", *this, lambda);
+    }
+  return error;
+}
+
+ErrorType
+BusImpl::disconnect_track (TrackIface &tracki)
+{
+  BseBus *self = as<BseBus*>();
+  TrackImpl &track = dynamic_cast<TrackImpl&> (tracki);
+  ErrorType error = bse_bus_disconnect (self, tracki.as<BseItem*>());
+  if (!error)
+    {
+      // an undo lambda is needed for wrapping object argument references
+      UndoDescriptor<TrackImpl> track_descriptor = undo_descriptor (track);
+      auto lambda = [track_descriptor] (BusImpl &self, BseUndoStack *ustack) -> ErrorType {
+        return self.connect_track (self.undo_resolve (track_descriptor));
+      };
+      push_undo ("Remove Track", *this, lambda);
+    }
   return error;
 }
 
diff --git a/bse/bsebus.hh b/bse/bsebus.hh
index 0296683..0186971 100644
--- a/bse/bsebus.hh
+++ b/bse/bsebus.hh
@@ -82,11 +82,14 @@ namespace Bse {
 
 class BusImpl : public SubSynthImpl, public virtual BusIface {
 protected:
-  virtual           ~BusImpl      ();
+  virtual          ~BusImpl          ();
 public:
-  explicit          BusImpl       (BseObject*);
-  virtual ErrorType ensure_output () override;
-  virtual ErrorType connect_track (TrackIface &track);
+  explicit          BusImpl          (BseObject*);
+  virtual ErrorType ensure_output    () override;
+  virtual ErrorType connect_bus      (BusIface &bus) override;
+  virtual ErrorType connect_track    (TrackIface &track) override;
+  virtual ErrorType disconnect_bus   (BusIface &bus) override;
+  virtual ErrorType disconnect_track (TrackIface &track) override;
 };
 
 } // Bse


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]