]> git.donarmstrong.com Git - lilypond.git/blob - lily/translator-ctors.cc
``slikken kreng''
[lilypond.git] / lily / translator-ctors.cc
1 /*
2   translator-ctors.cc -- implement Translator construction
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "translator.hh"
10 #include "dictionary.hh"
11 #include "warn.hh"
12
13 /*
14   should delete these after exit.
15  */
16
17 /*
18   UGH. Dictionary is deprecated
19  */
20 Dictionary<Translator*> *global_translator_dict=0;
21
22 LY_DEFINE(ly_get_all_translators,"ly-get-all-translators", 0, 0, 0,  (),
23           "Return an list of a all translator objects that may be instantiated
24 during a lilypond run.")
25 {
26   SCM l = SCM_EOL;
27   for (std::map<String,Translator*>::const_iterator (ci (global_translator_dict->begin()));
28        ci != global_translator_dict->end (); ci++)
29     {
30       l = scm_cons ((*ci).second->self_scm (), l);
31     }
32   return l;
33 }
34
35 void
36 add_translator (Translator *t)
37 {
38   if (!global_translator_dict)
39     global_translator_dict = new Dictionary<Translator*>;
40
41  (*global_translator_dict)[classname (t)] = t;
42 }
43
44 Translator*
45 get_translator (String s)
46 {
47   if (global_translator_dict->elem_b (s))
48     {
49         Translator* t = (*global_translator_dict)[s];
50         return t;
51     }
52
53   error (_f ("unknown translator: `%s'", s));
54   return 0;
55 }
56