]> git.donarmstrong.com Git - lilypond.git/blob - lily/context-specced-music-iterator.cc
38f5549141d0c86780ceb8e423bfb5963dde3f78
[lilypond.git] / lily / context-specced-music-iterator.cc
1 /*
2   context-specced-music-iterator.cc -- implement
3   Context_specced_music_iterator
4
5   source file of the GNU LilyPond music typesetter
6
7   (c) 2002--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
8 */
9
10 #include "music-wrapper-iterator.hh"
11 #include "context.hh"
12 #include "music.hh"
13
14
15 class Context_specced_music_iterator : public Music_wrapper_iterator
16 {
17 public:
18   DECLARE_SCHEME_CALLBACK (constructor, ());
19   virtual void construct_children ();
20 };
21
22 void
23 Context_specced_music_iterator::construct_children ()
24 {
25   SCM ct = get_music ()->get_property ("context-type");
26
27   string c_id;
28   SCM ci = get_music ()->get_property ("context-id");
29   if (scm_is_string (ci))
30     c_id = ly_scm2string (ci);
31   SCM ops = get_music ()->get_property ("property-operations");
32
33   Context *a = 0;
34
35   if (to_boolean (get_music ()->get_property ("create-new")))
36     a = get_outlet ()->create_unique_context (ct, c_id, ops);
37   else
38     a = get_outlet ()->find_create_context (ct, c_id, ops);
39
40   if (a
41       && to_boolean (get_music ()->get_property ("descend-only"))
42       && !is_child_context (get_outlet (), a))
43     a = 0;
44
45   if (a)
46     set_context (a);
47
48   Music_wrapper_iterator::construct_children ();
49 }
50
51 IMPLEMENT_CTOR_CALLBACK (Context_specced_music_iterator);