2 translator.hh -- declare Translator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
13 #include "global-ctor.hh"
15 #include "lily-proto.hh"
16 #include "virtual-methods.hh"
17 #include "lily-guile.hh"
21 #define get_property(x) internal_get_property(ly_symbol2scm(x))
24 #define TRANSLATOR_DECLARATIONS(NAME) \
27 VIRTUAL_COPY_CONS (Translator); \
28 static SCM static_description_; \
29 virtual SCM static_translator_description () const; \
30 virtual SCM translator_description () const;
33 Translate music into grobs.
39 Music_output_def * output_def_;
41 Translator (Translator const &);
42 Context * daddy_context_ ;
44 void removal_processing ();
45 virtual Music_output_def *get_output_def () const;
46 SCM internal_get_property (SCM symbol) const;
47 virtual Translator_group* get_daddy_translator ()const;
48 virtual Moment now_mom () const;
51 DECLARE_SMOBS (Translator, dummy);
52 protected: // should be private.
53 SCM simple_trans_list_;
54 friend class Context_def;
56 Score_context * get_score_context () const;
57 Global_context * get_global_context () const;
59 TRANSLATOR_DECLARATIONS(Translator);
60 virtual bool try_music (Music *req);
61 virtual void stop_translation_timestep ();
62 virtual void start_translation_timestep ();
63 virtual void initialize () ;
64 virtual void finalize ();
68 A macro to automate administration of translators.
70 #define ADD_THIS_TRANSLATOR(T) \
71 SCM T::static_description_ = SCM_EOL;\
72 static void _ ## T ## _adder () {\
74 T::static_description_ = t->static_translator_description ();\
75 scm_permanent_object (T::static_description_);\
78 SCM T::translator_description() const\
80 return static_description_;\
82 ADD_GLOBAL_CTOR (_ ## T ## _adder);
87 #define ENTER_DESCRIPTION(classname,desc,grobs,accepted,acked,read,write) \
88 ADD_THIS_TRANSLATOR (classname);\
90 classname::static_translator_description () const \
92 SCM static_properties= SCM_EOL; \
93 /* static_properties= acons (name ,gh_str02scm (Translator::name (self_scm ())), \
94 static_properties_); \
96 static_properties= scm_acons (ly_symbol2scm ("grobs-created"), \
97 parse_symbol_list (grobs), static_properties); \
99 static_properties= scm_acons (ly_symbol2scm ("description"), \
100 scm_makfrom0str (desc), static_properties); \
102 static_properties= scm_acons (ly_symbol2scm ("interfaces-acked"), \
103 parse_symbol_list (acked), static_properties); \
104 static_properties= scm_acons (ly_symbol2scm ("events-accepted"), \
105 parse_symbol_list (accepted), static_properties); \
107 static_properties= scm_acons (ly_symbol2scm ("properties-read"), \
108 parse_symbol_list (read), static_properties); \
110 static_properties= scm_acons (ly_symbol2scm ("properties-written"), \
111 parse_symbol_list (write), static_properties); \
113 return static_properties; \
118 void add_translator (Translator*trans);
120 Translator*get_translator (SCM s);
121 DECLARE_UNSMOB(Translator,translator);
122 bool melisma_busy (Translator*);
123 #endif // TRANSLATOR_HH