2 context.hh -- declare Context
4 source file of the GNU LilyPond music typesetter
6 (c) 2004--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
12 #include "context-key-manager.hh"
13 #include "lily-proto.hh"
14 #include "listener.hh"
16 #include "std-vector.hh"
17 #include "virtual-methods.hh"
21 Scheme_hash_table *properties_dict () const;
22 Context (Context const &src);
24 DECLARE_SMOBS (Context);
25 DECLARE_CLASSNAME(Context);
29 friend class Context_handle;
32 /* Used internally by create_context */
33 Stream_event *infant_event_;
36 Context *daddy_context_;
37 /* The used Context_def */
39 /* Additions to the Context_def, given by \with */
41 Context_key_manager key_manager_;
47 Translator_group *implementation_;
50 /* Events reported in the context is sent to this dispatcher. */
51 Dispatcher *event_source_;
53 /* Events reported to this context or recursively in any of its
54 children, are sent to this dispatcher. */
55 Dispatcher *events_below_;
57 // Translator_group is allowed to set implementation_.
58 friend class Translator_group;
59 // Context_def::instantiate initialises some protected members.
60 friend class Context_def;
61 // UGH! initialises implementation_
62 friend SCM ly_make_global_translator (SCM);
63 void clear_key_disambiguations ();
65 DECLARE_LISTENER (set_property_from_event);
66 DECLARE_LISTENER (unset_property_from_event);
69 Object_key const *get_grob_key (string name);
70 Object_key const *get_context_key (string name, string id);
72 string id_string () const { return id_string_; }
73 SCM children_contexts () const { return context_list_; }
74 SCM default_child_context_name () const;
76 Dispatcher *event_source () const { return event_source_; }
77 Dispatcher *events_below () const { return events_below_; }
78 void internal_send_stream_event (SCM type, Input *origin, SCM props[]);
80 SCM get_definition () const { return definition_; }
81 SCM get_definition_mods () const { return definition_mods_; }
83 Translator_group *implementation () const { return implementation_; }
84 Context *get_parent_context () const;
85 Context (Object_key const *);
88 SCM internal_get_property (SCM name_sym) const;
89 SCM properties_as_alist () const;
90 Context *where_defined (SCM name_sym, SCM *value) const;
91 void unset_property (SCM var_sym);
94 void internal_set_property (SCM var_sym, SCM value, char const *file, int line, char const *fun);
96 void internal_set_property (SCM var_sym, SCM value);
99 Context *create_context (Context_def *, string, SCM);
100 DECLARE_LISTENER (create_context_from_event);
101 DECLARE_LISTENER (acknowledge_infant);
102 DECLARE_LISTENER (remove_context);
103 DECLARE_LISTENER (change_parent);
104 void disconnect_from_parent ();
105 void check_removal ();
106 string context_name () const;
107 SCM context_name_symbol () const;
108 Global_context *get_global_context () const;
110 virtual Context *get_score_context () const;
111 virtual Output_def *get_output_def () const;
112 virtual Moment now_mom () const;
113 virtual Context *get_default_interpreter ();
115 bool is_alias (SCM) const;
116 void add_alias (SCM);
117 void add_context (Context *trans);
118 bool is_bottom_context () const;
119 bool is_removable () const;
121 Context *find_create_context (SCM context_name,
123 Context *create_unique_context (SCM context_name, string context_id,
125 vector<Context*> path_to_acceptable_context (SCM alias,
133 void apply_property_operations (Context *tg, SCM pre_init_ops);
134 void execute_pushpop_property (Context *trg, SCM prop, SCM eltprop, SCM val);
135 void execute_general_pushpop_property (Context *context,
136 SCM context_property, SCM grob_property_path, SCM val);
137 SCM updated_grob_properties (Context *tg, SCM sym);
138 Context *find_context_below (Context *where,
139 SCM type_sym, string id);
140 bool melisma_busy (Context *);
142 Context *get_voice_to_lyrics (Context *lyrics);
143 Grob *get_current_note_head (Context *voice);
144 Grob *get_current_rest (Context *voice);
145 DECLARE_UNSMOB (Context, context);
147 Moment measure_position (Context const *context);
148 Rational measure_length (Context const *context);
149 void set_context_property_on_children (Context *trans, SCM sym, SCM val);
151 /* Shorthand for creating and broadcasting stream events. */
152 #define send_stream_event(ctx, type, origin, ...) \
154 SCM props[] = { __VA_ARGS__, 0 }; \
155 ctx->internal_send_stream_event (ly_symbol2scm (type), origin, props); \
158 #endif /* CONTEXT_HH */