]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/translator.hh
Fix some bugs in the dynamic engraver and PostScript backend
[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--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #ifndef TRANSLATOR_HH
10 #define TRANSLATOR_HH
11
12 #include "global-ctor.hh"
13 #include "std-string.hh"
14 #include "lily-proto.hh"
15 #include "virtual-methods.hh"
16 #include "input.hh"
17 #include "smobs.hh"
18 #include "std-vector.hh"
19
20 struct Acknowledge_information
21 {
22   SCM symbol_;
23   Engraver_void_function_engraver_grob_info function_;
24 };
25
26 #define TRANSLATOR_DECLARATIONS(NAME)                                   \
27   public:                                                               \
28   NAME ();                                                              \
29   VIRTUAL_COPY_CONSTRUCTOR (Translator, NAME);                          \
30   static SCM static_description_;                                       \
31   static Drul_array<vector<Acknowledge_information> > acknowledge_static_array_drul_; \
32   virtual void fetch_precomputable_methods (Translator_void_method_ptr methods[]); \
33   virtual SCM static_translator_description () const;                   \
34   virtual SCM translator_description () const;                          \
35   virtual Engraver_void_function_engraver_grob_info get_acknowledger (SCM sym) \
36   {                                                                     \
37     return static_get_acknowledger (sym);                               \
38   }                                                                     \
39   virtual Engraver_void_function_engraver_grob_info get_end_acknowledger (SCM sym) \
40   {                                                                     \
41     return static_get_end_acknowledger (sym);                           \
42   } \
43   static Engraver_void_function_engraver_grob_info static_get_acknowledger (SCM sym); \
44   static Engraver_void_function_engraver_grob_info static_get_end_acknowledger(SCM); \
45   /* end #define */
46
47
48 #define DECLARE_ACKNOWLEDGER(x) public : void acknowledge_ ## x (Grob_info); protected:
49 #define DECLARE_END_ACKNOWLEDGER(x) public : void acknowledge_end_ ## x (Grob_info); protected:
50
51 enum Translator_precompute_index
52   {
53     START_TRANSLATION_TIMESTEP,
54     STOP_TRANSLATION_TIMESTEP,
55     PROCESS_MUSIC,
56     PROCESS_ACKNOWLEDGED,
57     TRANSLATOR_METHOD_PRECOMPUTE_COUNT,
58   };
59
60 /*
61   Translate music into grobs.
62 */
63 class Translator
64 {
65   void init ();
66
67 protected:
68   bool must_be_last_;
69
70 public:
71   bool must_be_last () const;
72
73   Context *context () const { return daddy_context_; }
74
75   Translator (Translator const &);
76
77   SCM internal_get_property (SCM symbol) const;
78
79   virtual Output_def *get_output_def () const;
80   virtual Translator_group *get_daddy_translator ()const;
81   virtual Moment now_mom () const;
82
83   virtual bool try_music (Music *req);
84   virtual void initialize ();
85   virtual void finalize ();
86
87   void stop_translation_timestep ();
88   void start_translation_timestep ();
89   void process_music ();
90   void process_acknowledged ();
91
92   Score_context *get_score_context () const;
93   Global_context *get_global_context () const;
94
95   TRANSLATOR_DECLARATIONS (Translator);
96   DECLARE_SMOBS (Translator, dummy);
97
98 protected:                      // should be private.
99   Context *daddy_context_;
100   virtual void derived_mark () const;
101
102   friend class Context_def;
103   friend class Context;
104 };
105 void add_translator (Translator *trans);
106
107 Translator *get_translator (SCM s);
108 DECLARE_UNSMOB (Translator, translator);
109 #endif // TRANSLATOR_HH