]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/translator-group.hh
Run grand replace for 2015.
[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 "listener.hh"
24 #include "translator.hh"
25
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 *);
29
30 struct Translator_method_binding
31 {
32   Translator *translator_;
33   Translator_void_method_ptr method_;
34
35   Translator_method_binding ()
36   {
37   }
38   Translator_method_binding (Translator *tr, Translator_void_method_ptr ptr)
39   {
40     translator_ = tr;
41     method_ = ptr;
42   }
43   void invoke ()
44   {
45     if (method_)
46       (translator_->*method_) ();
47   }
48 };
49
50 class Translator_group : public Smob<Translator_group>
51 {
52 public:
53   SCM mark_smob ();
54   int print_smob (SCM, scm_print_state *);
55   static const char type_p_name_[];
56   virtual ~Translator_group ();
57 private:
58   void precompute_method_bindings ();
59   vector<Translator_method_binding>
60   precomputed_method_bindings_[TRANSLATOR_METHOD_PRECOMPUTE_COUNT];
61
62   Translator_group_void_method
63   precomputed_self_method_bindings_[TRANSLATOR_METHOD_PRECOMPUTE_COUNT];
64
65   SCM protected_events_;
66
67   DECLARE_LISTENER (create_child_translator);
68
69 public:
70   DECLARE_CLASSNAME (Translator_group);
71
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 ();
77
78   void protect_event (SCM ev);
79
80   void stop_translation_timestep ();
81   void start_translation_timestep ();
82
83   virtual void fetch_precomputable_methods (Translator_group_void_method[]);
84
85   Translator_group ();
86
87   void precomputed_translator_foreach (Translator_precompute_index);
88   void call_precomputed_self_method (Translator_precompute_index);
89
90   Context *context () const { return context_; }
91 protected:
92   SCM simple_trans_list_;
93   Context *context_;
94
95   friend class Context_def;
96   virtual void derived_mark () const;
97 };
98
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);
104
105 #define foobar
106 #define ADD_TRANSLATOR_GROUP(classname, desc, grobs, read, write) foobar
107
108
109 #endif // TRANSLATOR_GROUP_HH