2 context.hh -- declare Context
4 source file of the GNU LilyPond music typesetter
6 (c) 2004--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
12 #include "listener.hh"
14 #include "std-vector.hh"
15 #include "virtual-methods.hh"
16 #include "scm-hash.hh"
17 #include "lily-proto.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 */
46 Translator_group *implementation_;
49 /* Events reported in the context is sent to this dispatcher. */
50 Dispatcher *event_source_;
52 /* Events reported to this context or recursively in any of its
53 children, are sent to this dispatcher. */
54 Dispatcher *events_below_;
56 // Translator_group is allowed to set implementation_.
57 friend class Translator_group;
58 // Context_def::instantiate initialises some protected members.
59 friend class Context_def;
60 // UGH! initialises implementation_
61 friend SCM ly_make_global_translator (SCM);
63 DECLARE_LISTENER (set_property_from_event);
64 DECLARE_LISTENER (unset_property_from_event);
67 string id_string () const { return id_string_; }
68 SCM children_contexts () const { return context_list_; }
69 SCM default_child_context_name () const;
71 Dispatcher *event_source () const { return event_source_; }
72 Dispatcher *events_below () const { return events_below_; }
73 void internal_send_stream_event (SCM type, Input *origin, SCM props[]);
75 SCM get_definition () const { return definition_; }
76 SCM get_definition_mods () const { return definition_mods_; }
78 Translator_group *implementation () const { return implementation_; }
79 Context *get_parent_context () const;
83 SCM internal_get_property (SCM name_sym) const;
84 SCM properties_as_alist () const;
85 Context *where_defined (SCM name_sym, SCM *value) const;
86 void unset_property (SCM var_sym);
88 void instrumented_set_property (SCM, SCM, const char*, int, const char*);
89 void internal_set_property (SCM var_sym, SCM value);
91 Context *create_context (Context_def *, string, SCM);
92 DECLARE_LISTENER (create_context_from_event);
93 DECLARE_LISTENER (acknowledge_infant);
94 DECLARE_LISTENER (remove_context);
95 DECLARE_LISTENER (change_parent);
96 void disconnect_from_parent ();
97 void check_removal ();
98 string context_name () const;
99 SCM context_name_symbol () const;
100 Global_context *get_global_context () const;
102 virtual Context *get_score_context () const;
103 virtual Output_def *get_output_def () const;
104 virtual Moment now_mom () const;
105 virtual Context *get_default_interpreter ();
107 bool is_alias (SCM) const;
108 void add_alias (SCM);
109 void add_context (Context *trans);
110 bool is_bottom_context () const;
111 bool is_removable () const;
113 Context *find_create_context (SCM context_name,
115 Context *create_unique_context (SCM context_name, string context_id,
117 vector<Context_def*> path_to_acceptable_context (SCM alias) const;
124 void apply_property_operations (Context *tg, SCM pre_init_ops);
125 void execute_pushpop_property (Context *trg, SCM prop, SCM eltprop, SCM val);
126 void execute_general_pushpop_property (Context *context,
127 SCM context_property, SCM grob_property_path, SCM val);
128 SCM updated_grob_properties (Context *tg, SCM sym);
129 Context *find_context_below (Context *where,
130 SCM type_sym, string id);
131 bool melisma_busy (Context *);
133 Context *get_voice_to_lyrics (Context *lyrics);
134 Grob *get_current_note_head (Context *voice);
135 Grob *get_current_rest (Context *voice);
136 DECLARE_UNSMOB (Context, context);
138 Moment measure_position (Context const *context);
139 Rational measure_length (Context const *context);
140 void set_context_property_on_children (Context *trans, SCM sym, SCM val);
142 /* Shorthand for creating and broadcasting stream events. */
143 #define send_stream_event(ctx, type, origin, ...) \
145 SCM props[] = { __VA_ARGS__, 0 }; \
146 ctx->internal_send_stream_event (ly_symbol2scm (type), origin, props); \
149 SCM nested_property_alist (SCM alist, SCM prop_path, SCM value);
150 SCM nested_property_revert_alist (SCM alist, SCM prop_path);
151 SCM evict_from_alist (SCM, SCM, SCM);
153 #endif /* CONTEXT_HH */