]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/translator.hh
*** empty log message ***
[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
19 struct Acknowledge_information
20 {
21   SCM symbol_;
22   Engraver_void_function_engraver_grob_info function_;
23 };
24
25 #define TRANSLATOR_DECLARATIONS(NAME)                                   \
26   public:                                                               \
27   NAME ();                                                              \
28   VIRTUAL_COPY_CONSTRUCTOR (Translator, NAME);                          \
29   static SCM static_description_;                                       \
30   static Array<Acknowledge_information> acknowledge_static_array_;      \
31   virtual void fetch_precomputable_methods (Translator_void_method_ptr methods[]); \
32   virtual SCM static_translator_description () const;                   \
33   virtual SCM translator_description () const;                          \
34   virtual Engraver_void_function_engraver_grob_info get_acknowledger (SCM sym) \
35   {                                                                     \
36     return static_get_acknowledger (sym);                               \
37   }                                                                     \
38   static Engraver_void_function_engraver_grob_info static_get_acknowledger (SCM sym);
39
40 #define DECLARE_ACKNOWLEDGER(x) public : void acknowledge_ ## x (Grob_info); protected:
41
42 enum Translator_precompute_index
43   {
44     START_TRANSLATION_TIMESTEP,
45     STOP_TRANSLATION_TIMESTEP,
46     PROCESS_MUSIC,
47     PROCESS_ACKNOWLEDGED,
48     TRANSLATOR_METHOD_PRECOMPUTE_COUNT,
49   };
50
51 /*
52   Translate music into grobs.
53 */
54 class Translator
55 {
56   void init ();
57
58 protected:
59   bool must_be_last_;
60
61 public:
62   bool must_be_last () const;
63
64   Context *context () const { return daddy_context_; }
65
66   Translator (Translator const &);
67
68   SCM internal_get_property (SCM symbol) const;
69
70   virtual Output_def *get_output_def () const;
71   virtual Translator_group *get_daddy_translator ()const;
72   virtual Moment now_mom () const;
73
74   virtual bool try_music (Music *req);
75   virtual void initialize ();
76   virtual void finalize ();
77
78   void stop_translation_timestep ();
79   void start_translation_timestep ();
80   void process_music ();
81   void process_acknowledged ();
82
83   Score_context *get_score_context () const;
84   Global_context *get_global_context () const;
85
86   TRANSLATOR_DECLARATIONS (Translator);
87   DECLARE_SMOBS (Translator, dummy);
88
89 protected:                      // should be private.
90   Context *daddy_context_;
91   virtual void derived_mark () const;
92
93   friend class Context_def;
94   friend class Context;
95 };
96 void add_translator (Translator *trans);
97
98 Translator *get_translator (SCM s);
99 DECLARE_UNSMOB (Translator, translator);
100 #endif // TRANSLATOR_HH