From afe5331a0b7c358f357f2d3f869a3a2c6832a792 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sun, 6 Aug 2023 13:10:35 -0600 Subject: [PATCH] pbd: fairly unconscionable that Command in libpbd is not namespaced, so now it is --- gtk2_ardour/editor.h | 2 +- gtk2_ardour/editor_ops.cc | 2 +- libs/ardour/ardour/automation_list.h | 2 +- libs/ardour/ardour/legatize.h | 6 +++--- libs/ardour/ardour/midi_model.h | 10 +++++----- libs/ardour/ardour/midi_operator.h | 8 +++++--- libs/ardour/ardour/playlist.h | 2 +- libs/ardour/ardour/quantize.h | 2 +- libs/ardour/ardour/session.h | 13 +++++++------ libs/ardour/ardour/transform.h | 6 +++--- libs/ardour/ardour/transpose.h | 2 +- libs/ardour/automation_list.cc | 2 +- libs/ardour/legatize.cc | 2 +- libs/ardour/luabindings.cc | 14 +++++++------- libs/ardour/quantize.cc | 2 +- libs/ardour/session_command.cc | 6 ++++-- libs/ardour/transform.cc | 2 +- libs/ardour/transpose.cc | 2 +- libs/pbd/command.cc | 2 +- libs/pbd/pbd/command.h | 4 ++++ libs/pbd/pbd/functor_command.h | 2 +- libs/pbd/pbd/memento_command.h | 2 +- libs/pbd/pbd/property_basics.h | 6 ++---- libs/pbd/pbd/sequence_property.h | 3 ++- libs/pbd/pbd/stateful.h | 4 ++-- libs/pbd/pbd/stateful_diff_command.h | 2 +- libs/pbd/pbd/undo.h | 8 ++++---- libs/pbd/undo.cc | 1 + 28 files changed, 64 insertions(+), 55 deletions(-) diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index e037891e2d..21c8a3a588 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -2295,7 +2295,7 @@ private: void apply_filter (ARDOUR::Filter&, std::string cmd, ProgressReporter* progress = 0); - Command* apply_midi_note_edit_op_to_region (ARDOUR::MidiOperator& op, MidiRegionView& mrv); + PBD::Command* apply_midi_note_edit_op_to_region (ARDOUR::MidiOperator& op, MidiRegionView& mrv); /* plugin setup */ int plugin_setup (std::shared_ptr, std::shared_ptr, ARDOUR::Route::PluginSetupOptions); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 442fc17623..842eb06ba0 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -5982,7 +5982,7 @@ Editor::strip_region_silence () } } -Command* +PBD::Command* Editor::apply_midi_note_edit_op_to_region (MidiOperator& op, MidiRegionView& mrv) { Evoral::Sequence::Notes selected; diff --git a/libs/ardour/ardour/automation_list.h b/libs/ardour/ardour/automation_list.h index 2733e5347e..5d025e7517 100644 --- a/libs/ardour/ardour/automation_list.h +++ b/libs/ardour/ardour/automation_list.h @@ -116,7 +116,7 @@ public: XMLNode& get_state () const; int set_state (const XMLNode &, int version); - Command* memento_command (XMLNode* before, XMLNode* after); + PBD::Command* memento_command (XMLNode* before, XMLNode* after); bool operator!= (const AutomationList &) const; diff --git a/libs/ardour/ardour/legatize.h b/libs/ardour/ardour/legatize.h index 5bef47cab1..9aca0ab5e5 100644 --- a/libs/ardour/ardour/legatize.h +++ b/libs/ardour/ardour/legatize.h @@ -41,9 +41,9 @@ public: typedef Evoral::Sequence::Notes Notes; - Command* operator()(std::shared_ptr model, - Temporal::Beats position, - std::vector& seqs); + PBD::Command* operator()(std::shared_ptr model, + Temporal::Beats position, + std::vector& seqs); std::string name () const { return (_shrink_only ? std::string ("remove overlap") : std::string ("legatize")); } diff --git a/libs/ardour/ardour/midi_model.h b/libs/ardour/ardour/midi_model.h index 50f49b8d5e..3e7680fc98 100644 --- a/libs/ardour/ardour/midi_model.h +++ b/libs/ardour/ardour/midi_model.h @@ -63,7 +63,7 @@ public: MidiModel (MidiSource&); - class LIBARDOUR_API DiffCommand : public Command { + class LIBARDOUR_API DiffCommand : public PBD::Command { public: DiffCommand (std::shared_ptr m, const std::string& name); @@ -275,22 +275,22 @@ public: * This STARTS and COMMITS an undo command. * The command will constitute one item on the undo stack. */ - void apply_diff_command_as_commit (Session& session, Command* cmd); + void apply_diff_command_as_commit (Session& session, PBD::Command* cmd); - void apply_diff_command_as_commit (Session* session, Command* cmd) { if (session) { apply_diff_command_as_commit (*session, cmd); } } + void apply_diff_command_as_commit (Session* session, PBD::Command* cmd) { if (session) { apply_diff_command_as_commit (*session, cmd); } } /** Add a command as part of a larger reversible transaction * * Ownership of cmd is taken, it must not be deleted by the caller. * The command will be incorporated into the current command. */ - void apply_diff_command_as_subcommand (Session& session, Command* cmd); + void apply_diff_command_as_subcommand (Session& session, PBD::Command* cmd); /** Apply the midi diff, but without any effect on undo * * Ownership of cmd is not changed. */ - void apply_diff_command_only (Session& session, Command* cmd); + void apply_diff_command_only (Session& session, PBD::Command* cmd); bool sync_to_source (const Source::WriterLock& source_lock); diff --git a/libs/ardour/ardour/midi_operator.h b/libs/ardour/ardour/midi_operator.h index 3e1553a3ea..9970416d10 100644 --- a/libs/ardour/ardour/midi_operator.h +++ b/libs/ardour/ardour/midi_operator.h @@ -26,7 +26,9 @@ #include "temporal/beats.h" #include "evoral/Sequence.h" +namespace PBD { class Command; +} namespace ARDOUR { @@ -37,9 +39,9 @@ class LIBARDOUR_API MidiOperator { MidiOperator () {} virtual ~MidiOperator() {} - virtual Command* operator() (std::shared_ptr, - Temporal::Beats, - std::vector::Notes>&) = 0; + virtual PBD::Command* operator() (std::shared_ptr, + Temporal::Beats, + std::vector::Notes>&) = 0; virtual std::string name() const = 0; }; diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h index 4e1e5cc536..c56f014117 100644 --- a/libs/ardour/ardour/playlist.h +++ b/libs/ardour/ardour/playlist.h @@ -102,7 +102,7 @@ public: void update (const RegionListProperty::ChangeRecord&); void clear_owned_changes (); - void rdiff (std::vector&) const; + void rdiff (std::vector&) const; void rdiff_and_add_command (Session*); diff --git a/libs/ardour/ardour/quantize.h b/libs/ardour/ardour/quantize.h index e5546e16eb..a2376abe69 100644 --- a/libs/ardour/ardour/quantize.h +++ b/libs/ardour/ardour/quantize.h @@ -33,7 +33,7 @@ public: float strength, float swing, Temporal::Beats const & threshold); ~Quantize (); - Command* operator() (std::shared_ptr, + PBD::Command* operator() (std::shared_ptr, Temporal::Beats position, std::vector::Notes>&); std::string name() const { return std::string ("quantize"); } diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index f2582658b1..d8ffb15c55 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -110,6 +110,7 @@ class Parser; namespace PBD { class Controllable; class Progress; +class Command; } namespace luabridge { @@ -1084,9 +1085,9 @@ public: * This must only be called after begin_reversible_command () * @param cmd (additional) command to add */ - void commit_reversible_command (Command* cmd = 0); + void commit_reversible_command (PBD::Command* cmd = 0); - void add_command (Command *const cmd); + void add_command (PBD::Command *const cmd); /** create an StatefulDiffCommand from the given object and add it to the stack. * @@ -1127,13 +1128,13 @@ public: */ bool abort_empty_reversible_command (); - void add_commands (std::vector const & cmds); + void add_commands (std::vector const & cmds); std::map registry; // these commands are implemented in libs/ardour/session_command.cc - Command* memento_command_factory(XMLNode* n); - Command* stateful_diff_command_factory (XMLNode *); + PBD::Command* memento_command_factory(XMLNode* n); + PBD::Command* stateful_diff_command_factory (XMLNode *); void register_with_memento_command_factory(PBD::ID, PBD::StatefulDestructible*); /* clicking */ @@ -1386,7 +1387,7 @@ public: bool bang_trigger_at(int32_t route_index, int32_t row_index); bool unbang_trigger_at(int32_t route_index, int32_t row_index); - void globally_change_time_domain (Temporal::TimeDomain from, Temporal::TimeDomain to); + PBD::Command* globally_change_time_domain (Temporal::TimeDomain from, Temporal::TimeDomain to); protected: friend class AudioEngine; diff --git a/libs/ardour/ardour/transform.h b/libs/ardour/ardour/transform.h index 20c4096ec2..95ba079529 100644 --- a/libs/ardour/ardour/transform.h +++ b/libs/ardour/ardour/transform.h @@ -131,9 +131,9 @@ public: Transform(const Program& prog); - Command* operator()(std::shared_ptr model, - Temporal::Beats position, - std::vector& seqs); + PBD::Command* operator()(std::shared_ptr model, + Temporal::Beats position, + std::vector& seqs); std::string name() const { return std::string ("transform"); } diff --git a/libs/ardour/ardour/transpose.h b/libs/ardour/ardour/transpose.h index c4a8af6c4b..416d9f7324 100644 --- a/libs/ardour/ardour/transpose.h +++ b/libs/ardour/ardour/transpose.h @@ -32,7 +32,7 @@ public: Transpose (int semitones); - Command* operator() (std::shared_ptr model, + PBD::Command* operator() (std::shared_ptr model, Temporal::Beats position, std::vector& seqs); diff --git a/libs/ardour/automation_list.cc b/libs/ardour/automation_list.cc index 9569500b69..542d6fe02d 100644 --- a/libs/ardour/automation_list.cc +++ b/libs/ardour/automation_list.cc @@ -315,7 +315,7 @@ AutomationList::thaw () } } -Command* +PBD::Command* AutomationList::memento_command (XMLNode* before, XMLNode* after) { return new MementoCommand (*this, before, after); diff --git a/libs/ardour/legatize.cc b/libs/ardour/legatize.cc index eb6509c3d8..bcb7eaf8c1 100644 --- a/libs/ardour/legatize.cc +++ b/libs/ardour/legatize.cc @@ -29,7 +29,7 @@ Legatize::Legatize(bool shrink_only) Legatize::~Legatize () {} -Command* +PBD::Command* Legatize::operator()(std::shared_ptr model, Temporal::Beats position, std::vector& seqs) diff --git a/libs/ardour/luabindings.cc b/libs/ardour/luabindings.cc index cd2302134b..905ed66c9b 100644 --- a/libs/ardour/luabindings.cc +++ b/libs/ardour/luabindings.cc @@ -507,9 +507,9 @@ LuaBindings::common (lua_State* L) .deriveWSPtrClass ("StatefulDestructiblePtr") .endClass () - .deriveClass ("Command") - .addFunction ("set_name", &Command::set_name) - .addFunction ("name", &Command::name) + .deriveClass ("Command") + .addFunction ("set_name", &PBD::Command::set_name) + .addFunction ("name", &PBD::Command::name) .endClass () /* UndoTransaction::add_command() subscribes to DropReferences() @@ -521,7 +521,7 @@ LuaBindings::common (lua_State* L) * use Session::add_stateful_diff_command() * and Session::abort_reversible_command() */ - .deriveClass ("StatefulDiffCommand") + .deriveClass ("StatefulDiffCommand") .addFunction ("undo", &PBD::StatefulDiffCommand::undo) .addFunction ("empty", &PBD::StatefulDiffCommand::empty) .endClass () @@ -1765,13 +1765,13 @@ LuaBindings::common (lua_State* L) .endClass () .deriveWSPtrClass > ("MidiModel") - .addFunction ("apply_command", (void (MidiModel::*)(Session*, Command*))&MidiModel::apply_diff_command_as_commit) /* deprecated: left here in case any extant scripts use apply_command */ - .addFunction ("apply_diff_command_as_commit", (void (MidiModel::*)(Session*, Command*))&MidiModel::apply_diff_command_as_commit) + .addFunction ("apply_command", (void (MidiModel::*)(Session*, PBD::Command*))&MidiModel::apply_diff_command_as_commit) /* deprecated: left here in case any extant scripts use apply_command */ + .addFunction ("apply_diff_command_as_commit", (void (MidiModel::*)(Session*, PBD::Command*))&MidiModel::apply_diff_command_as_commit) .addFunction ("new_note_diff_command", &MidiModel::new_note_diff_command) .endClass () .beginNamespace ("MidiModel") - .deriveClass ("DiffCommand") + .deriveClass ("DiffCommand") .endClass () .deriveClass ("NoteDiffCommand") diff --git a/libs/ardour/quantize.cc b/libs/ardour/quantize.cc index 2aa6bbbd7d..500313d182 100644 --- a/libs/ardour/quantize.cc +++ b/libs/ardour/quantize.cc @@ -118,7 +118,7 @@ swing_position (Temporal::Beats pos, Temporal::Beats grid, double swing_strength return pos; } -Command* +PBD::Command* Quantize::operator () (std::shared_ptr model, Temporal::Beats position, std::vector::Notes>& seqs) diff --git a/libs/ardour/session_command.cc b/libs/ardour/session_command.cc index 2c2fe0e6a2..ebe09da638 100644 --- a/libs/ardour/session_command.cc +++ b/libs/ardour/session_command.cc @@ -41,7 +41,9 @@ #include "pbd/statefuldestructible.h" #include "pbd/types_convert.h" +namespace PBD { class Command; +} using namespace PBD; using namespace ARDOUR; @@ -54,7 +56,7 @@ void Session::register_with_memento_command_factory(PBD::ID id, PBD::StatefulDes registry[id] = ptr; } -Command * +PBD::Command * Session::memento_command_factory(XMLNode *n) { PBD::ID id; @@ -151,7 +153,7 @@ Session::memento_command_factory(XMLNode *n) return 0 ; } -Command * +PBD::Command * Session::stateful_diff_command_factory (XMLNode* n) { PBD::ID id; diff --git a/libs/ardour/transform.cc b/libs/ardour/transform.cc index beebb63737..fe29ae3c22 100644 --- a/libs/ardour/transform.cc +++ b/libs/ardour/transform.cc @@ -119,7 +119,7 @@ Transform::Operation::eval(Context& ctx) const ctx.stack.push(Variant(lhs.type(), value)); } -Command* +PBD::Command* Transform::operator()(std::shared_ptr model, Temporal::Beats position, std::vector& seqs) diff --git a/libs/ardour/transpose.cc b/libs/ardour/transpose.cc index 4f3c5849ee..3c58587d0c 100644 --- a/libs/ardour/transpose.cc +++ b/libs/ardour/transpose.cc @@ -24,7 +24,7 @@ Transpose::Transpose(int semitones) : _semitones(semitones) {} -Command* +PBD::Command* Transpose::operator()(std::shared_ptr model, Temporal::Beats position, std::vector& seqs) diff --git a/libs/pbd/command.cc b/libs/pbd/command.cc index bacb9eaa1a..f120aeee4b 100644 --- a/libs/pbd/command.cc +++ b/libs/pbd/command.cc @@ -21,7 +21,7 @@ #include "pbd/command.h" #include "pbd/xml++.h" -XMLNode &Command::get_state() const +XMLNode &PBD::Command::get_state() const { XMLNode *node = new XMLNode ("Command"); node->add_content("WARNING: Somebody forgot to subclass Command."); diff --git a/libs/pbd/pbd/command.h b/libs/pbd/pbd/command.h index f72d875676..3220081306 100644 --- a/libs/pbd/pbd/command.h +++ b/libs/pbd/pbd/command.h @@ -29,6 +29,8 @@ #include "pbd/signals.h" #include "pbd/statefuldestructible.h" +namespace PBD { + /** Base class for Undo/Redo commands and changesets */ class LIBPBD_API Command : public PBD::StatefulDestructible, public PBD::ScopedConnectionList { @@ -57,4 +59,6 @@ protected: std::string _name; }; +} /* namespace */ + #endif // __lib_pbd_command_h_ diff --git a/libs/pbd/pbd/functor_command.h b/libs/pbd/pbd/functor_command.h index 4a1dfc9d49..533e8d207f 100644 --- a/libs/pbd/pbd/functor_command.h +++ b/libs/pbd/pbd/functor_command.h @@ -36,7 +36,7 @@ namespace PBD { template -class /*LIBPBD_API*/ FunctorCommand : public Command +class /*LIBPBD_API*/ FunctorCommand : public PBD::Command { private: typedef void (obj_type::*functor_type)(arg_type); diff --git a/libs/pbd/pbd/memento_command.h b/libs/pbd/pbd/memento_command.h index 2e20d51a42..ec570d99b7 100644 --- a/libs/pbd/pbd/memento_command.h +++ b/libs/pbd/pbd/memento_command.h @@ -101,7 +101,7 @@ private: * memento, and redo is restoring the after memento. */ template -class LIBPBD_TEMPLATE_API MementoCommand : public Command +class LIBPBD_TEMPLATE_API MementoCommand : public PBD::Command { public: MementoCommand (obj_T& a_object, XMLNode* a_before, XMLNode* a_after) diff --git a/libs/pbd/pbd/property_basics.h b/libs/pbd/pbd/property_basics.h index 68b9bf2619..e74f126b7d 100644 --- a/libs/pbd/pbd/property_basics.h +++ b/libs/pbd/pbd/property_basics.h @@ -29,10 +29,8 @@ #include "pbd/libpbd_visibility.h" #include "pbd/xml++.h" -class Command; - namespace PBD { - +class LIBPBD_API Command; class LIBPBD_API PropertyList; class LIBPBD_API StatefulDiffCommand; @@ -140,7 +138,7 @@ public: virtual void get_changes_as_properties (PropertyList& changes, Command *) const = 0; /** Collect StatefulDiffCommands for changes to anything that we own */ - virtual void rdiff (std::vector &) const {} + virtual void rdiff (std::vector &) const {} /** Look in an XML node written by get_changes_as_xml and, if XML from this property * is found, create a property with the changes from the XML. diff --git a/libs/pbd/pbd/sequence_property.h b/libs/pbd/pbd/sequence_property.h index e1bcccdb5d..bdc4d70cc2 100644 --- a/libs/pbd/pbd/sequence_property.h +++ b/libs/pbd/pbd/sequence_property.h @@ -37,6 +37,7 @@ #include "pbd/error.h" namespace PBD { +class Command; /** A base class for properties whose state is a container of other * things. Its behaviour is `specialised' for this purpose in that @@ -224,7 +225,7 @@ class /*LIBPBD_API*/ SequenceProperty : public PropertyBase } } - void rdiff (std::vector& cmds) const { + void rdiff (std::vector& cmds) const { for (typename Container::const_iterator i = begin(); i != end(); ++i) { if ((*i)->changed ()) { StatefulDiffCommand* sdc = new StatefulDiffCommand (*i); diff --git a/libs/pbd/pbd/stateful.h b/libs/pbd/pbd/stateful.h index bf66855e11..8fd259abc8 100644 --- a/libs/pbd/pbd/stateful.h +++ b/libs/pbd/pbd/stateful.h @@ -89,8 +89,8 @@ class LIBPBD_API Stateful { void clear_changes (); virtual void clear_owned_changes (); - PropertyList* get_changes_as_properties (Command *) const; - virtual void rdiff (std::vector &) const; + PropertyList* get_changes_as_properties (PBD::Command *) const; + virtual void rdiff (std::vector &) const; bool changed() const; /* create a property list from an XMLNode */ diff --git a/libs/pbd/pbd/stateful_diff_command.h b/libs/pbd/pbd/stateful_diff_command.h index 62b33f676e..6973d52b65 100644 --- a/libs/pbd/pbd/stateful_diff_command.h +++ b/libs/pbd/pbd/stateful_diff_command.h @@ -33,7 +33,7 @@ class PropertyList; /** A Command which stores its action as the differences between the before and after * state of a Stateful object. */ -class LIBPBD_API StatefulDiffCommand : public Command +class LIBPBD_API StatefulDiffCommand : public PBD::Command { public: StatefulDiffCommand (std::shared_ptr); diff --git a/libs/pbd/pbd/undo.h b/libs/pbd/pbd/undo.h index 3cf546b606..b689c9a56c 100644 --- a/libs/pbd/pbd/undo.h +++ b/libs/pbd/pbd/undo.h @@ -41,7 +41,7 @@ typedef sigc::slot UndoAction; -class LIBPBD_API UndoTransaction : public Command +class LIBPBD_API UndoTransaction : public PBD::Command { public: UndoTransaction (); @@ -55,8 +55,8 @@ public: return _clearing; } - void add_command (Command* const); - void remove_command (Command* const); + void add_command (PBD::Command* const); + void remove_command (PBD::Command* const); void operator() (); void undo (); @@ -75,7 +75,7 @@ public: } private: - std::list actions; + std::list actions; struct timeval _timestamp; bool _clearing; diff --git a/libs/pbd/undo.cc b/libs/pbd/undo.cc index 1428922ebe..ebd0aa3a3c 100644 --- a/libs/pbd/undo.cc +++ b/libs/pbd/undo.cc @@ -30,6 +30,7 @@ using namespace std; using namespace sigc; +using namespace PBD; UndoTransaction::UndoTransaction () : _clearing (false)