lilypond-0.1.37
[lilypond.git] / lily / music-output-def.cc
blob0c93fb55ab8dac9176a6a71914e1c0d7a9641e6c
1 /*
2 music-output-def.cc -- implement Music_output_def
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "debug.hh"
10 #include "music-output-def.hh"
11 #include "global-translator.hh"
12 #include "dictionary-iter.hh"
14 IMPLEMENT_IS_TYPE_B(Music_output_def);
16 Music_output_def::Music_output_def ()
20 Music_output_def::~Music_output_def ()
22 for (Dictionary_iter<Translator*> i (translator_p_dict_); i.ok (); i++)
23 delete i.val ();
26 Music_output_def::Music_output_def (Music_output_def const &s)
28 for (Dictionary_iter<Translator*> i (s.translator_p_dict_); i.ok (); i++)
29 assign_translator (i.key (), i.val ()->clone ());
32 Translator*
33 Music_output_def::find_translator_l (String name) const
35 if (translator_p_dict_.elt_b (name))
36 return translator_p_dict_[name];
38 if (global_translator_dict_p->elt_b (name))
39 return (*global_translator_dict_p)[name];
41 return 0;
45 Global_translator *
46 Music_output_def::get_global_translator_p ()
48 Translator * t = find_translator_l ("Score")->clone ();
49 Global_translator *g = t->group_l ()->global_l ();
50 t->add_processing ();
52 return g;
56 void
57 Music_output_def::assign_translator (String s, Translator*t)
59 t->type_str_ = s;
60 t->output_def_l_ = this;
61 if (translator_p_dict_.elt_b (s))
62 delete translator_p_dict_[s];
63 translator_p_dict_[s] = t;
66 void
67 Music_output_def::print () const
69 #ifndef NPRINT
70 for (Dictionary_iter<Translator*> i (translator_p_dict_); i.ok (); i++)
72 DOUT << i.key () << " = ";
73 i.val ()->print ();
75 #endif