]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/translator.hh
release: 1.3.1
[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--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9
10 #ifndef TRANSLATOR_HH
11 #define TRANSLATOR_HH
12 #include "global-ctor.hh"
13 #include "string.hh"
14 #include "lily-proto.hh"
15 #include "virtual-methods.hh"
16 #include "property-inspect.hh"
17 #include "dictionary.hh"
18 #include "parray.hh"
19 #include "input.hh"
20
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 public:
27   Music_output_def * output_def_l_;
28   String type_str_;
29   
30   virtual const char *name() const;
31   bool is_alias_b (String) const;
32     
33   VIRTUAL_COPY_CONS(Translator);
34   Translator (Translator const &);
35   Translator ();
36   virtual ~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_requests();
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 (String, Translator_group **) const;
64   SCM get_property (SCM symbol, Translator_group **) const;
65   
66   virtual Moment now_mom () const;  
67
68 protected:
69    enum { 
70     ORPHAN,
71     VIRGIN,
72     CREATION_INITED,
73     MOVE_INITED,
74     ACCEPTED_REQS,
75     PROCESSED_REQS,
76     ACKED_REQS,
77     MOVE_DONE
78   } status;
79
80   /*    
81         @see{try_request}
82         Default: always return false
83         */
84   virtual void do_add_processing ();
85   virtual bool do_try_music (Music *req_l);
86   virtual void do_print () const;
87   virtual void do_pre_move_processing();
88   virtual void do_post_move_processing();
89   virtual void do_process_requests () ;
90   virtual void do_creation_processing() ;
91   virtual void do_removal_processing();
92 };
93
94
95 /**
96   A macro to automate administration of translators.
97  */
98 #define ADD_THIS_TRANSLATOR(T)                          \
99 static void  _ ## T ## _adder () {\
100       T *t = new T;\
101       t->type_str_ = classname (t);\
102       add_translator (t);\
103 }\
104 ADD_GLOBAL_CTOR(_ ## T ## _adder);
105
106
107
108 extern Dictionary<Translator*> *global_translator_dict_p;
109 void add_translator (Translator*trans_p);
110
111 Translator*get_translator_l (String s);
112
113 #endif // TRANSLATOR_HH