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