From 3f24977735b06f9b39a82d66c216ba27e3a302d5 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 17 Feb 2009 03:49:32 +0000 Subject: Make a bunch of stuff boost::noncopyable. Clean up. git-svn-id: svn://localhost/ardour2/branches/3.0@4613 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/audio_unit.h | 2 +- libs/ardour/ardour/audioanalyser.h | 3 +- libs/ardour/ardour/buffer_set.h | 22 ++++----- libs/ardour/ardour/chan_count.h | 28 ++++------- libs/ardour/ardour/diskstream.h | 94 +++++++++++++++++++------------------ libs/ardour/ardour/playlist.h | 10 ++-- libs/ardour/ardour/plugin.h | 5 +- libs/ardour/ardour/plugin_manager.h | 3 +- libs/ardour/ardour/port.h | 9 ++-- libs/ardour/ardour/port_set.h | 27 ++++------- libs/ardour/ardour/processor.h | 16 +++---- libs/ardour/ardour/region.h | 2 + libs/ardour/ardour/session.h | 3 +- libs/ardour/ardour/source.h | 3 +- libs/ardour/playlist.cc | 14 ------ libs/ardour/route.cc | 4 -- 16 files changed, 106 insertions(+), 139 deletions(-) (limited to 'libs/ardour') diff --git a/libs/ardour/ardour/audio_unit.h b/libs/ardour/ardour/audio_unit.h index 497954092f..6333ece5d0 100644 --- a/libs/ardour/ardour/audio_unit.h +++ b/libs/ardour/ardour/audio_unit.h @@ -63,7 +63,7 @@ class AUPlugin : public ARDOUR::Plugin AUPlugin (const AUPlugin& other); virtual ~AUPlugin (); - std::string unique_id () const; + std::string unique_id () const; const char * label () const; const char * name () const { return _info->name.c_str(); } const char * maker () const { return _info->creator.c_str(); } diff --git a/libs/ardour/ardour/audioanalyser.h b/libs/ardour/ardour/audioanalyser.h index 06b841990a..7bb12b2b63 100644 --- a/libs/ardour/ardour/audioanalyser.h +++ b/libs/ardour/ardour/audioanalyser.h @@ -25,6 +25,7 @@ #include #include #include +#include #include namespace ARDOUR { @@ -32,7 +33,7 @@ namespace ARDOUR { class Readable; class Session; -class AudioAnalyser { +class AudioAnalyser : public boost::noncopyable { public: typedef Vamp::Plugin AnalysisPlugin; diff --git a/libs/ardour/ardour/buffer_set.h b/libs/ardour/ardour/buffer_set.h index 3f7a6e7665..dbdf41b87a 100644 --- a/libs/ardour/ardour/buffer_set.h +++ b/libs/ardour/ardour/buffer_set.h @@ -32,7 +32,6 @@ class AudioBuffer; class MidiBuffer; class PortSet; - /** A set of buffers of various types. * * These are mainly accessed from Session and passed around as scratch buffers @@ -69,32 +68,26 @@ public: size_t buffer_capacity(DataType type) const; - Buffer& get(DataType type, size_t i) - { + Buffer& get(DataType type, size_t i) { assert(i <= _count.get(type)); return *_buffers[type][i]; } - AudioBuffer& get_audio(size_t i) - { + AudioBuffer& get_audio(size_t i) { return (AudioBuffer&)get(DataType::AUDIO, i); } - MidiBuffer& get_midi(size_t i) - { + MidiBuffer& get_midi(size_t i) { return (MidiBuffer&)get(DataType::MIDI, i); } void read_from(BufferSet& in, jack_nframes_t nframes, jack_nframes_t offset=0); // ITERATORS - - // FIXME: this is a filthy copy-and-paste mess - // FIXME: litter these with assertions + // FIXME: possible to combine these? templates? class audio_iterator { public: - AudioBuffer& operator*() { return _set.get_audio(_index); } AudioBuffer* operator->() { return &_set.get_audio(_index); } audio_iterator& operator++() { ++_index; return *this; } // yes, prefix only @@ -113,15 +106,17 @@ public: audio_iterator audio_begin() { return audio_iterator(*this, 0); } audio_iterator audio_end() { return audio_iterator(*this, _count.n_audio()); } + class iterator { public: - Buffer& operator*() { return _set.get(_type, _index); } Buffer* operator->() { return &_set.get(_type, _index); } iterator& operator++() { ++_index; return *this; } // yes, prefix only bool operator==(const iterator& other) { return (_index == other._index); } bool operator!=(const iterator& other) { return (_index != other._index); } - iterator operator=(const iterator& other) { _set = other._set; _type = other._type; _index = other._index; return *this; } + iterator operator=(const iterator& other) { + _set = other._set; _type = other._type; _index = other._index; return *this; + } private: friend class BufferSet; @@ -136,7 +131,6 @@ public: iterator begin(DataType type) { return iterator(*this, type, 0); } iterator end(DataType type) { return iterator(*this, type, _count.get(type)); } - private: typedef std::vector BufferVec; diff --git a/libs/ardour/ardour/chan_count.h b/libs/ardour/ardour/chan_count.h index 986ef76e25..e4981d11ef 100644 --- a/libs/ardour/ardour/chan_count.h +++ b/libs/ardour/ardour/chan_count.h @@ -36,14 +36,12 @@ public: ChanCount() { reset(); } // Convenience constructor for making single-typed streams (stereo, mono, etc) - ChanCount(DataType type, uint32_t channels) - { + ChanCount(DataType type, uint32_t channels) { reset(); set(type, channels); } - void reset() - { + void reset() { for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) { _counts[*t] = 0; } @@ -58,8 +56,7 @@ public: inline uint32_t n_midi() const { return _counts[DataType::MIDI]; } inline void set_midi(uint32_t m) { _counts[DataType::MIDI] = m; } - uint32_t n_total() const - { + uint32_t n_total() const { uint32_t ret = 0; for (uint32_t i=0; i < DataType::num_types; ++i) ret += _counts[i]; @@ -67,8 +64,7 @@ public: return ret; } - bool operator==(const ChanCount& other) const - { + bool operator==(const ChanCount& other) const { for (uint32_t i=0; i < DataType::num_types; ++i) if (_counts[i] != other._counts[i]) return false; @@ -76,13 +72,11 @@ public: return true; } - bool operator!=(const ChanCount& other) const - { + bool operator!=(const ChanCount& other) const { return ! (*this == other); } - bool operator<(const ChanCount& other) const - { + bool operator<(const ChanCount& other) const { for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) { if (_counts[*t] > other._counts[*t]) { return false; @@ -91,13 +85,11 @@ public: return (*this != other); } - bool operator<=(const ChanCount& other) const - { + bool operator<=(const ChanCount& other) const { return ( (*this < other) || (*this == other) ); } - bool operator>(const ChanCount& other) const - { + bool operator>(const ChanCount& other) const { for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) { if (_counts[*t] < other._counts[*t]) { return false; @@ -106,8 +98,7 @@ public: return (*this != other); } - bool operator>=(const ChanCount& other) const - { + bool operator>=(const ChanCount& other) const { return ( (*this > other) || (*this == other) ); } @@ -115,7 +106,6 @@ public: static const ChanCount ZERO; private: - uint32_t _counts[DataType::num_types]; }; diff --git a/libs/ardour/ardour/diskstream.h b/libs/ardour/ardour/diskstream.h index 03d2e23cbd..e74687dcaf 100644 --- a/libs/ardour/ardour/diskstream.h +++ b/libs/ardour/ardour/diskstream.h @@ -29,6 +29,8 @@ #include +#include + #include #include @@ -56,12 +58,12 @@ class Region; class Send; class Session; -class Diskstream : public SessionObject +class Diskstream : public SessionObject, public boost::noncopyable { public: enum Flag { - Recordable = 0x1, - Hidden = 0x2, + Recordable = 0x1, + Hidden = 0x2, Destructive = 0x4 }; @@ -246,62 +248,62 @@ class Diskstream : public SessionObject uint32_t i_am_the_modifier; - ARDOUR::IO* _io; - ChanCount _n_channels; + ARDOUR::IO* _io; + ChanCount _n_channels; boost::shared_ptr _playlist; - mutable gint _record_enabled; - double _visible_speed; - double _actual_speed; + mutable gint _record_enabled; + double _visible_speed; + double _actual_speed; /* items needed for speed change logic */ - bool _buffer_reallocation_required; - bool _seek_required; + bool _buffer_reallocation_required; + bool _seek_required; - bool force_refill; - nframes_t capture_start_frame; - nframes_t capture_captured; - bool was_recording; - nframes_t adjust_capture_position; - nframes_t _capture_offset; - nframes_t _roll_delay; - nframes_t first_recordable_frame; - nframes_t last_recordable_frame; - int last_possibly_recording; - AlignStyle _alignment_style; - bool _scrubbing; - bool _slaved; - bool _processed; - Location* loop_location; - nframes_t overwrite_frame; - off_t overwrite_offset; - bool pending_overwrite; - bool overwrite_queued; - IOChange input_change_pending; - nframes_t wrap_buffer_size; - nframes_t speed_buffer_size; - - uint64_t last_phase; + bool force_refill; + nframes_t capture_start_frame; + nframes_t capture_captured; + bool was_recording; + nframes_t adjust_capture_position; + nframes_t _capture_offset; + nframes_t _roll_delay; + nframes_t first_recordable_frame; + nframes_t last_recordable_frame; + int last_possibly_recording; + AlignStyle _alignment_style; + bool _scrubbing; + bool _slaved; + bool _processed; + Location* loop_location; + nframes_t overwrite_frame; + off_t overwrite_offset; + bool pending_overwrite; + bool overwrite_queued; + IOChange input_change_pending; + nframes_t wrap_buffer_size; + nframes_t speed_buffer_size; + + uint64_t last_phase; /// diskstream speed in 40.24 fixed point math - uint64_t phi; + uint64_t phi; /// target diskstream speed in 40.24 fixed point math - uint64_t target_phi; + uint64_t target_phi; - nframes_t file_frame; - nframes_t playback_sample; - nframes_t playback_distance; - bool commit_should_unlock; + nframes_t file_frame; + nframes_t playback_sample; + nframes_t playback_distance; + bool commit_should_unlock; - uint32_t _read_data_count; - uint32_t _write_data_count; + uint32_t _read_data_count; + uint32_t _write_data_count; - bool in_set_state; - AlignStyle _persistent_alignment_style; - bool first_input_change; + bool in_set_state; + AlignStyle _persistent_alignment_style; + bool first_input_change; - Glib::Mutex state_lock; + Glib::Mutex state_lock; nframes_t scrub_start; nframes_t scrub_buffer_size; diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h index d2920fb610..151d240b4c 100644 --- a/libs/ardour/ardour/playlist.h +++ b/libs/ardour/ardour/playlist.h @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -50,7 +51,9 @@ namespace ARDOUR { class Session; class Region; -class Playlist : public SessionObject, public boost::enable_shared_from_this { +class Playlist : public SessionObject, + public boost::noncopyable, + public boost::enable_shared_from_this { public: typedef list > RegionList; @@ -217,11 +220,6 @@ class Playlist : public SessionObject, public boost::enable_shared_from_this +#include #include #include @@ -28,11 +29,11 @@ #include #include -#include #include #include #include #include +#include #include #include @@ -87,7 +88,7 @@ class PluginInfo { typedef boost::shared_ptr PluginInfoPtr; typedef std::list PluginInfoList; -class Plugin : public PBD::StatefulDestructible, public Latent +class Plugin : public PBD::StatefulDestructible, public Latent, public boost::noncopyable { public: Plugin (ARDOUR::AudioEngine&, ARDOUR::Session&); diff --git a/libs/ardour/ardour/plugin_manager.h b/libs/ardour/ardour/plugin_manager.h index 858decd0e5..abf4c884cc 100644 --- a/libs/ardour/ardour/plugin_manager.h +++ b/libs/ardour/ardour/plugin_manager.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -36,7 +37,7 @@ namespace ARDOUR { class Plugin; -class PluginManager { +class PluginManager : public boost::noncopyable { public: PluginManager (); ~PluginManager (); diff --git a/libs/ardour/ardour/port.h b/libs/ardour/ardour/port.h index c63faa162d..cf54c5065b 100644 --- a/libs/ardour/ardour/port.h +++ b/libs/ardour/ardour/port.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "ardour/data_type.h" #include "ardour/types.h" @@ -33,7 +34,7 @@ namespace ARDOUR { class AudioEngine; class Buffer; -class Port : public sigc::trackable +class Port : public sigc::trackable, public boost::noncopyable { public: enum Flags { @@ -115,8 +116,8 @@ private: /* XXX */ bool _last_monitor; - std::string _name; ///< port short name - Flags _flags; ///< flags + std::string _name; ///< port short name + Flags _flags; ///< flags /** ports that we are connected to, kept so that we can reconnect to JACK when required */ @@ -125,4 +126,4 @@ private: } -#endif +#endif /* __ardour_port_h__ */ diff --git a/libs/ardour/ardour/port_set.h b/libs/ardour/ardour/port_set.h index 7b9e716e4a..92591389d9 100644 --- a/libs/ardour/ardour/port_set.h +++ b/libs/ardour/ardour/port_set.h @@ -21,6 +21,7 @@ #include #include +#include namespace ARDOUR { @@ -34,7 +35,7 @@ class MidiPort; * the nth port of a given type. Note that port(n) and nth_audio_port(n) may * NOT return the same port. */ -class PortSet { +class PortSet : public boost::noncopyable { public: PortSet(); @@ -66,12 +67,10 @@ public: bool empty() const { return (_count.n_total() == 0); } // ITERATORS - - // FIXME: this is a filthy copy-and-paste mess + // FIXME: possible to combine these? templates? class iterator { public: - Port& operator*() { return *_set.port(_type, _index); } Port* operator->() { return _set.port(_type, _index); } iterator& operator++() { ++_index; return *this; } // yes, prefix only @@ -89,19 +88,18 @@ public: size_t _index; }; - iterator begin(DataType type = DataType::NIL) - { return iterator(*this, type, 0); } + iterator begin(DataType type = DataType::NIL) { + return iterator(*this, type, 0); + } - iterator end(DataType type = DataType::NIL) - { + iterator end(DataType type = DataType::NIL) { return iterator(*this, type, (type == DataType::NIL) ? _count.n_total() : _count.get(type)); } - // FIXME: typeify + class const_iterator { public: - const Port& operator*() { return *_set.port(_index); } const Port* operator->() { return _set.port(_index); } const_iterator& operator++() { ++_index; return *this; } // yes, prefix only @@ -114,7 +112,7 @@ public: const_iterator(const PortSet& list, size_t index) : _set(list), _index(index) {} const PortSet& _set; - size_t _index; + size_t _index; }; const_iterator begin() const { return const_iterator(*this, 0); } @@ -123,7 +121,6 @@ public: class audio_iterator { public: - AudioPort& operator*() { return *_set.nth_audio_port(_index); } AudioPort* operator->() { return _set.nth_audio_port(_index); } audio_iterator& operator++() { ++_index; return *this; } // yes, prefix only @@ -136,17 +133,13 @@ public: audio_iterator(PortSet& list, size_t index) : _set(list), _index(index) {} PortSet& _set; - size_t _index; + size_t _index; }; audio_iterator audio_begin() { return audio_iterator(*this, 0); } audio_iterator audio_end() { return audio_iterator(*this, _count.n_audio()); } private: - // Prevent copies (undefined) - PortSet(const PortSet& copy); - void operator=(const PortSet& other); - typedef std::vector PortVec; // Vector of vectors, indexed by DataType::to_index() diff --git a/libs/ardour/ardour/processor.h b/libs/ardour/ardour/processor.h index 430e281bfc..5cfa51eb2a 100644 --- a/libs/ardour/ardour/processor.h +++ b/libs/ardour/ardour/processor.h @@ -49,7 +49,7 @@ class Processor : public SessionObject, public AutomatableControls, public Laten public: static const string state_node_name; - Processor(Session&, const string& name, Placement p); // TODO: remove placement in favour of sort key + Processor(Session&, const string& name, Placement p); // TODO: remove placement (use sort key) virtual ~Processor() { } @@ -70,13 +70,17 @@ class Processor : public SessionObject, public AutomatableControls, public Laten virtual void set_block_size (nframes_t nframes) {} - virtual void run_in_place (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset) { assert(is_in_place()); } + virtual void run_in_place (BufferSet& bufs, + nframes_t start_frame, nframes_t end_frame, + nframes_t nframes, nframes_t offset) { assert(is_in_place()); } - virtual void run_out_of_place (BufferSet& input, BufferSet& output, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset) { assert(is_out_of_place()); } + virtual void run_out_of_place (BufferSet& input, BufferSet& output, + nframes_t start_frame, nframes_t end_frame, + nframes_t nframes, nframes_t offset) { assert(is_out_of_place()); } virtual void silence (nframes_t nframes, nframes_t offset) {} - void activate () { _active = true; ActiveChanged(); } + void activate () { _active = true; ActiveChanged(); } void deactivate () { _active = false; ActiveChanged(); } virtual bool configure_io (ChanCount in, ChanCount out); @@ -115,10 +119,6 @@ protected: Placement _placement; uint32_t _sort_key; void* _gui; /* generic, we don't know or care what this is */ - -private: - /* disallow copy construction */ - Processor (Processor const &); }; } // namespace ARDOUR diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h index b55d77f499..a4ce35b61b 100644 --- a/libs/ardour/ardour/region.h +++ b/libs/ardour/ardour/region.h @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -48,6 +49,7 @@ enum RegionEditState { class Region : public SessionObject + , public boost::noncopyable , public boost::enable_shared_from_this , public Readable { diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 2e56e99722..82e88b994c 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -116,7 +117,7 @@ using std::string; using std::map; using std::set; -class Session : public PBD::StatefulDestructible +class Session : public PBD::StatefulDestructible, public boost::noncopyable { private: typedef std::pair,bool> RouteBooleanState; diff --git a/libs/ardour/ardour/source.h b/libs/ardour/ardour/source.h index 7b5fc43659..943b7b444c 100644 --- a/libs/ardour/ardour/source.h +++ b/libs/ardour/ardour/source.h @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -37,7 +38,7 @@ namespace ARDOUR { class Session; class Playlist; -class Source : public SessionObject, public ARDOUR::Readable +class Source : public SessionObject, public ARDOUR::Readable, public boost::noncopyable { public: enum Flag { diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index 8f4c94078d..575da0a89f 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -250,20 +250,6 @@ Playlist::init (bool hide) Modified.connect (mem_fun (*this, &Playlist::mark_session_dirty)); } -Playlist::Playlist (const Playlist& pl) - : SessionObject(pl._session, pl._name) - , _type(pl.data_type()) -{ - fatal << _("playlist const copy constructor called") << endmsg; -} - -Playlist::Playlist (Playlist& pl) - : SessionObject(pl._session, pl._name) - , _type(pl.data_type()) -{ - fatal << _("playlist non-const copy constructor called") << endmsg; -} - Playlist::~Playlist () { { diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index e1093f2f8f..ea2a472495 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -1292,7 +1292,6 @@ Route::add_processors (const ProcessorList& others, ProcessorStreams* err) /** Turn off all processors with a given placement * @param p Placement of processors to disable */ - void Route::disable_processors (Placement p) { @@ -1309,7 +1308,6 @@ Route::disable_processors (Placement p) /** Turn off all redirects */ - void Route::disable_processors () { @@ -1325,7 +1323,6 @@ Route::disable_processors () /** Turn off all redirects with a given placement * @param p Placement of redirects to disable */ - void Route::disable_plugins (Placement p) { @@ -1342,7 +1339,6 @@ Route::disable_plugins (Placement p) /** Turn off all plugins */ - void Route::disable_plugins () { -- cgit v1.2.3