* scm/beam.scm (check-slope-callbacks): check sign of slope.
[lilypond.git] / lily / music-constructor.cc
blobe86672d7c7db6b6eccafc1a5b2979443485c56a6
1 /*
2 music-constructor.cc -- implement Music_constructor
4 source file of the GNU LilyPond music typesetter
6 (c) 2001--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
10 #include <map> // UGH.
11 #include <assert.h>
13 #include "warn.hh"
14 #include "music-constructor.hh"
16 typedef Music* (*Music_ctor) ();
18 static std::map<String,Music_ctor> *ctors_map_;
20 void
21 add_music_ctor (String s, Music_ctor c)
23 if (!ctors_map_)
24 ctors_map_ = new std::map<String, Music_ctor>;
26 (*ctors_map_)[s] = c;
30 Music_ctor
31 get_music_ctor (String s)
33 if (ctors_map_->find (s) == ctors_map_->end ())
34 return 0;
36 return (* ctors_map_)[s];
39 Music*
40 make_music (String s)
42 Music_ctor c = get_music_ctor (s);
43 if (!c)
44 programming_error (String ("No constructor for music: ") + s);
45 assert (c);
47 return (*c) ();