ardour
clock_group.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 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 "clock_group.h"
21 
23  : ignore_changes (false)
24  , _clock_mode (AudioClock::Frames)
25 {
26 }
27 
29 {
30 }
31 
32 void
34 {
35  if (clocks.insert (&clock).second) {
36  clock.mode_changed.connect (sigc::bind (sigc::mem_fun (*this, &ClockGroup::one_clock_changed), &clock));
37  clock.set_mode (_clock_mode);
38  }
39 }
40 
41 void
43 {
44  clocks.erase (&clock);
45 }
46 
47 void
49 {
50  if (!ignore_changes) {
51  set_clock_mode (clock->mode());
52  }
53 }
54 
55 void
57 {
58  _clock_mode = mode;
59 
60  ignore_changes = true;
61  for (std::set<AudioClock*>::iterator c = clocks.begin(); c != clocks.end(); ++c) {
62  (*c)->set_mode (mode);
63  }
64  ignore_changes = false;
65 }
66 
sigc::signal< void > mode_changed
Definition: audio_clock.h:93
std::set< AudioClock * > clocks
Definition: clock_group.h:40
Mode mode() const
Definition: audio_clock.h:56
AudioClock::Mode _clock_mode
Definition: clock_group.h:42
void set_mode(Mode)
void remove(AudioClock &)
Definition: clock_group.cc:42
void one_clock_changed(AudioClock *)
Definition: clock_group.cc:48
void add(AudioClock &)
Definition: clock_group.cc:33
bool ignore_changes
Definition: clock_group.h:41
void set_clock_mode(AudioClock::Mode)
Definition: clock_group.cc:56