3 Copyright (C) 2006 Paul Davis
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #ifndef __lib_pbd_command_h__
23 #define __lib_pbd_command_h__
27 #include "pbd/libpbd_visibility.h"
28 #include "pbd/signals.h"
29 #include "pbd/statefuldestructible.h"
31 /** Base class for Undo/Redo commands and changesets */
32 class LIBPBD_API Command : public PBD::StatefulDestructible, public PBD::ScopedConnectionList
35 virtual ~Command() { /* NOTE: derived classes must call drop_references() */ }
37 virtual void operator() () = 0;
39 void set_name (const std::string& str) { _name = str; }
40 const std::string& name() const { return _name; }
42 virtual void undo() = 0;
43 virtual void redo() { (*this)(); }
45 virtual XMLNode &get_state();
46 virtual int set_state(const XMLNode&, int /*version*/) { /* noop */ return 0; }
48 virtual bool empty () const {
54 Command(const std::string& name) : _name(name) {}
59 #endif // __lib_pbd_command_h_