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