Ardour  8.12
command.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2015 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2006 Hans Fugal <hans@fugal.net>
4  * Copyright (C) 2007-2009 David Robillard <d@drobilla.net>
5  * Copyright (C) 2009-2010 Carl Hetherington <carl@carlh.net>
6  * Copyright (C) 2015-2016 Robin Gareus <robin@gareus.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 #ifndef __lib_pbd_command_h__
24 #define __lib_pbd_command_h__
25 
26 #include <string>
27 
28 #include "pbd/libpbd_visibility.h"
29 #include "pbd/signals.h"
31 
32 namespace PBD {
33 
36 {
37 public:
38  virtual ~Command() { /* NOTE: derived classes must call drop_references() */ }
39 
40  virtual void operator() () = 0;
41 
42  void set_name (const std::string& str) { _name = str; }
43  const std::string& name() const { return _name; }
44 
45  virtual void undo() = 0;
46  virtual void redo() { (*this)(); }
47 
48  virtual XMLNode& get_state() const;
49  virtual int set_state(const XMLNode&, int /*version*/) { /* noop */ return 0; }
50 
51  virtual bool empty () const {
52  return false;
53  }
54 
55 protected:
56  Command() {}
57  Command(const std::string& name) : _name(name) {}
58 
59  std::string _name;
60 };
61 
62 } /* namespace */
63 
64 #endif // __lib_pbd_command_h_
std::string _name
Definition: command.h:59
virtual bool empty() const
Definition: command.h:51
const std::string & name() const
Definition: command.h:43
virtual XMLNode & get_state() const
void set_name(const std::string &str)
Definition: command.h:42
virtual ~Command()
Definition: command.h:38
virtual void undo()=0
virtual void redo()
Definition: command.h:46
virtual int set_state(const XMLNode &, int)
Definition: command.h:49
Command(const std::string &name)
Definition: command.h:57
Definition: xml++.h:114
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBPBD_API
Definition: axis_view.h:42