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