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, dummy);
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 void internal_set_property (SCM var_sym, SCM value);
91 Context *where_defined (SCM name_sym, SCM *value) const;
92 void unset_property (SCM var_sym);
94 Context *create_context (Context_def *, string, SCM);
95 DECLARE_LISTENER (create_context_from_event);
96 DECLARE_LISTENER (acknowledge_infant);
97 DECLARE_LISTENER (remove_context);
98 DECLARE_LISTENER (change_parent);
99 void disconnect_from_parent ();
100 void check_removal ();
101 string context_name () const;
102 SCM context_name_symbol () const;
103 Global_context *get_global_context () const;
105 virtual Context *get_score_context () const;
106 virtual Output_def *get_output_def () const;
107 virtual Moment now_mom () const;
108 virtual Context *get_default_interpreter ();
110 bool is_alias (SCM) const;
111 void add_alias (SCM);
112 void add_context (Context *trans);
113 bool is_bottom_context () const;
114 bool is_removable () const;
115 bool try_music (Music *);
117 Context *find_create_context (SCM context_name,
119 Context *create_unique_context (SCM context_name, string context_id,
121 vector<Context*> path_to_acceptable_context (SCM alias,
129 void apply_property_operations (Context *tg, SCM pre_init_ops);
130 void execute_pushpop_property (Context *trg, SCM prop, SCM eltprop, SCM val);
131 void execute_general_pushpop_property (Context *context,
132 SCM context_property, SCM grob_property_path, SCM val);
133 SCM updated_grob_properties (Context *tg, SCM sym);
134 Context *find_context_below (Context *where,
135 SCM type_sym, string id);
136 bool melisma_busy (Context *);
138 Context *get_voice_to_lyrics (Context *lyrics);
139 Grob *get_current_note_head (Context *voice);
140 Grob *get_current_rest (Context *voice);
141 DECLARE_UNSMOB (Context, context);
143 Moment measure_position (Context const *context);
144 Rational measure_length (Context const *context);
145 void set_context_property_on_children (Context *trans, SCM sym, SCM val);
147 /* Shorthand for creating and broadcasting stream events. */
148 #define send_stream_event(ctx, type, origin, ...) \
150 SCM props[] = { __VA_ARGS__, 0 }; \
151 ctx->internal_send_stream_event (ly_symbol2scm (type), origin, props); \
154 #endif /* CONTEXT_HH */