]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/translator.hh
release: 1.3.142
[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 /** Make some kind of #Element#s from Requests. Elements are made by
23   hierarchically grouped #Translator#s
24   */
25 class Translator : public Input {
26   void init ();
27 public:
28   Music_output_def * output_def_l_;
29   String type_str_;
30   
31   virtual const char *name () const;
32   bool is_alias_b (String) const;
33     
34   VIRTUAL_COPY_CONS (Translator);
35   Translator (Translator const &);
36   Translator ();
37   
38   Translator_group * daddy_trans_l_ ;
39  
40
41   void pre_move_processing ();
42   void announces ();
43   void post_move_processing ();
44   void removal_processing ();
45   /**
46     ask daddy for a feature
47     */
48   Music_output_def *output_def_l () const;
49
50   SCM get_property (const char *) const;
51   SCM get_property (SCM symbol) const;
52   
53   virtual Moment now_mom () const;  
54
55   /*
56     ugh: bubbled up from Translator_group. 
57    */
58   SCM simple_trans_list_;
59   SCM trans_group_list_;
60   SCM definition_;
61   
62   SCM properties_scm_;
63   DECLARE_SMOBS (Translator, dummy);
64 public:
65
66     /**
67     try to fit the request in this engraver
68
69     @return
70     false: not noted,  not taken.
71
72     true: request swallowed. Don't try to put the request elsewhere.
73
74     */
75   virtual bool try_music (Music *req_l);
76   virtual void stop_translation_timestep ();
77   virtual void start_translation_timestep ();
78   virtual void do_announces () ;
79   virtual void initialize () ;
80   virtual void finalize ();
81 };
82
83
84 /**
85   A macro to automate administration of translators.
86  */
87 #define ADD_THIS_TRANSLATOR(T)                          \
88 static void  _ ## T ## _adder () {\
89       T *t = new T;\
90       t->type_str_ = classname (t);\
91       add_translator (t);\
92 }\
93 ADD_GLOBAL_CTOR (_ ## T ## _adder);
94
95
96
97 extern Dictionary<Translator*> *global_translator_dict_p;
98 void add_translator (Translator*trans_p);
99
100 Translator*get_translator_l (String s);
101 Translator *unsmob_translator (SCM);
102 #endif // TRANSLATOR_HH