]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/translator.hh
release: 1.1.29
[lilypond.git] / lily / include / translator.hh
1 /*
2   translator.hh -- declare Translator
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9
10 #ifndef TRANSLATOR_HH
11 #define TRANSLATOR_HH
12 #include "global-ctor.hh"
13 #include "string.hh"
14 #include "lily-proto.hh"
15 #include "virtual-methods.hh"
16 #include "scalar.hh"
17 #include "dictionary.hh"
18 #include "parray.hh"
19 #include "input.hh"
20
21
22 /** Make some kind of #Element#s from Requests. Elements are made by
23   hierarchically grouped #Translator#s
24   */
25 class Translator : public Input {
26 public:
27   Music_output_def * output_def_l_;
28   String  type_str_;
29
30   bool is_alias_b (String) const;
31   
32
33     
34   VIRTUAL_COPY_CONS(Translator);
35   Translator (Translator const &);
36   Translator ();
37   virtual ~Translator ();
38   
39   Translator_group * daddy_trans_l_ ;
40  
41   void print () const;
42   
43   /**
44     try to fit the request in this engraver
45
46     @return
47     false: not noted,  not taken.
48
49     true: request swallowed. Don't try to put the request elsewhere.
50
51     */
52   bool try_music (Music*);
53   void pre_move_processing();
54   void add_processing ();
55   void creation_processing ();
56   void process_requests();
57   void post_move_processing();
58   void removal_processing();
59   /**
60     ask daddy for a feature
61     */
62   Music_output_def *output_def_l () const;
63   Scalar get_property (String, Translator_group **) const;
64   virtual Moment now_mom () const;  
65
66 protected:
67    enum { 
68     ORPHAN,
69     VIRGIN,
70     CREATION_INITED,
71     MOVE_INITED,
72     ACCEPTED_REQS,
73     PROCESSED_REQS,
74     ACKED_REQS,
75     MOVE_DONE
76   } status;
77
78   /*    
79         @see{try_request}
80         Default: always return false
81         */
82   virtual void do_add_processing ();
83   virtual bool do_try_music (Music *req_l);
84   virtual void do_print () const;
85   virtual void do_pre_move_processing(){}
86   virtual void do_post_move_processing(){}
87   virtual void do_process_requests () {}
88   virtual void do_creation_processing() {}
89   virtual void do_removal_processing() {}
90 };
91
92
93 /**
94   A macro to automate administration of translators.
95  */
96 #define ADD_THIS_TRANSLATOR(T)                          \
97 static void  _ ## T ## _adder () {\
98       T *t = new T;\
99       t->type_str_ = classname (t);\
100       add_translator (t);\
101 }\
102 ADD_GLOBAL_CTOR(_ ## T ## _adder);
103
104
105
106 extern Dictionary<Translator*> *global_translator_dict_p;
107 void add_translator (Translator*trans_p);
108
109 Translator*get_translator_l (String s);
110
111 #endif // TRANSLATOR_HH