]> git.donarmstrong.com Git - lilypond.git/blob - lily/music-constructor.cc
2615221615b801fe75b81e0a73b182ac64f721cd
[lilypond.git] / lily / music-constructor.cc
1 /*   
2   music-constructor.cc --  implement Music_constructor
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #include <map>                  // UGH.
11 #include "music-constructor.hh"
12 typedef Music* (*Music_ctor) ();
13
14 static std::map<String,Music_ctor> *ctors_map_;
15
16 void
17 add_music_ctor (String s,  Music_ctor c)
18 {
19   if (!ctors_map_)
20     ctors_map_ = new std::map<String, Music_ctor>;
21   
22  (*ctors_map_)[s] = c;
23 }
24
25
26 Music_ctor
27 get_music_ctor (String s)
28 {
29   if (ctors_map_->find (s) == ctors_map_->end ())
30     return 0;
31
32   return (* ctors_map_)[s];
33 }
34
35 Music* 
36 get_music (String s)
37 {
38   return (*get_music_ctor (s)) ();
39 }
40