]> git.donarmstrong.com Git - lilypond.git/blob - lily/context-specced-music-iterator.cc
* lily/context-specced-music-iterator.cc (construct_children):
[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--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8
9 */
10
11 #include "music-wrapper-iterator.hh"
12 #include "context.hh"
13
14 class Context_specced_music_iterator : public Music_wrapper_iterator
15 {
16 public:
17   DECLARE_SCHEME_CALLBACK (constructor,());
18   virtual void construct_children ();
19 };
20
21 void
22 Context_specced_music_iterator::construct_children ()
23 {
24   SCM ct = get_music ()->get_property ("context-type");
25
26   String c_id;
27   SCM ci = get_music ()->get_property ("context-id");
28   if (scm_is_string (ci))
29     c_id = ly_scm2string (ci);
30   SCM ops = get_music ()->get_property ("property-operations");
31   
32   Context * a = 0;
33
34   if (c_id == "$uniqueContextId")
35     a = get_outlet ()->create_unique_context (ct, ops);
36   else
37     a = get_outlet ()->find_create_context (ct, c_id, ops);
38
39   if (a
40        && to_boolean (get_music ()->get_property ("descend-only"))
41       && !is_child_context (get_outlet (), a))
42     a = 0;
43   
44   if (a)
45     set_context (a);
46
47   Music_wrapper_iterator::construct_children ();
48 }
49
50 IMPLEMENT_CTOR_CALLBACK (Context_specced_music_iterator);