2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1997--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef TRANSLATOR_GROUP_HH
21 #define TRANSLATOR_GROUP_HH
23 #include "listener.hh"
24 #include "translator.hh"
26 typedef void (Translator:: *Translator_method) (void);
27 typedef void (Translator_group:: *Translator_group_method) (void);
28 typedef void (*Translator_group_void_method) (Translator_group *);
30 struct Translator_method_binding
32 Translator *translator_;
33 Translator::Callback method_;
35 Translator_method_binding ()
38 Translator_method_binding (Translator *tr, Translator::Callback ptr)
46 (translator_->*method_) ();
50 class Translator_group : public Smob<Translator_group>
53 SCM mark_smob () const;
54 int print_smob (SCM, scm_print_state *) const;
55 static const char type_p_name_[];
56 virtual ~Translator_group ();
58 void precompute_method_bindings ();
59 vector<Translator_method_binding>
60 precomputed_method_bindings_[TRANSLATOR_METHOD_PRECOMPUTE_COUNT];
62 Translator_group_void_method
63 precomputed_self_method_bindings_[TRANSLATOR_METHOD_PRECOMPUTE_COUNT];
65 SCM protected_events_;
67 void create_child_translator (SCM);
70 DECLARE_CLASSNAME (Translator_group);
72 virtual void connect_to_context (Context *c);
73 virtual void disconnect_from_context ();
74 virtual SCM get_simple_trans_list ();
75 virtual void initialize ();
76 virtual void finalize ();
78 void protect_event (SCM ev);
80 void stop_translation_timestep ();
81 void start_translation_timestep ();
83 virtual void fetch_precomputable_methods (Translator_group_void_method[]);
87 void precomputed_translator_foreach (Translator_precompute_index);
88 void call_precomputed_self_method (Translator_precompute_index);
90 Context *context () const { return context_; }
92 SCM simple_trans_list_;
95 friend class Context_def;
96 virtual void derived_mark () const;
99 SCM names_to_translators (SCM namelist, Context *tg);
100 void recurse_over_translators (Context *c, Translator_method ptr,
101 Translator_group_method ptr2, Direction);
102 void precomputed_recurse_over_translators (Context *c, Translator_precompute_index idx, Direction dir);
103 Translator_group *get_translator_group (SCM sym);
106 #define ADD_TRANSLATOR_GROUP(classname, desc, grobs, read, write) foobar
109 #endif // TRANSLATOR_GROUP_HH