]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/translator.hh
release: 1.5.19
[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--2001 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 "parray.hh"
19 #include "input.hh"
20 #include "smobs.hh"
21
22 #define get_property(x) internal_get_property(ly_symbol2scm(x))
23
24
25 #define TRANSLATOR_DECLARATIONS(NAME)                   \
26 public:                                                 \
27   NAME();\
28   VIRTUAL_COPY_CONS (Translator);                               \
29   static SCM static_description_;                       \
30   virtual SCM static_translator_description () const;   \
31   virtual SCM translator_description () const;
32
33 /** Make some kind of #Element#s from Requests. Elements are made by
34   hierarchically grouped #Translator#s
35   */
36 class Translator : public Input {
37   void init ();
38 public:
39   Music_output_def * output_def_l_;
40   String type_str_;
41   
42   bool is_alias_b (String) const;
43     
44
45   Translator (Translator const &);
46
47   
48   Translator_group * daddy_trans_l_ ;
49   DECLARE_SCHEME_CALLBACK(name, (SCM trans));
50   DECLARE_SCHEME_CALLBACK(description,(SCM trans));
51   void announces ();
52
53   void removal_processing ();
54   /**
55     ask daddy for a feature
56     */
57   Music_output_def *output_def_l () const;
58
59   SCM internal_get_property (SCM symbol) const;
60   
61   virtual Moment now_mom () const;  
62
63   /*
64     ugh: bubbled up from Translator_group. 
65    */
66   SCM simple_trans_list_;
67   SCM trans_group_list_;
68   SCM definition_;
69   
70   SCM properties_scm_;
71   DECLARE_SMOBS (Translator, dummy);
72
73 public:
74   TRANSLATOR_DECLARATIONS(Translator);
75     /**
76     try to fit the request in this engraver
77
78     @return
79     false: not noted,  not taken.
80
81     true: request swallowed. Don't try to put the request elsewhere.
82
83     */
84   virtual bool try_music (Music *req_l);
85   virtual void stop_translation_timestep ();
86   virtual void start_translation_timestep ();
87   virtual void do_announces () ;
88   virtual void initialize () ;
89   virtual void finalize ();
90 };
91
92
93 /**
94   A macro to automate administration of translators.
95  */
96 #define ADD_THIS_TRANSLATOR(T)                          \
97 SCM T::static_description_ = SCM_EOL;\
98 static void  _ ## T ## _adder () {\
99       T *t = new T;\
100       T::static_description_ = t->static_translator_description ();\
101       scm_permanent_object (T::static_description_);\
102       t->type_str_ = classname (t);\
103       add_translator (t);\
104 }\
105 SCM T::translator_description() const\
106 { \
107   return static_description_;\
108 }\
109 ADD_GLOBAL_CTOR (_ ## T ## _adder);
110
111
112
113
114 #define ENTER_DESCRIPTION(classname,desc,grobs,acked,read,write)                                                \
115 ADD_THIS_TRANSLATOR (classname);\
116 SCM                                                                                             \
117 classname::static_translator_description () const \
118 {                                                                                               \
119   SCM  static_properties= SCM_EOL;                                                              \
120   /*  static_properties= acons (name ,gh_str02scm (Translator::name (self_scm ())),             \
121                               static_properties_);                                              \
122   */                                                                                            \
123   static_properties= scm_acons (ly_symbol2scm ("grobs-created"),                                \
124                               parse_symbol_list (grobs), static_properties);    \
125                                                                                                 \
126   static_properties= scm_acons (ly_symbol2scm ("description"),                                  \
127                               ly_str02scm (desc), static_properties);                           \
128                                                                                                 \
129   static_properties= scm_acons (ly_symbol2scm ("interfaces-acked"),                             \
130                               parse_symbol_list (acked), static_properties);                    \
131                                                                                                 \
132   static_properties= scm_acons (ly_symbol2scm ("properties-read"),                              \
133                               parse_symbol_list (read), static_properties);                     \
134                                                                                                 \
135   static_properties= scm_acons (ly_symbol2scm ("properties-written"),                           \
136                                 parse_symbol_list (write), static_properties);                  \
137                                                                                                 \
138   return static_properties;                                                                     \
139 }
140
141
142
143 extern Dictionary<Translator*> *global_translator_dict_p;
144 void add_translator (Translator*trans_p);
145
146 Translator*get_translator_l (String s);
147 DECLARE_UNSMOB(Translator,translator);
148 #endif // TRANSLATOR_HH