rearrange inheritance so that Automatable IS-A Slavable
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 25 Apr 2016 17:41:38 +0000 (13:41 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 31 May 2016 19:30:41 +0000 (15:30 -0400)
Share assign code via Slavable; add visibility tags to Slavable+SlavableAutomationControl

libs/ardour/ardour/automatable.h
libs/ardour/ardour/route.h
libs/ardour/ardour/slavable.h
libs/ardour/ardour/slavable_automation_control.h
libs/ardour/ardour/vca.h
libs/ardour/route.cc
libs/ardour/slavable.cc
libs/ardour/vca.cc

index c9e14cfae5170f00ad660d3a1240987bc106c99c..5f9f7d2b91165d271145023178ad871aa85e1f80 100644 (file)
 #include <map>
 #include <set>
 #include <string>
+
 #include <boost/shared_ptr.hpp>
+
 #include "pbd/signals.h"
+
 #include "evoral/ControlSet.hpp"
+
 #include "ardour/libardour_visibility.h"
+#include "ardour/slavable.h"
 #include "ardour/types.h"
 
 class XMLNode;
@@ -39,7 +44,7 @@ class AutomationControl;
 /* The inherited ControlSet is virtual because AutomatableSequence inherits
  * from this AND EvoralSequence, which is also a ControlSet
  */
-class LIBARDOUR_API Automatable : virtual public Evoral::ControlSet
+class LIBARDOUR_API Automatable : virtual public Evoral::ControlSet, public Slavable
 {
 public:
        Automatable(Session&);
@@ -47,17 +52,17 @@ public:
 
         virtual ~Automatable();
 
-       boost::shared_ptr<Evoral::Control>
-       control_factory(const Evoral::Parameter& id);
+       boost::shared_ptr<Evoral::Control> control_factory(const Evoral::Parameter& id);
 
-       boost::shared_ptr<AutomationControl>
-       automation_control (const Evoral::Parameter& id, bool create_if_missing=false);
+       boost::shared_ptr<AutomationControl> automation_control (const Evoral::Parameter& id) {
+               return automation_control (id, false);
+       }
 
-       boost::shared_ptr<const AutomationControl>
-       automation_control (const Evoral::Parameter& id) const;
+       boost::shared_ptr<AutomationControl> automation_control (const Evoral::Parameter& id, bool create_if_missing);
+       boost::shared_ptr<const AutomationControl> automation_control (const Evoral::Parameter& id) const;
 
        virtual void add_control(boost::shared_ptr<Evoral::Control>);
-       virtual bool find_next_event(double start, double end, Evoral::ControlEvent& ev, bool only_active = true) const;
+       virtual bool find_next_event (double start, double end, Evoral::ControlEvent& ev, bool only_active = true) const;
        void clear_controls ();
 
         virtual void transport_located (framepos_t now);
index 52be8c94b40142dd90165bddb836c336e42f0db9..2e2c1ccf7221e3624b1c87a10d4ac5380732e96e 100644 (file)
@@ -91,7 +91,6 @@ class LIBARDOUR_API Route : public GraphNode,
                             public Monitorable,
                             public Automatable,
                             public RouteGroupMember,
-                            public Slavable,
                             public boost::enable_shared_from_this<Route>
 {
 public:
@@ -612,9 +611,6 @@ public:
        virtual void set_block_size (pframes_t nframes);
 
   protected:
-       int assign_controls (boost::shared_ptr<VCA>);
-       int unassign_controls (boost::shared_ptr<VCA>);
-
         virtual framecnt_t check_initial_delay (framecnt_t nframes, framepos_t&) { return nframes; }
 
        void fill_buffers_with_input (BufferSet& bufs, boost::shared_ptr<IO> io, pframes_t nframes);
index b0ef33e1b43a35ce1d6a49c67cbdbdf1bc62b36e..147f90fda0b9f74fb292e86b3a08a0a569d47e77 100644 (file)
 
 #include <boost/shared_ptr.hpp>
 
-#include <pbd/signals.h>
+#include "pbd/signals.h"
+
+#include "evoral/Parameter.hpp"
+
+#include "ardour/libardour_visibility.h"
 
 class XMLNode;
 
@@ -34,8 +38,9 @@ namespace ARDOUR {
 
 class VCA;
 class VCAManager;
+class AutomationControl;
 
-class Slavable
+class LIBARDOUR_API Slavable
 {
     public:
        Slavable ();
@@ -47,14 +52,16 @@ class Slavable
        void assign (boost::shared_ptr<VCA>);
        void unassign (boost::shared_ptr<VCA>);
 
+       virtual boost::shared_ptr<AutomationControl> automation_control (const Evoral::Parameter& id) = 0;
+
        static std::string xml_node_name;
 
        /* signal sent VCAManager once assignment is possible */
        static PBD::Signal1<void,VCAManager*> Assign;
 
     protected:
-       virtual int assign_controls (boost::shared_ptr<VCA>) = 0;
-       virtual int unassign_controls (boost::shared_ptr<VCA>) = 0;
+       virtual int assign_controls (boost::shared_ptr<VCA>);
+       virtual int unassign_controls (boost::shared_ptr<VCA>);
 
     private:
        mutable Glib::Threads::RWLock master_lock;
index 98745e025d091a317d3461db5a5cc957e6800739..45b555595fad2b97c935b56d6c350af69ccf61cd 100644 (file)
 #define __ardour_slavable_automation_control_h__
 
 #include "ardour/automation_control.h"
+#include "ardour/libardour_visibility.h"
 
 namespace ARDOUR {
 
-class SlavableAutomationControl : public AutomationControl
+class LIBARDOUR_API SlavableAutomationControl : public AutomationControl
 {
     public:
        SlavableAutomationControl(ARDOUR::Session&,
index 926cd500e03df94fb7044626e6fcbb7a821c9f15..4225605f9b41b43a0b740c42e6b609c6932bae57 100644 (file)
@@ -46,7 +46,6 @@ class LIBARDOUR_API VCA : public Stripable,
                           public Soloable,
                           public Muteable,
                           public Automatable,
-                          public Slavable,
                           public Recordable,
                           public Monitorable,
                           public boost::enable_shared_from_this<VCA> {
@@ -132,10 +131,6 @@ class LIBARDOUR_API VCA : public Stripable,
        virtual std::string send_name (uint32_t n) const { return std::string(); }
        virtual boost::shared_ptr<AutomationControl> master_send_enable_controllable () const { return boost::shared_ptr<AutomationControl>(); }
 
-  protected:
-       int assign_controls (boost::shared_ptr<VCA>);
-       int unassign_controls (boost::shared_ptr<VCA>);
-
   private:
        uint32_t    _number;
 
index c36e501aefde8e1d9bf1c59add2658568ede0908..a449540c6fbf82e64b5bc1d0e910c73f0f58fb54 100644 (file)
@@ -5444,33 +5444,6 @@ Route::slaved_to (boost::shared_ptr<VCA> vca) const
        return _gain_control->slaved_to (vca->gain_control());
 }
 
-int
-Route::assign_controls (boost::shared_ptr<VCA> vca)
-{
-       _gain_control->add_master (vca->gain_control());
-       _solo_control->add_master (vca->solo_control());
-       _mute_control->add_master (vca->mute_control());
-
-       return 0;
-}
-
-int
-Route::unassign_controls (boost::shared_ptr<VCA> vca)
-{
-       if (!vca) {
-               /* unassign from all */
-               _gain_control->clear_masters ();
-               _solo_control->clear_masters ();
-               _mute_control->clear_masters ();
-       } else {
-               _gain_control->remove_master (vca->gain_control());
-               _solo_control->remove_master (vca->solo_control());
-               _mute_control->remove_master (vca->mute_control());
-       }
-
-       return 0;
-}
-
 bool
 Route::muted_by_others_soloing () const
 {
index 7a7b8e291947bc4c85d66b4293357414426f5de5..4a759f5fef41a20abd567a74d314e731cf16ec3b 100644 (file)
@@ -26,6 +26,7 @@
 #include "pbd/xml++.h"
 
 #include "ardour/slavable.h"
+#include "ardour/slavable_automation_control.h"
 #include "ardour/vca.h"
 #include "ardour/vca_manager.h"
 
@@ -127,3 +128,59 @@ Slavable::unassign (boost::shared_ptr<VCA> v)
        (void) unassign_controls (v);
        _masters.erase (v->number());
 }
+
+int
+Slavable::assign_controls (boost::shared_ptr<VCA> vca)
+{
+       boost::shared_ptr<SlavableAutomationControl> slave;
+       boost::shared_ptr<AutomationControl> master;
+       AutomationType types[] = {
+               GainAutomation,
+               SoloAutomation,
+               MuteAutomation,
+               RecEnableAutomation,
+               MonitoringAutomation,
+               NullAutomation
+       };
+
+       for (uint32_t n = 0; types[n] != NullAutomation; ++n) {
+
+               slave = boost::dynamic_pointer_cast<SlavableAutomationControl> (automation_control (types[n]));
+               master = vca->automation_control (types[n]);
+
+               if (slave && master) {
+                       slave->add_master (master);
+               }
+       }
+
+       return 0;
+}
+
+int
+Slavable::unassign_controls (boost::shared_ptr<VCA> vca)
+{
+       boost::shared_ptr<SlavableAutomationControl> slave;
+       boost::shared_ptr<AutomationControl> master;
+       AutomationType types[] = {
+               GainAutomation,
+               SoloAutomation,
+               MuteAutomation,
+               RecEnableAutomation,
+               MonitoringAutomation,
+               NullAutomation
+       };
+
+       for (uint32_t n = 0; types[n] != NullAutomation; ++n) {
+
+               slave = boost::dynamic_pointer_cast<SlavableAutomationControl> (automation_control (types[n]));
+               if (!vca) {
+                       /* unassign from all */
+                       slave->clear_masters ();
+               } else {
+                       slave->remove_master (master);
+               }
+       }
+
+       return 0;
+}
+
index 2d1fbdec8fa929764ff0417d30821b1b9960a11d..8227bf87494c477f1f40146f03e552432987f4ef 100644 (file)
@@ -161,61 +161,6 @@ VCA::clear_all_solo_state ()
        _solo_control->clear_all_solo_state ();
 }
 
-int
-VCA::assign_controls (boost::shared_ptr<VCA> vca)
-{
-       boost::shared_ptr<SlavableAutomationControl> slave;
-       boost::shared_ptr<AutomationControl> master;
-       AutomationType types[] = {
-               GainAutomation,
-               SoloAutomation,
-               MuteAutomation,
-               RecEnableAutomation,
-               MonitoringAutomation,
-               NullAutomation
-       };
-
-       for (uint32_t n = 0; types[n] != NullAutomation; ++n) {
-
-               slave = boost::dynamic_pointer_cast<SlavableAutomationControl> (automation_control (types[n]));
-               master = vca->automation_control (types[n]);
-
-               if (slave && master) {
-                       slave->add_master (master);
-               }
-       }
-
-       return 0;
-}
-
-int
-VCA::unassign_controls (boost::shared_ptr<VCA> vca)
-{
-       boost::shared_ptr<SlavableAutomationControl> slave;
-       boost::shared_ptr<AutomationControl> master;
-       AutomationType types[] = {
-               GainAutomation,
-               SoloAutomation,
-               MuteAutomation,
-               RecEnableAutomation,
-               MonitoringAutomation,
-               NullAutomation
-       };
-
-       for (uint32_t n = 0; types[n] != NullAutomation; ++n) {
-
-               slave = boost::dynamic_pointer_cast<SlavableAutomationControl> (automation_control (types[n]));
-               if (!vca) {
-                       /* unassign from all */
-                       slave->clear_masters ();
-               } else {
-                       slave->remove_master (master);
-               }
-       }
-
-       return 0;
-}
-
 MonitorState
 VCA::monitoring_state () const
 {