788a5be0341776c716f0a9d8fd88e52b212171dc
[ardour.git] / libs / pbd / stateful_diff_command.cc
1 /*
2     Copyright (C) 2010 Paul Davis 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include "pbd/stateful_diff_command.h"
21
22 using namespace std;
23 using namespace PBD;
24
25 /** Create a new StatefulDiffCommand by examining the changes made to a Stateful
26  *  since the last time that clear_history was called on it.
27  *  @param s Stateful object.
28  */
29
30 StatefulDiffCommand::StatefulDiffCommand (Stateful* s)
31         : _object (s)
32 {
33         pair<XMLNode *, XMLNode*> const p = s->diff ();
34         _before = p.first;
35         _after = p.second;
36 }
37
38
39 StatefulDiffCommand::~StatefulDiffCommand ()
40 {
41         delete _before;
42         delete _after;
43 }
44
45 void
46 StatefulDiffCommand::operator() ()
47 {
48         _object->set_state (*_after, Stateful::current_state_version);
49 }
50
51 void
52 StatefulDiffCommand::undo ()
53 {
54         _object->set_state (*_before, Stateful::current_state_version);
55 }
56
57 XMLNode&
58 StatefulDiffCommand::get_state ()
59 {
60         /* XXX */
61 }