diff options
author | David Robillard <d@drobilla.net> | 2007-07-16 18:32:31 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-07-16 18:32:31 +0000 |
commit | 94f329cd1e761ad164a2fb1e2a1bd12103099c2e (patch) | |
tree | 261853e8fa2f3b30652599be767ec9d99bd05c41 | |
parent | 155bc17e2bf2bad2ca5aff4f9df83401821a5573 (diff) |
Fix formatting of command stuff to adhere to The Guidelines(TM).
git-svn-id: svn://localhost/ardour2/trunk@2130 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | libs/pbd/command.cc | 6 | ||||
-rw-r--r-- | libs/pbd/pbd/command.h | 16 | ||||
-rw-r--r-- | libs/pbd/pbd/memento_command.h | 106 | ||||
-rw-r--r-- | libs/pbd/pbd/undo.h | 8 |
4 files changed, 70 insertions, 66 deletions
diff --git a/libs/pbd/command.cc b/libs/pbd/command.cc index f84d99491f..011534a662 100644 --- a/libs/pbd/command.cc +++ b/libs/pbd/command.cc @@ -23,7 +23,7 @@ XMLNode &Command::get_state() { - XMLNode *node = new XMLNode ("Command"); - node->add_content("WARNING: Somebody forgot to subclass Command."); - return *node; + XMLNode *node = new XMLNode ("Command"); + node->add_content("WARNING: Somebody forgot to subclass Command."); + return *node; } diff --git a/libs/pbd/pbd/command.h b/libs/pbd/pbd/command.h index 23bcf85b91..5d45f85ac3 100644 --- a/libs/pbd/pbd/command.h +++ b/libs/pbd/pbd/command.h @@ -1,5 +1,6 @@ /* - Copyright (C) 2006 Hans Fugal & Paul Davis + Copyright (C) 2006 Paul Davis + Author: Hans Fugal This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,13 +25,16 @@ class Command : public PBD::StatefulDestructible { - public: +public: virtual ~Command() {} + virtual void operator() () = 0; - virtual void undo() = 0; - virtual void redo() { (*this)(); } - virtual XMLNode &get_state(); - virtual int set_state(const XMLNode&) { /* noop */ return 0; } + + virtual void undo() = 0; + virtual void redo() { (*this)(); } + + virtual XMLNode &get_state(); + virtual int set_state(const XMLNode&) { /* noop */ return 0; } }; #endif // __lib_pbd_command_h_ diff --git a/libs/pbd/pbd/memento_command.h b/libs/pbd/pbd/memento_command.h index d913b2c0fe..fdc7527dc6 100644 --- a/libs/pbd/pbd/memento_command.h +++ b/libs/pbd/pbd/memento_command.h @@ -1,5 +1,6 @@ /* - Copyright (C) 2006 Hans Fugal & Paul Davis + Copyright (C) 2006 Paul Davis + Author: Hans Fugal This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,8 +22,6 @@ #define __lib_pbd_memento_command_h__ #include <iostream> -using std::cerr; -using std::endl; #include <pbd/command.h> #include <pbd/stacktrace.h> @@ -36,66 +35,67 @@ using std::endl; * (from Stateful::get_state()), so undo becomes restoring the before * memento, and redo is restoring the after memento. */ - template <class obj_T> class MementoCommand : public Command { - public: - MementoCommand(obj_T &object, - XMLNode *before, - XMLNode *after - ) - : obj(object), before(before), after(after) { +public: + MementoCommand(obj_T &object, XMLNode *before, XMLNode *after) + : obj(object), before(before), after(after) + { /* catch destruction of the object */ new PBD::Shiva<obj_T,MementoCommand<obj_T> > (object, *this); } - ~MementoCommand () { - GoingAway(); - if (before) { + ~MementoCommand () + { + GoingAway(); /* EMIT SIGNAL */ + + if (before) delete before; - } - if (after) { + + if (after) delete after; - } } - void operator() () - { - if (after) - obj.set_state(*after); - } - void undo() - { - if (before) - obj.set_state(*before); - } - virtual XMLNode &get_state() - { - string name; - if (before && after) - name = "MementoCommand"; - else if (before) - name = "MementoUndoCommand"; - else - name = "MementoRedoCommand"; - - - XMLNode *node = new XMLNode(name); - - node->add_property("obj_id", obj.id().to_s()); - node->add_property("type_name", typeid(obj).name()); - - if (before) - node->add_child_copy(*before); - if (after) - node->add_child_copy(*after); - - return *node; - } - - protected: - obj_T &obj; - XMLNode *before, *after; + + void operator() () + { + if (after) + obj.set_state(*after); + } + + void undo() + { + if (before) + obj.set_state(*before); + } + + virtual XMLNode &get_state() + { + string name; + if (before && after) + name = "MementoCommand"; + else if (before) + name = "MementoUndoCommand"; + else + name = "MementoRedoCommand"; + + XMLNode *node = new XMLNode(name); + + node->add_property("obj_id", obj.id().to_s()); + node->add_property("type_name", typeid(obj).name()); + + if (before) + node->add_child_copy(*before); + + if (after) + node->add_child_copy(*after); + + return *node; + } + +protected: + obj_T &obj; + XMLNode *before, *after; }; #endif // __lib_pbd_memento_h__ diff --git a/libs/pbd/pbd/undo.h b/libs/pbd/pbd/undo.h index 9539d8b41d..ea9a6d0e8b 100644 --- a/libs/pbd/pbd/undo.h +++ b/libs/pbd/pbd/undo.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002 Brett Viren & Paul Davis + Copyright (C) 2002 Brett Viren & Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -45,7 +45,7 @@ class UndoTransaction : public Command void add_command (Command* const); void remove_command (Command* const); - void operator() (); + void operator() (); void undo(); void redo(); @@ -93,8 +93,8 @@ class UndoHistory : public sigc::trackable void clear_undo (); void clear_redo (); - XMLNode &get_state(uint32_t depth = 0); - void save_state(); + XMLNode &get_state(uint32_t depth = 0); + void save_state(); sigc::signal<void> Changed; |