]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/translator.hh
* lily/include/midi-item.hh (class Midi_track): idem.
[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 vector<Acknowledge_information> acknowledge_static_array_;     \
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   static Engraver_void_function_engraver_grob_info static_get_acknowledger (SCM sym);
40
41 #define DECLARE_ACKNOWLEDGER(x) public : void acknowledge_ ## x (Grob_info); protected:
42
43 enum Translator_precompute_index
44   {
45     START_TRANSLATION_TIMESTEP,
46     STOP_TRANSLATION_TIMESTEP,
47     PROCESS_MUSIC,
48     PROCESS_ACKNOWLEDGED,
49     TRANSLATOR_METHOD_PRECOMPUTE_COUNT,
50   };
51
52 /*
53   Translate music into grobs.
54 */
55 class Translator
56 {
57   void init ();
58
59 protected:
60   bool must_be_last_;
61
62 public:
63   bool must_be_last () const;
64
65   Context *context () const { return daddy_context_; }
66
67   Translator (Translator const &);
68
69   SCM internal_get_property (SCM symbol) const;
70
71   virtual Output_def *get_output_def () const;
72   virtual Translator_group *get_daddy_translator ()const;
73   virtual Moment now_mom () const;
74
75   virtual bool try_music (Music *req);
76   virtual void initialize ();
77   virtual void finalize ();
78
79   void stop_translation_timestep ();
80   void start_translation_timestep ();
81   void process_music ();
82   void process_acknowledged ();
83
84   Score_context *get_score_context () const;
85   Global_context *get_global_context () const;
86
87   TRANSLATOR_DECLARATIONS (Translator);
88   DECLARE_SMOBS (Translator, dummy);
89
90 protected:                      // should be private.
91   Context *daddy_context_;
92   virtual void derived_mark () const;
93
94   friend class Context_def;
95   friend class Context;
96 };
97 void add_translator (Translator *trans);
98
99 Translator *get_translator (SCM s);
100 DECLARE_UNSMOB (Translator, translator);
101 #endif // TRANSLATOR_HH