Ardour  9.0-pre0-582-g084a23a80d
tempo_map_change.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2022 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 #include <string>
20 
21 #include "temporal/tempo.h"
22 
23 #include "public_editor.h"
24 
25 /* RAII for tempo map edits. This object manages both Tempo map RCU stuff, plus
26  * reversible command state, removing the need for repeated boilerplate at each
27  * map edit site.
28  *
29  * One complication: GUI tempo map markers are all reassociated with the
30  * relevant points of the write-copy of the map during ::begin() (typically
31  * called in the constructor, unless it's begin argument is false). You must
32  * delay getting a reference on a point to edit until after the TempoMapChange
33  * object has called begin() (i.e. has been constructed), otherwise the
34  * reference will point to the "old" copy of the map.
35  */
36 
38  public:
39  TempoMapChange (PublicEditor& e, std::string const & name, bool update_on_commit = true, bool begin = true);
41 
42  void begin ();
43  void abort ();
45 
46  Temporal::TempoMap& map() const { return *writable_map.get(); }
47 
48  private:
51  std::string name;
52  bool aborted;
53  bool begun;
56 };
Representation of the interface of the Editor class.
Temporal::TempoMap::WritableSharedPtr writable_map
PublicEditor & editor
void use_new_map(Temporal::TempoMap::WritableSharedPtr)
Temporal::TempoMap & map() const
std::string name
TempoMapChange(PublicEditor &e, std::string const &name, bool update_on_commit=true, bool begin=true)
std::shared_ptr< TempoMap > WritableSharedPtr
Definition: xml++.h:114