2 music-output-def.cc -- implement Music_output_def
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "music-output-def.hh"
12 #include "global-translator.hh"
13 #include "dictionary-iter.hh"
14 #include "identifier.hh"
16 #include "lily-guile.hh"
19 Music_output_def::get_next_default_count () const
26 Music_output_def::Music_output_def ()
29 translator_p_dict_p_
= new Scope
;
32 Music_output_def::~Music_output_def ()
35 delete translator_p_dict_p_
;
38 Music_output_def::Music_output_def (Music_output_def
const &s
)
40 scope_p_
= new Scope (*s
.scope_p_
);
41 translator_p_dict_p_
= new Scope (*s
.translator_p_dict_p_
);
42 default_properties_
= s
.default_properties_
;
44 for (Scope_iter
i (*translator_p_dict_p_
); i
.ok (); i
++)
46 Translator
* t
= i
.val ()->access_content_Translator_group (false);
47 t
-> output_def_l_
= this;
52 Music_output_def::assign_translator (Translator_group
*tp
)
54 String s
=tp
->type_str_
;
57 tp
->warning (_("Interpretation context with empty type"));
59 if (translator_p_dict_p_
->elem_b (s
))
60 delete translator_p_dict_p_
->elem (s
);
62 translator_p_dict_p_
->elem (s
) = new Translator_group_identifier (tp
, 0);
63 tp
->output_def_l_
= this;
67 Music_output_def::find_translator_l (String name
) const
69 if (translator_p_dict_p_
->elem_b (name
))
70 return translator_p_dict_p_
->elem (name
)->access_content_Translator_group (false);
72 if (global_translator_dict_p
->elem_b (name
))
73 return global_translator_dict_p
->elem(name
);
80 Music_output_def::get_global_translator_p ()
82 Translator
* t
= find_translator_l ("Score");
84 error (_f ("Can't find `%s' context", "Score"));
86 Global_translator
*g
= dynamic_cast <Global_translator
*> (t
);
93 Music_output_def::print () const
96 DEBUG_OUT
<< "Translators: \n";
97 translator_p_dict_p_
->print ();
98 DEBUG_OUT
<< "Other definitions.\n";
104 Music_output_def::get_default_output () const
106 if (safe_global_b
|| !scope_p_
->elem_b ("output"))
108 Identifier
* id
= scope_p_
->elem ("output");
110 String
*p
= id
->access_content_String (false);
111 return p
? *p
: String ("");