]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/translator.hh
* lily/context.cc (where_defined): also assign value in
[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 /* nothing */
50 #define PRECOMPUTED_VIRTUAL 
51
52
53 /*
54   Translate music into grobs.
55 */
56 class Translator
57 {
58   void init ();
59   
60 protected:
61   bool must_be_last_;
62
63 public:
64   bool must_be_last () const;
65
66   Context *context () const { return daddy_context_; }
67
68   Translator (Translator const &);
69
70   SCM internal_get_property (SCM symbol) const;
71
72   virtual Output_def *get_output_def () const;
73   virtual Translator_group *get_daddy_translator ()const;
74   virtual Moment now_mom () const;
75   
76   virtual bool try_music (Music *req);
77   virtual void initialize ();
78   virtual void finalize ();
79
80   PRECOMPUTED_VIRTUAL void stop_translation_timestep ();
81   PRECOMPUTED_VIRTUAL void start_translation_timestep ();
82   PRECOMPUTED_VIRTUAL void process_music ();
83   PRECOMPUTED_VIRTUAL void process_acknowledged ();
84   
85   Score_context *get_score_context () const;
86   Global_context *get_global_context () const;
87
88   TRANSLATOR_DECLARATIONS (Translator);
89   DECLARE_SMOBS (Translator, dummy);
90
91 protected:                      // should be private.
92   Context *daddy_context_;
93   virtual void derived_mark () const;
94
95   friend class Context_def;
96   friend class Context;
97 };
98 void add_translator (Translator *trans);
99
100 Translator *get_translator (SCM s);
101 DECLARE_UNSMOB (Translator, translator);
102 #endif // TRANSLATOR_HH