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 "listener.hh"
15 #include "std-vector.hh"
16 #include "virtual-methods.hh"
20 Scheme_hash_table *properties_dict () const;
21 Context (Context const &src);
23 DECLARE_SMOBS (Context);
24 DECLARE_CLASSNAME(Context);
28 friend class Context_handle;
31 /* Used internally by create_context */
32 Stream_event *infant_event_;
35 Context *daddy_context_;
36 /* The used Context_def */
38 /* Additions to the Context_def, given by \with */
40 Context_key_manager key_manager_;
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);
62 void clear_key_disambiguations ();
64 DECLARE_LISTENER (set_property_from_event);
65 DECLARE_LISTENER (unset_property_from_event);
68 Object_key const *get_grob_key (string name);
69 Object_key const *get_context_key (string name, string id);
71 string id_string () const { return id_string_; }
72 SCM children_contexts () const { return context_list_; }
73 SCM default_child_context_name () const;
75 Dispatcher *event_source () const { return event_source_; }
76 Dispatcher *events_below () const { return events_below_; }
77 void internal_send_stream_event (SCM type, Input *origin, SCM props[]);
79 SCM get_definition () const { return definition_; }
80 SCM get_definition_mods () const { return definition_mods_; }
82 Translator_group *implementation () const { return implementation_; }
83 Context *get_parent_context () const;
84 Context (Object_key const *);
87 SCM internal_get_property (SCM name_sym) const;
88 SCM properties_as_alist () const;
89 Context *where_defined (SCM name_sym, SCM *value) const;
90 void unset_property (SCM var_sym);
93 void internal_set_property (SCM var_sym, SCM value, char const *file, int line, char const *fun);
95 void internal_set_property (SCM var_sym, SCM value);
98 Context *create_context (Context_def *, string, SCM);
99 DECLARE_LISTENER (create_context_from_event);
100 DECLARE_LISTENER (acknowledge_infant);
101 DECLARE_LISTENER (remove_context);
102 DECLARE_LISTENER (change_parent);
103 void disconnect_from_parent ();
104 void check_removal ();
105 string context_name () const;
106 SCM context_name_symbol () const;
107 Global_context *get_global_context () const;
109 virtual Context *get_score_context () const;
110 virtual Output_def *get_output_def () const;
111 virtual Moment now_mom () const;
112 virtual Context *get_default_interpreter ();
114 bool is_alias (SCM) const;
115 void add_alias (SCM);
116 void add_context (Context *trans);
117 bool is_bottom_context () const;
118 bool is_removable () const;
120 Context *find_create_context (SCM context_name,
122 Context *create_unique_context (SCM context_name, string context_id,
124 vector<Context*> path_to_acceptable_context (SCM alias,
132 void apply_property_operations (Context *tg, SCM pre_init_ops);
133 void execute_pushpop_property (Context *trg, SCM prop, SCM eltprop, SCM val);
134 void execute_general_pushpop_property (Context *context,
135 SCM context_property, SCM grob_property_path, SCM val);
136 SCM updated_grob_properties (Context *tg, SCM sym);
137 Context *find_context_below (Context *where,
138 SCM type_sym, string id);
139 bool melisma_busy (Context *);
141 Context *get_voice_to_lyrics (Context *lyrics);
142 Grob *get_current_note_head (Context *voice);
143 Grob *get_current_rest (Context *voice);
144 DECLARE_UNSMOB (Context, context);
146 Moment measure_position (Context const *context);
147 Rational measure_length (Context const *context);
148 void set_context_property_on_children (Context *trans, SCM sym, SCM val);
150 /* Shorthand for creating and broadcasting stream events. */
151 #define send_stream_event(ctx, type, origin, ...) \
153 SCM props[] = { __VA_ARGS__, 0 }; \
154 ctx->internal_send_stream_event (ly_symbol2scm (type), origin, props); \
157 #endif /* CONTEXT_HH */