Fix compilation.
[ardour.git] / libs / ardour / ardour / port.h
1 /*
2     Copyright (C) 2002 Paul Davis 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __ardour_port_h__
21 #define __ardour_port_h__
22
23 #include <sigc++/signal.h>
24 #include <pbd/failed_constructor.h>
25 #include <ardour/ardour.h>
26 #include <ardour/data_type.h>
27 #include <jack/jack.h>
28
29 namespace ARDOUR {
30
31 class AudioEngine;
32 class Buffer;
33
34 /** Abstract base for ports
35  */
36 class Port : public virtual sigc::trackable {
37    public:
38         enum Flags {
39                 IsInput = JackPortIsInput,
40                 IsOutput = JackPortIsOutput,
41                 IsPhysical = JackPortIsPhysical,
42                 IsTerminal = JackPortIsTerminal,
43                 CanMonitor = JackPortCanMonitor
44         };
45
46         virtual ~Port() {}
47
48         std::string name() const { 
49                 return _name;
50         }
51
52
53         Flags flags() const {
54                 return _flags;
55         }
56
57         bool receives_input() const {
58                 return _flags & IsInput;
59         }
60
61         bool sends_output () const {
62                 return _flags & JackPortIsOutput;
63         }
64
65         bool can_monitor () const {
66                 return _flags & CanMonitor;
67         }
68
69         void enable_metering() {
70                 _metering++;
71         }
72         
73         void disable_metering () {
74                 if (_metering) { _metering--; }
75         }
76         
77         virtual DataType type() const = 0;
78         virtual void cycle_start(nframes_t nframes) {}
79         virtual void cycle_end() {}
80         virtual Buffer& get_buffer() = 0;
81         virtual std::string short_name() = 0;
82         virtual int set_name (std::string str) = 0;
83         virtual int reestablish () = 0;
84         virtual int connected () const = 0;
85         virtual bool connected_to (const std::string& portname) const = 0;
86         virtual const char ** get_connections () const = 0;
87         virtual bool monitoring_input () const = 0;
88         virtual void ensure_monitor_input (bool yn) = 0;
89         virtual void request_monitor_input (bool yn) = 0;
90         virtual nframes_t latency () const = 0;
91         virtual nframes_t total_latency () const = 0;
92         virtual void set_latency (nframes_t nframes) = 0;
93
94         sigc::signal<void,bool> MonitorInputChanged;
95         sigc::signal<void,bool> ClockSyncChanged;
96
97   protected:
98         friend class AudioEngine;
99
100         Port ();
101
102         virtual int disconnect () = 0;
103         virtual void recompute_total_latency() const = 0;
104         virtual void reset ();
105         
106         /* engine isn't supposed to access below here */
107
108         Flags _flags;
109         std::string    _type;
110         std::string    _name;
111         unsigned short _metering;
112         bool           _last_monitor;
113 };
114  
115 } // namespace ARDOUR
116
117 #endif /* __ardour_port_h__ */