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