]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/translator.hh
* Documentation/user/refman.itely (More stanzas): document slur
[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--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9
10 #ifndef TRANSLATOR_HH
11 #define TRANSLATOR_HH
12
13 #include "global-ctor.hh"
14 #include "string.hh"
15 #include "lily-proto.hh"
16 #include "virtual-methods.hh"
17 #include "lily-guile.hh"
18 #include "input.hh"
19 #include "smobs.hh"
20
21 #define get_property(x) internal_get_property(ly_symbol2scm(x))
22
23
24 #define TRANSLATOR_DECLARATIONS(NAME)                   \
25 public:                                                 \
26   NAME();\
27   VIRTUAL_COPY_CONS (Translator);                               \
28   static SCM static_description_;                       \
29   virtual SCM static_translator_description () const;   \
30   virtual SCM translator_description () const;
31
32 /*
33   Translate music into grobs.
34 */
35 class Translator
36 {
37   void init ();
38 public:
39   Music_output_def * output_def_;
40   
41   bool is_alias (SCM) const;
42   Translator (Translator const &);
43
44   
45   Translator_group * daddy_trans_ ;
46   void removal_processing ();
47   Music_output_def *get_output_def () const;
48
49   SCM internal_get_property (SCM symbol) const;
50   
51   virtual Moment now_mom () const;  
52
53   /*
54     ugh: bubbled up.
55    */
56   SCM definition_;
57   SCM properties_scm_;
58   SCM trans_group_list_;
59   SCM accepts_list_;
60   virtual SCM get_simple_trans_list ();
61 public:
62   DECLARE_SMOBS (Translator, dummy);
63 private:
64   /*
65     ugh: bubbled up from Translator_group. 
66    */
67
68 protected:                      // should be private.
69   SCM simple_trans_list_;
70   friend class Context_def;
71   // ugir.
72   //   friend SCM Translator_group::get_simple_trans_list ();
73
74
75 public:
76   Global_translator * top_translator () const;
77   TRANSLATOR_DECLARATIONS(Translator);
78   virtual bool try_music (Music *req);
79   virtual void stop_translation_timestep ();
80   virtual void start_translation_timestep ();
81   virtual void do_announces () ;
82   virtual void initialize () ;
83   virtual void finalize ();
84 };
85
86
87 /**
88   A macro to automate administration of translators.
89  */
90 #define ADD_THIS_TRANSLATOR(T)                          \
91 SCM T::static_description_ = SCM_EOL;\
92 static void  _ ## T ## _adder () {\
93       T *t = new T;\
94       T::static_description_ = t->static_translator_description ();\
95       scm_permanent_object (T::static_description_);\
96       add_translator (t);\
97 }\
98 SCM T::translator_description() const\
99 { \
100   return static_description_;\
101 }\
102 ADD_GLOBAL_CTOR (_ ## T ## _adder);
103
104
105
106
107 #define ENTER_DESCRIPTION(classname,desc,grobs,accepted,acked,read,write)                                               \
108 ADD_THIS_TRANSLATOR (classname);\
109 SCM                                                                                             \
110 classname::static_translator_description () const \
111 {                                                                                               \
112   SCM  static_properties= SCM_EOL;                                                              \
113   /*  static_properties= acons (name ,gh_str02scm (Translator::name (self_scm ())),             \
114                               static_properties_);                                              \
115   */                                                                                            \
116   static_properties= scm_acons (ly_symbol2scm ("grobs-created"),                                \
117                               parse_symbol_list (grobs), static_properties);    \
118                                                                                                 \
119   static_properties= scm_acons (ly_symbol2scm ("description"),                                  \
120                               scm_makfrom0str (desc), static_properties);                               \
121                                                                                                 \
122   static_properties= scm_acons (ly_symbol2scm ("interfaces-acked"),                             \
123                               parse_symbol_list (acked), static_properties);                    \
124   static_properties= scm_acons (ly_symbol2scm ("events-accepted"),                              \
125                               parse_symbol_list (accepted), static_properties);                 \
126                                                                                                 \
127   static_properties= scm_acons (ly_symbol2scm ("properties-read"),                              \
128                               parse_symbol_list (read), static_properties);                     \
129                                                                                                 \
130   static_properties= scm_acons (ly_symbol2scm ("properties-written"),                           \
131                                 parse_symbol_list (write), static_properties);                  \
132                                                                                                 \
133   return static_properties;                                                                     \
134 }
135
136
137
138 void add_translator (Translator*trans);
139
140 Translator*get_translator (SCM s);
141 DECLARE_UNSMOB(Translator,translator);
142 #endif // TRANSLATOR_HH