Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
24 
25 #include <string>
26 
27 #include "pbd/libpbd_visibility.h"
28 #include "pbd/signals.h"
30 
31 namespace PBD {
32 
35 {
36 public:
37  virtual ~Command() { /* NOTE: derived classes must call drop_references() */ }
38 
39  virtual void operator() () = 0;
40 
41  void set_name (const std::string& str) { _name = str; }
42  const std::string& name() const { return _name; }
43 
44  virtual void undo() = 0;
45  virtual void redo() { (*this)(); }
46 
47  virtual XMLNode& get_state() const;
48  virtual int set_state(const XMLNode&, int /*version*/) { /* noop */ return 0; }
49 
50  virtual bool empty () const {
51  return false;
52  }
53 
54 protected:
55  Command() {}
56  Command(const std::string& name) : _name(name) {}
57 
58  std::string _name;
59 };
60 
61 } /* namespace */
62 
std::string _name
Definition: command.h:58
virtual bool empty() const
Definition: command.h:50
const std::string & name() const
Definition: command.h:42
virtual XMLNode & get_state() const
void set_name(const std::string &str)
Definition: command.h:41
virtual ~Command()
Definition: command.h:37
virtual void undo()=0
virtual void redo()
Definition: command.h:45
virtual int set_state(const XMLNode &, int)
Definition: command.h:48
Command(const std::string &name)
Definition: command.h:56
Definition: xml++.h:114
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBPBD_API
Definition: axis_view.h:42