fix SConstruct so that it can build from a git checkout rather than an svn checkout
[ardour.git] / libs / ardour / ardour / port.h
index c1e502727f44cc53dc03b25d6fb6d96d95e385f0..084022541d3993d3c9639237215e87f0dbc501a8 100644 (file)
 #ifndef __ardour_port_h__
 #define __ardour_port_h__
 
+#include <set>
+#include <vector>
+#include <string>
+#include <cstring>
 #include <sigc++/signal.h>
 #include <pbd/failed_constructor.h>
 #include <ardour/ardour.h>
@@ -43,13 +47,12 @@ class Port : public virtual sigc::trackable {
                CanMonitor = JackPortCanMonitor
        };
 
-       virtual ~Port() {}
+       virtual ~Port();
 
        std::string name() const { 
                return _name;
        }
 
-
        Flags flags() const {
                return _flags;
        }
@@ -59,7 +62,7 @@ class Port : public virtual sigc::trackable {
        }
 
        bool sends_output () const {
-               return _flags & JackPortIsOutput;
+               return _flags & IsOutput;
        }
 
        bool can_monitor () const {
@@ -73,18 +76,30 @@ class Port : public virtual sigc::trackable {
        void disable_metering () {
                if (_metering) { _metering--; }
        }
-       
+
+       virtual void cycle_start (nframes_t nframes, nframes_t offset) {}
+       virtual void cycle_end (nframes_t nframes, nframes_t offset) {}
        virtual DataType type() const = 0;
-       virtual void cycle_start(nframes_t nframes) {}
-       virtual void cycle_end() {}
        virtual Buffer& get_buffer() = 0;
-       virtual std::string short_name() = 0;
-       virtual int set_name (std::string str) = 0;
-       virtual bool is_mine (jack_client_t *client) = 0;
-       virtual int reestablish () = 0;
-       virtual int connected () const = 0;
-       virtual bool connected_to (const std::string& portname) const = 0;
-       virtual const char ** get_connections () const = 0;
+
+       virtual bool connected () const;
+       virtual bool connected_to (const std::string& portname) const;
+       virtual int get_connections (std::vector<std::string>&) const;
+
+       virtual int connect (Port& other);
+       virtual int disconnect (Port& other);
+       virtual int disconnect_all ();
+       
+       virtual void reset ();
+       virtual int reestablish () {return 0; }
+       virtual int reconnect () { return 0; }
+
+       virtual int set_name (const std::string& str) {
+               _name = str;
+               return 0;
+       }
+
+       virtual std::string short_name() const = 0;
        virtual bool monitoring_input () const = 0;
        virtual void ensure_monitor_input (bool yn) = 0;
        virtual void request_monitor_input (bool yn) = 0;
@@ -95,24 +110,71 @@ class Port : public virtual sigc::trackable {
        sigc::signal<void,bool> MonitorInputChanged;
        sigc::signal<void,bool> ClockSyncChanged;
 
+       static void set_engine (AudioEngine*);
+
   protected:
        friend class AudioEngine;
 
-       Port ();
+       Port (const std::string& name, Flags flgs);
 
-       virtual int disconnect () = 0;
-       virtual void recompute_total_latency() const = 0;
-       virtual void reset ();
+       virtual void recompute_total_latency() const {}
        
        /* engine isn't supposed to access below here */
 
-       Flags _flags;
+       Flags          _flags;
        std::string    _type;
        std::string    _name;
        unsigned short _metering;
        bool           _last_monitor;
+       nframes_t      _latency;
+
+       std::set<Port*> _connections;
+
+       static AudioEngine* engine;
+};
+
+class PortConnectableByName {
+  public:
+       PortConnectableByName() {}
+       virtual ~PortConnectableByName() {}
+
+       virtual int connect (const std::string& other_name) = 0;
+       virtual int disconnect (const std::string& other_name) = 0;
 };
  
+class PortFacade : public virtual Port, public PortConnectableByName { 
+  public:
+       PortFacade (const std::string& name, Flags flgs) : Port (name, flgs), _ext_port (0) {}
+       ~PortFacade() {}
+
+       void reset ();
+       int reestablish ();
+       int reconnect ();
+
+       int connect (Port& other);
+       int disconnect (Port& other);
+       int disconnect_all ();
+
+       int connect (const std::string& other_name);
+       int disconnect (const std::string& other_name);
+
+       bool connected () const;
+       bool connected_to (const std::string& portname) const;
+       int get_connections (std::vector<std::string>&) const;
+
+       std::string short_name() const;
+       int         set_name (const std::string& str);
+       bool        monitoring_input () const;
+       void        ensure_monitor_input (bool yn);
+       void        request_monitor_input (bool yn);
+       nframes_t   latency () const;
+       nframes_t   total_latency () const;
+       void        set_latency (nframes_t nframes);
+
+  protected:
+       Port* _ext_port;
+};
+
 } // namespace ARDOUR
 
 #endif /* __ardour_port_h__ */