]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/translator-group.hh
Issue 4842/4: Replace Translator_method et al
[lilypond.git] / lily / include / translator-group.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1997--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
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.
10
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.
15
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/>.
18 */
19
20 #ifndef TRANSLATOR_GROUP_HH
21 #define TRANSLATOR_GROUP_HH
22
23 #include "callback.hh"
24 #include "listener.hh"
25 #include "translator.hh"
26
27 class Translator_group : public Smob<Translator_group>
28 {
29 public:
30   SCM mark_smob () const;
31   int print_smob (SCM, scm_print_state *) const;
32   static const char type_p_name_[];
33   virtual ~Translator_group ();
34 private:
35   void precompute_method_bindings ();
36   vector<Method_instance>
37   precomputed_method_bindings_[TRANSLATOR_METHOD_PRECOMPUTE_COUNT];
38
39   SCM
40   precomputed_self_method_bindings_[TRANSLATOR_METHOD_PRECOMPUTE_COUNT];
41
42   SCM protected_events_;
43
44   void create_child_translator (SCM);
45
46 public:
47   DECLARE_CLASSNAME (Translator_group);
48
49   virtual void connect_to_context (Context *c);
50   virtual void disconnect_from_context ();
51   virtual SCM get_simple_trans_list ();
52   virtual void initialize ();
53   virtual void finalize ();
54
55   void protect_event (SCM ev);
56
57   void stop_translation_timestep ();
58   void start_translation_timestep ();
59
60   virtual void fetch_precomputable_methods (SCM []);
61
62   Translator_group ();
63
64   void precomputed_translator_foreach (Translator_precompute_index);
65   void call_precomputed_self_method (Translator_precompute_index);
66
67   Context *context () const { return context_; }
68 protected:
69   SCM simple_trans_list_;
70   Context *context_;
71
72   friend class Context_def;
73   virtual void derived_mark () const;
74 };
75
76 SCM names_to_translators (SCM namelist, Context *tg);
77 void recurse_over_translators (Context *c, SCM tr_method,
78                                SCM tr_group_method, Direction);
79 void precomputed_recurse_over_translators (Context *c, Translator_precompute_index idx, Direction dir);
80 Translator_group *get_translator_group (SCM sym);
81
82 #define foobar
83 #define ADD_TRANSLATOR_GROUP(classname, desc, grobs, read, write) foobar
84
85
86 #endif // TRANSLATOR_GROUP_HH