Fix formatting of command stuff to adhere to The Guidelines(TM).
authorDavid Robillard <d@drobilla.net>
Mon, 16 Jul 2007 18:32:31 +0000 (18:32 +0000)
committerDavid Robillard <d@drobilla.net>
Mon, 16 Jul 2007 18:32:31 +0000 (18:32 +0000)
git-svn-id: svn://localhost/ardour2/trunk@2130 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/pbd/command.cc
libs/pbd/pbd/command.h
libs/pbd/pbd/memento_command.h
libs/pbd/pbd/undo.h

index f84d99491f75fb76d31e3095a2186668fb5650c8..011534a6626bfb8815b634173e01bd49e84bacc7 100644 (file)
@@ -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;
 }
index 23bcf85b91cee4c6e46acd481b5b7f2115afc817..5d45f85ac31f545050bfc32884871d7452ab02eb 100644 (file)
@@ -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
 
 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_
index d913b2c0fe198eeeff73ca242daf4a627855f038..fdc7527dc6495c04397ea67e9797fa3fc63e265c 100644 (file)
@@ -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__
index 9539d8b41dc734fd8ac88bcc33c1186d177de734..ea9a6d0e8bf7a81044a4b3df2a7ab40baa1675b2 100644 (file)
@@ -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;