2 translator.hh -- declare Translator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
12 #include "global-ctor.hh"
14 #include "lily-proto.hh"
15 #include "virtual-methods.hh"
19 /* copied from lily-guile.hh */
21 #define get_property(x) internal_get_property (ly_symbol2scm (x))
24 #define TRANSLATOR_DECLARATIONS(NAME) \
27 VIRTUAL_COPY_CONSTRUCTOR (Translator, NAME); \
28 static SCM static_description_; \
29 virtual SCM static_translator_description () const; \
30 virtual SCM translator_description () const;
33 Translate music into grobs.
43 bool must_be_last () const;
45 Context *context () const { return daddy_context_; }
47 Translator (Translator const &);
49 SCM internal_get_property (SCM symbol) const;
51 virtual Output_def *get_output_def () const;
52 virtual Translator_group *get_daddy_translator ()const;
53 virtual Moment now_mom () const;
54 virtual bool try_music (Music *req);
55 virtual void stop_translation_timestep ();
56 virtual void start_translation_timestep ();
57 virtual void initialize ();
58 virtual void process_music ();
59 virtual void do_announces ();
60 virtual void finalize ();
62 Score_context *get_score_context () const;
63 Global_context *get_global_context () const;
65 TRANSLATOR_DECLARATIONS (Translator);
66 DECLARE_SMOBS (Translator, dummy);
67 protected: // should be private.
68 Context *daddy_context_;
69 virtual void derived_mark () const;
71 friend class Context_def;
76 A macro to automate administration of translators.
78 #define ADD_THIS_TRANSLATOR(T) \
79 SCM T::static_description_ = SCM_EOL; \
80 static void _ ## T ## _adder () \
83 T::static_description_ = t->static_translator_description (); \
84 scm_permanent_object (T::static_description_); \
87 SCM T::translator_description () const \
89 return static_description_; \
91 ADD_GLOBAL_CTOR (_ ## T ## _adder);
93 #define ADD_TRANSLATOR(classname, desc, grobs, accepted, acked, read, write) \
94 ADD_THIS_TRANSLATOR (classname); \
96 classname::static_translator_description () const \
98 SCM static_properties = SCM_EOL; \
99 /* static_properties = acons (name , gh_str02scm (Translator::name (self_scm ())), \
100 static_properties_); \
102 static_properties = scm_acons (ly_symbol2scm ("grobs-created"), \
103 parse_symbol_list (grobs), static_properties); \
105 static_properties = scm_acons (ly_symbol2scm ("description"), \
106 scm_makfrom0str (desc), static_properties); \
108 static_properties = scm_acons (ly_symbol2scm ("interfaces-acked"), \
109 parse_symbol_list (acked), static_properties); \
110 static_properties = scm_acons (ly_symbol2scm ("events-accepted"), \
111 parse_symbol_list (accepted), static_properties); \
113 static_properties = scm_acons (ly_symbol2scm ("properties-read"), \
114 parse_symbol_list (read), static_properties); \
116 static_properties = scm_acons (ly_symbol2scm ("properties-written"), \
117 parse_symbol_list (write), static_properties); \
119 return static_properties; \
122 void add_translator (Translator *trans);
124 Translator *get_translator (SCM s);
125 DECLARE_UNSMOB (Translator, translator);
126 #endif // TRANSLATOR_HH