lilypond-1.4.4
[lilypond.git] / lily / global-regs.cc
blobca027af462f7d13136a1c3f2486129e57009efba
1 /*
2 global-regs.cc -- implement
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "proto.hh"
10 #include "plist.hh"
11 #include "input-register.hh"
12 #include "debug.hh"
13 #include "register.hh"
15 struct Request_register_table_entry {
16 String name_str_;
17 Reg_ctor ctor_l_;
18 Request_register_table_entry(String s, Reg_ctor f) {
19 name_str_ =s;
20 ctor_l_ = f;
22 Request_register_table_entry()
24 ctor_l_ =0;
28 static Array<Request_register_table_entry> *reg_table=0;
30 void
31 add_request_register(String s, Reg_ctor f)
33 if (!reg_table)
34 reg_table = new Array<Request_register_table_entry>;
36 reg_table->push(Request_register_table_entry(s, f));
40 Request_register*
41 get_register_p(String s)
43 for (int i=0; i < reg_table->size(); i++) {
44 if ((*reg_table)[i].name_str_ == s)
45 return (*(*reg_table)[i].ctor_l_)();
47 error("Unknown register `" + s +"\'");
48 return 0;