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