summaryrefslogtreecommitdiff
path: root/lily/global-regs.cc
blob: 3451ca5270a231fc51d18c95cb5ee251d2fb1528 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
  global-regs.cc -- implement 

  source file of the LilyPond music typesetter

  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
*/

#include "proto.hh"
#include "plist.hh"
#include "input-register.hh"
#include "debug.hh"
#include "register.hh"

struct Request_register_table_entry {
    String name_str_;
    Reg_ctor ctor_l_;
    Request_register_table_entry(String s, Reg_ctor f) {
	name_str_ =s;
	ctor_l_ = f;
    }
    Request_register_table_entry()
    {
	ctor_l_ =0;
    }
};

static Array<Request_register_table_entry> *reg_table=0;

void
add_request_register(String s, Reg_ctor f)
{
    if (!reg_table)
	reg_table = new Array<Request_register_table_entry>;
    
    reg_table->push(Request_register_table_entry(s, f));
}


Request_register*
get_nongroup_register_p(String s)
{
    for (int i=0; i < reg_table->size(); i++) {
	if ((*reg_table)[i].name_str_ == s)
	    return (*(*reg_table)[i].ctor_l_)();
    }
    error("Unknown register `" + s +"\'");
    return 0;
}