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>
13 #include "global-ctor.hh"
15 #include "lily-proto.hh"
16 #include "virtual-methods.hh"
20 /* copied from lily-guile.hh */
22 #define get_property(x) internal_get_property (ly_symbol2scm (x))
25 #define TRANSLATOR_DECLARATIONS(NAME) \
28 VIRTUAL_COPY_CONSTRUCTOR (Translator, NAME); \
29 static SCM static_description_; \
30 virtual SCM static_translator_description () const; \
31 virtual SCM translator_description () const;
34 Translate music into grobs.
44 bool must_be_last () const;
46 Context * context () const { return daddy_context_; }
48 Translator (Translator const &);
50 SCM internal_get_property (SCM symbol) const;
52 virtual Output_def *get_output_def () const;
53 virtual Translator_group* get_daddy_translator ()const;
54 virtual Moment now_mom () const;
55 virtual bool try_music (Music *req);
56 virtual void stop_translation_timestep ();
57 virtual void start_translation_timestep ();
58 virtual void initialize () ;
59 virtual void process_music ();
60 virtual void do_announces ();
61 virtual void finalize ();
63 Score_context * get_score_context () const;
64 Global_context * get_global_context () const;
67 TRANSLATOR_DECLARATIONS(Translator);
68 DECLARE_SMOBS (Translator, dummy);
69 protected: // should be private.
70 Context * daddy_context_ ;
71 virtual void derived_mark () const;
73 friend class Context_def;
78 A macro to automate administration of translators.
80 #define ADD_THIS_TRANSLATOR(T) \
81 SCM T::static_description_ = SCM_EOL;\
82 static void _ ## T ## _adder () {\
84 T::static_description_ = t->static_translator_description ();\
85 scm_permanent_object (T::static_description_);\
88 SCM T::translator_description() const\
90 return static_description_;\
92 ADD_GLOBAL_CTOR (_ ## T ## _adder);
97 #define ADD_TRANSLATOR(classname, desc, grobs, accepted, acked, read, write) \
98 ADD_THIS_TRANSLATOR (classname);\
100 classname::static_translator_description () const \
102 SCM static_properties = SCM_EOL; \
103 /* static_properties = acons (name , gh_str02scm (Translator::name (self_scm ())), \
104 static_properties_); \
106 static_properties = scm_acons (ly_symbol2scm ("grobs-created"), \
107 parse_symbol_list (grobs), static_properties); \
109 static_properties = scm_acons (ly_symbol2scm ("description"), \
110 scm_makfrom0str (desc), static_properties); \
112 static_properties = scm_acons (ly_symbol2scm ("interfaces-acked"), \
113 parse_symbol_list (acked), static_properties); \
114 static_properties = scm_acons (ly_symbol2scm ("events-accepted"), \
115 parse_symbol_list (accepted), static_properties); \
117 static_properties = scm_acons (ly_symbol2scm ("properties-read"), \
118 parse_symbol_list (read), static_properties); \
120 static_properties = scm_acons (ly_symbol2scm ("properties-written"), \
121 parse_symbol_list (write), static_properties); \
123 return static_properties; \
128 void add_translator (Translator*trans);
130 Translator*get_translator (SCM s);
131 DECLARE_UNSMOB(Translator, translator);
132 #endif // TRANSLATOR_HH