]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/register.hh
release: 0.0.63
[lilypond.git] / lily / include / register.hh
1 /*
2   register.hh -- declare Request_register
3
4   source file of the LilyPond music typesetter
5
6   (c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9
10 #ifndef REGISTER_HH
11 #define REGISTER_HH
12
13 #include "lily-proto.hh"
14 #include "varray.hh"
15 #include "request.hh"
16 #include "staff-elem-info.hh"
17 #include "staff-info.hh"
18
19 /**
20   a struct which processes requests, and creates the #Staff_elem#s.
21   It may use derived classes. Hungarian postfix: register
22   */
23 class Request_register {
24     friend class Register_group_register;
25     /**
26       You cannot copy a Request_register
27      */
28     Request_register(const Request_register&){}
29 protected:
30     
31
32     /// utility
33     virtual Paper_def * paper() const;
34
35     /**
36       try to fit the request in this register
37
38       @return
39       false: not noted,  not taken.
40
41       true: request swallowed. Don't try to put the request elsewhere.
42
43
44       Default: always return false
45       */
46     virtual bool try_request(Request *req_l);
47     
48     /// make items/spanners with the requests you got
49     virtual void process_requests(){}
50
51     /** typeset any items/spanners. Default: do nothing
52      */
53     virtual void pre_move_processing(){}
54     /** reset any appropriate data. Default: do nothing
55      */
56     virtual void post_move_processing(){}
57    
58     /**
59       Is this request eligible to be processed? Default: return false.
60      */
61     virtual bool acceptable_request_b(Request*) const;
62
63     /**
64       typeset a "command" item. Default: pass on to daddy.
65       If the column is not breakable, #pre_p# and #post_p# are junked
66       */
67     virtual void typeset_breakable_item(Item * pre_p ,
68                                         Item * nobreak_p, Item * post_p);
69     /**
70       Invoke walker method to typeset element. Default: pass on to daddy.
71       */
72     virtual void typeset_element(Staff_elem*elem_p);
73     
74      /**
75       take note of item/spanner
76       put item in spanner. Adjust local key; etc.
77
78       Default: ignore the info
79       */
80     virtual void acknowledge_element(Staff_elem_info) {}
81     /**
82       Announce element. Default: pass on to daddy. Utility
83       */
84     virtual void announce_element(Staff_elem_info);
85     /**
86       Set Feature of the register(s). Default: ignore Feature.
87      */
88     virtual void set_feature(Feature){}
89     /**
90       ask daddy for a feature
91      */
92     virtual Scalar get_feature(String type_str);
93     /**
94       Does this equal or contain a certain register?
95      */
96
97     virtual void sync_features() {}
98     
99     virtual bool contains_b(Request_register*reg_l)const;
100     /**
101       Get information on the staff. Default: ask daddy.
102       */
103     virtual Staff_info get_staff_info();
104
105
106     virtual void do_print()const;  
107 public:
108     /** Every Request_register (except for the 'top' which is directly
109       inside the Staff_walker, is a element of a group.  */
110     Register_group_register * daddy_reg_l_;
111
112     Request_register();
113     virtual ~Request_register(){}
114     NAME_MEMBERS(Request_register);
115     void print() const;
116 };
117
118 /**
119   A macro to automate administration of registers.
120  */
121 #define ADD_THIS_REGISTER(c)                            \
122 struct c ## init {                                      \
123     static Request_register * globalctor (){            \
124         return new c;                                   \
125     }                                                   \
126     c ## init () {                                      \
127         add_request_register(c::static_name(), globalctor);     \
128                                                         \
129     }                                                   \
130 } _ ## c ## init;
131
132 typedef Request_register*(*Reg_ctor)(void);
133 void add_request_register(String s, Reg_ctor f);
134
135 #endif // REGISTER_HH
136