]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/translator.hh
df5f2532541488171fba727d56be88e214155320
[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   /*
71     UGH. Clean this up.
72    */
73    enum { 
74     ORPHAN,
75     VIRGIN,
76     CREATION_INITED,
77     MOVE_INITED,
78     ACCEPTED_REQS,
79     PROCESSED_REQS,
80     ACKED_REQS,
81     MOVE_DONE
82   } status;
83
84   /*    
85         @see{try_request}
86         Default: always return false
87         */
88   virtual void do_add_processing ();
89   virtual bool do_try_music (Music *req_l);
90   virtual void do_print () const;
91   virtual void do_pre_move_processing();
92   virtual void do_post_move_processing();
93   virtual void do_process_requests () ;
94   virtual void do_creation_processing() ;
95   virtual void do_removal_processing();
96 };
97
98
99 /**
100   A macro to automate administration of translators.
101  */
102 #define ADD_THIS_TRANSLATOR(T)                          \
103 static void  _ ## T ## _adder () {\
104       T *t = new T;\
105       t->type_str_ = classname (t);\
106       add_translator (t);\
107 }\
108 ADD_GLOBAL_CTOR(_ ## T ## _adder);
109
110
111
112 extern Dictionary<Translator*> *global_translator_dict_p;
113 void add_translator (Translator*trans_p);
114
115 Translator*get_translator_l (String s);
116
117 #endif // TRANSLATOR_HH