]> git.donarmstrong.com Git - lilypond.git/blob - lily/performer-group.cc
Patch for auto-beam; Fix issue 511
[lilypond.git] / lily / performer-group.cc
1 /*
2   performer-group-performer.cc -- implement Performer_group
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1996--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7   Jan Nieuwenhuizen <janneke@gnu.org>
8 */
9
10 #include "performer-group.hh"
11
12 #include "context.hh"
13 #include "audio-element.hh"
14 #include "warn.hh"
15
16 ADD_TRANSLATOR_GROUP (Performer_group,
17                       /* doc */
18                       "",
19
20                       /* create */
21                       "",
22
23                       /* read */
24                       "",
25
26                       /* write */
27                       ""
28                       );
29
30 void
31 Performer_group::announce_element (Audio_element_info info)
32 {
33   announce_infos_.push_back (info);
34   Translator_group *t
35     = context ()->get_parent_context ()->implementation ();
36
37   if (Performer_group *eg = dynamic_cast<Performer_group *> (t))
38     eg->announce_element (info);
39 }
40
41 void
42 Performer_group::acknowledge_audio_elements ()
43 {
44   for (vsize j = 0; j < announce_infos_.size (); j++)
45     {
46       Audio_element_info info = announce_infos_[j];
47
48       for (SCM p = get_simple_trans_list (); scm_is_pair (p); p = scm_cdr (p))
49         {
50           Translator *t = unsmob_translator (scm_car (p));
51           Performer *eng = dynamic_cast<Performer *> (t);
52           if (eng && eng != info.origin_trans_)
53             eng->acknowledge_audio_element (info);
54         }
55     }
56 }
57
58 void
59 performer_each (SCM list, Performer_method method)
60 {
61   for (SCM p = list; scm_is_pair (p); p = scm_cdr (p))
62     {
63       Performer *e = dynamic_cast<Performer *> (unsmob_translator (scm_car (p)));
64       if (e)
65         (e->*method) ();
66     }
67 }
68
69 void
70 Performer_group::do_announces ()
71 {
72   for (SCM s = context ()->children_contexts ();
73        scm_is_pair (s); s = scm_cdr (s))
74     {
75       Context *c = unsmob_context (scm_car (s));
76       Performer_group *group
77         = dynamic_cast<Performer_group *> (c->implementation ());
78       if (group)
79         group->do_announces ();
80     }
81
82   while (1)
83     {
84       performer_each (get_simple_trans_list (),
85                       &Performer::create_audio_elements);
86
87       if (!announce_infos_.size ())
88         break;
89
90       acknowledge_audio_elements ();
91       announce_infos_.clear ();
92     }
93 }