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