]> git.donarmstrong.com Git - lilypond.git/blob - lily/translator-ctors.cc
*** empty log message ***
[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--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "translator.hh"
10 #include <map>
11 #include "warn.hh"
12
13 /*
14   should delete these after exit.
15 */
16
17 std::map<String,Translator*> *global_translator_dict=0;
18
19 LY_DEFINE(get_all_translators,"ly:get-all-translators", 0, 0, 0,  (),
20           "Return an list of a all translator objects that may be instantiated "
21           " during a lilypond run.")
22 {
23   SCM l = SCM_EOL;
24   for (std::map<String,Translator*>::const_iterator (ci (global_translator_dict->begin()));
25        ci != global_translator_dict->end (); ci++)
26     {
27       l = scm_cons ((*ci).second->self_scm (), l);
28     }
29   return l;
30 }
31
32 void
33 add_translator (Translator *t)
34 {
35   if (!global_translator_dict)
36     global_translator_dict = new std::map<String,Translator*>;
37
38   (*global_translator_dict)[classname (t)] = t;
39 }
40
41 Translator*
42 get_translator (String s)
43 {
44   if (global_translator_dict->find (s) !=
45       global_translator_dict->end ())
46     {
47       Translator* t = (*global_translator_dict)[s];
48       return t;
49     }
50
51   error (_f ("unknown translator: `%s'", s));
52   return 0;
53 }
54