]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/translator.hh
release: 1.3.19
[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  #include <typeinfo>
13 #include "global-ctor.hh"
14 #include "string.hh"
15 #include "lily-proto.hh"
16 #include "virtual-methods.hh"
17 #include "lily-guile.hh"
18 #include "dictionary.hh"
19 #include "parray.hh"
20 #include "input.hh"
21
22
23 /** Make some kind of #Element#s from Requests. Elements are made by
24   hierarchically grouped #Translator#s
25   */
26 class Translator : public Input {
27 public:
28   Music_output_def * output_def_l_;
29   String type_str_;
30   
31   virtual const char *name() const;
32   bool is_alias_b (String) const;
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
64   SCM get_property (String, Translator_group **) const;
65   SCM get_property (SCM symbol, Translator_group **) const;
66   
67   virtual Moment now_mom () const;  
68
69 protected:
70    enum { 
71     ORPHAN,
72     VIRGIN,
73     CREATION_INITED,
74     MOVE_INITED,
75     ACCEPTED_REQS,
76     PROCESSED_REQS,
77     ACKED_REQS,
78     MOVE_DONE
79   } status;
80
81   /*    
82         @see{try_request}
83         Default: always return false
84         */
85   virtual void do_add_processing ();
86   virtual bool do_try_music (Music *req_l);
87   virtual void do_print () const;
88   virtual void do_pre_move_processing();
89   virtual void do_post_move_processing();
90   virtual void do_process_requests () ;
91   virtual void do_creation_processing() ;
92   virtual void do_removal_processing();
93 };
94
95
96 /**
97   A macro to automate administration of translators.
98  */
99 #define ADD_THIS_TRANSLATOR(T)                          \
100 static void  _ ## T ## _adder () {\
101       T *t = new T;\
102       t->type_str_ = classname (t);\
103       add_translator (t);\
104 }\
105 ADD_GLOBAL_CTOR(_ ## T ## _adder);
106
107
108
109 extern Dictionary<Translator*> *global_translator_dict_p;
110 void add_translator (Translator*trans_p);
111
112 Translator*get_translator_l (String s);
113
114 #endif // TRANSLATOR_HH