X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Finclude%2Ftranslator.hh;h=997735483ad6a0826cccc3b3ecaf5c96cf9309c4;hb=dfb3c8a4b2ee5edab542740b7ae1026b07ba2ef6;hp=bfcf734e307007a63cf610844bc29637e9048edb;hpb=2862b1027f316a2f0444fa92e441ee28acf7a463;p=lilypond.git diff --git a/lily/include/translator.hh b/lily/include/translator.hh index bfcf734e30..997735483a 100644 --- a/lily/include/translator.hh +++ b/lily/include/translator.hh @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1997 Han-Wen Nienhuys + (c) 1997--1998 Han-Wen Nienhuys */ @@ -13,30 +13,110 @@ #include "string.hh" #include "lily-proto.hh" #include "virtual-methods.hh" +#include "scalar.hh" +#include "dictionary.hh" +#include "parray.hh" +#include "input.hh" + /** Make some kind of #Element#s from Requests. Elements are made by hierarchically grouped #Translator#s */ -class Translator { +class Translator : public Input { public: - String id_str_; - - int iterator_count_; - - virtual Global_translator *global_l() { return 0; } + Music_output_def * output_def_l_; + String type_str_; + + bool is_alias_b (String) const; + - virtual void print() const; - /// Score_register = 0, Staff_registers = 1, etc) - virtual int depth_i() const=0; - virtual bool is_bottom_engraver_b() const { return false; } - virtual bool try_request (Request*); - virtual Translator *find_get_translator_l (String name, String id)=0; - virtual Translator *ancestor_l (int l=1)=0; - virtual ~Translator(){} - DECLARE_MY_RUNTIME_TYPEINFO; - Translator(); - virtual Translator *get_default_interpreter()=0; + VIRTUAL_COPY_CONS(Translator); + Translator (Translator const &); + Translator (); + virtual ~Translator (); + + Translator_group * daddy_trans_l_ ; + + void print () const; + + /** + try to fit the request in this engraver + + @return + false: not noted, not taken. + + true: request swallowed. Don't try to put the request elsewhere. + + */ + bool try_music (Music*); + void pre_move_processing(); + void add_processing (); + void creation_processing (); + void process_requests(); + void post_move_processing(); + void removal_processing(); + /** + ask daddy for a feature + */ + Music_output_def *output_def_l () const; + Scalar get_property (String, Translator_group **) const; + virtual Moment now_mom () const; + +protected: + enum { + ORPHAN, + VIRGIN, + CREATION_INITED, + MOVE_INITED, + ACCEPTED_REQS, + PROCESSED_REQS, + ACKED_REQS, + MOVE_DONE + } status; + + /* + @see{try_request} + Default: always return false + */ + virtual void do_add_processing (); + virtual bool do_try_music (Music *req_l); + virtual void do_print () const; + virtual void do_pre_move_processing(){} + virtual void do_post_move_processing(){} + virtual void do_process_requests () {} + virtual void do_creation_processing() {} + virtual void do_removal_processing() {} }; + +template +class Translator_adder +{ +public: + static Translator *ctor () + { + T *t = new T; + t->type_str_ = classname (t); + return t; + } + Translator_adder () { + add_constructor (ctor); + } +}; + +/** + A macro to automate administration of translators. + */ +#define ADD_THIS_TRANSLATOR(c) \ + Translator_adder _ ## c ## init; + +typedef Translator *(*Translator_ctor) (); + +extern Dictionary *global_translator_dict_p; +void add_translator (Translator*trans_p); +void add_constructor (Translator_ctor ctor); + +Translator*get_translator_l (String s); + #endif // TRANSLATOR_HH