lilypond-1.3.80
[lilypond.git] / lily / music-output-def.cc
blob07895d86e2eec35dd5f6fd85c589c5581682d19d
1 /*
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>
7 */
9 #include "dictionary.hh"
10 #include "scope.hh"
11 #include "debug.hh"
12 #include "music-output-def.hh"
13 #include "global-translator.hh"
15 #include "identifier.hh"
16 #include "main.hh"
17 #include "lily-guile.hh"
19 int
20 Music_output_def::get_next_default_count () const
22 return 0;
27 Music_output_def::Music_output_def ()
29 scope_p_ = new Scope;
30 translator_p_dict_p_ = new Scope;
33 Music_output_def::~Music_output_def ()
35 delete scope_p_;
36 delete translator_p_dict_p_;
39 Music_output_def::Music_output_def (Music_output_def const &s)
41 scope_p_ = new Scope (*s.scope_p_);
42 translator_p_dict_p_ = new Scope (*s.translator_p_dict_p_);
45 void
46 Music_output_def::assign_translator (Translator_group*tp)
48 String s =tp->type_str_;
49 if (s.empty_b ())
51 tp->warning (_("Interpretation context with empty type"));
54 translator_p_dict_p_->set (s, new Translator_group_identifier (tp, 0));
57 Translator*
58 Music_output_def::find_translator_l (String name) const
60 if (translator_p_dict_p_->elem_b (name))
61 return translator_p_dict_p_->elem (name)->access_content_Translator_group (false);
63 map<String, Translator*>::const_iterator ki
64 =global_translator_dict_p->find (name);
66 if (ki != global_translator_dict_p->end ())
67 return (*ki).second ;
69 return 0;
73 Global_translator *
74 Music_output_def::get_global_translator_p ()
76 Translator * t = find_translator_l ("Score");
77 if (!t)
78 error (_f ("can't find `%s' context", "Score"));
79 t = t->clone ();
80 t->output_def_l_ = this;
81 Global_translator *g = dynamic_cast <Global_translator *> (t);
82 t->add_processing ();
84 return g;
87 void
88 Music_output_def::print () const
92 String
93 Music_output_def::get_default_output () const
95 if (safe_global_b || !scope_p_->elem_b ("output"))
96 return "";
97 SCM s = scope_p_->scm_elem ("output");
101 return gh_string_p (s) ? ly_scm2string (s) : String ("");