2 music-output-def.cc -- implement Music_output_def
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 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"
18 Music_output_def::get_next_default_count () const
25 Music_output_def::Music_output_def ()
28 translator_p_dict_p_
= new Scope
;
31 Music_output_def::~Music_output_def ()
34 delete translator_p_dict_p_
;
37 Music_output_def::Music_output_def (Music_output_def
const &s
)
39 scope_p_
= new Scope (*s
.scope_p_
);
40 translator_p_dict_p_
= new Scope (*s
.translator_p_dict_p_
);
42 for (Dictionary_iter
<Identifier
*> i (*translator_p_dict_p_
); i
.ok (); i
++)
44 Translator
* t
= i
.val ()->access_content_Translator (false);
45 t
-> output_def_l_
= this;
50 Music_output_def::assign_translator (Translator
*tp
)
52 String s
=tp
->type_str_
;
53 if (translator_p_dict_p_
->elem_b (s
))
54 delete translator_p_dict_p_
->elem (s
);
56 (*translator_p_dict_p_
)[s
] = new Translator_identifier (tp
, 0);
57 tp
->output_def_l_
= this;
61 Music_output_def::find_translator_l (String name
) const
63 if (translator_p_dict_p_
->elem_b (name
))
64 return (*translator_p_dict_p_
)[name
]->access_content_Translator (false);
66 if (global_translator_dict_p
->elem_b (name
))
67 return (*global_translator_dict_p
)[name
];
74 Music_output_def::get_global_translator_p ()
76 Translator
* t
= find_translator_l ("Score");
78 error (_("Can't find Score context"));
80 Global_translator
*g
= dynamic_cast <Global_translator
*> (t
);
87 Music_output_def::print () const
90 translator_p_dict_p_
->print ();
96 Music_output_def::get_default_output () const
98 if (safe_global_b
|| !scope_p_
->elem_b ("output"))
100 Identifier
* id
= (*scope_p_
) ["output"];
102 String
*p
= id
->access_content_String (false);
103 return p
? *p
: String ("");