]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/translator.hh
release: 1.3.82
[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--2000 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   void print () const;
41   
42   /**
43     try to fit the request in this engraver
44
45     @return
46     false: not noted,  not taken.
47
48     true: request swallowed. Don't try to put the request elsewhere.
49
50     */
51   bool try_music (Music*);
52   void pre_move_processing();
53   void add_processing ();
54   void creation_processing ();
55   void process_music();
56   void post_move_processing();
57   void removal_processing();
58   /**
59     ask daddy for a feature
60     */
61   Music_output_def *output_def_l () const;
62
63   SCM get_property (const char *) const;
64   SCM get_property (SCM symbol) const;
65   
66   virtual Moment now_mom () const;  
67
68   /*
69     ugh: bubbled up from Translator_group. 
70    */
71   SCM consists_name_list_;
72   SCM end_consists_name_list_;
73   SCM accepts_name_list_;
74   SCM simple_trans_list_;
75   SCM trans_group_list_;
76   SCM properties_scm_;
77   SCM property_pushes_;
78   DECLARE_SMOBS(Translator, dummy);
79
80 public:
81   /*
82     UGH. Clean this up.
83    */
84    enum { 
85     ORPHAN,
86     VIRGIN,
87     CREATION_INITED,
88     MOVE_INITED,
89     ACCEPTED_REQS,
90     PROCESSED_REQS,
91     ACKED_REQS,
92     MOVE_DONE
93   } status_;                    // junkme
94 protected:
95
96   /*    
97         @see{try_request}
98         Default: always return false
99         */
100   virtual void do_add_processing ();
101   virtual bool do_try_music (Music *req_l);
102   virtual void do_print () const;
103   virtual void do_pre_move_processing();
104   virtual void do_post_move_processing();
105   virtual void do_process_music () ;
106   virtual void do_creation_processing() ;
107   virtual void do_removal_processing();
108 };
109
110
111 /**
112   A macro to automate administration of translators.
113  */
114 #define ADD_THIS_TRANSLATOR(T)                          \
115 static void  _ ## T ## _adder () {\
116       T *t = new T;\
117       t->type_str_ = classname (t);\
118       add_translator (t);\
119 }\
120 ADD_GLOBAL_CTOR(_ ## T ## _adder);
121
122
123
124 extern Dictionary<Translator*> *global_translator_dict_p;
125 void add_translator (Translator*trans_p);
126
127 Translator*get_translator_l (String s);
128 Translator *unsmob_translator (SCM);
129 #endif // TRANSLATOR_HH