2 context.hh -- declare Context
4 source file of the GNU LilyPond music typesetter
6 (c) 2004--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
13 #include "std-vector.hh"
15 #include "lily-proto.hh"
16 #include "virtual-methods.hh"
17 #include "context-key-manager.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;
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 friend class Context_def;
57 void clear_key_disambiguations ();
61 Object_key const *get_grob_key (string name);
62 Object_key const *get_context_key (string name, string id);
64 Context *create_context (Context_def *, string, SCM);
65 string id_string () const { return id_string_; }
66 SCM children_contexts () const { return context_list_; }
67 SCM default_child_context_name () const;
68 int get_unique() { return unique_; }
70 Dispatcher *event_source () const { return event_source_; }
71 Dispatcher *events_below () const { return events_below_; }
72 void internal_send_stream_event (SCM type, SCM props[]);
74 SCM get_definition () const { return definition_; }
75 SCM get_definition_mods () const { return definition_mods_; }
77 Translator_group *implementation () const { return implementation_; }
78 Context *get_parent_context () const;
79 Context (Object_key const *);
82 SCM internal_get_property (SCM name_sym) const;
83 SCM properties_as_alist () const;
84 void internal_set_property (SCM var_sym, SCM value);
85 Context *where_defined (SCM name_sym, SCM *value) const;
86 void unset_property (SCM var_sym);
88 Context *remove_context (Context *trans);
89 void check_removal ();
90 string context_name () const;
91 SCM context_name_symbol () const;
92 Global_context *get_global_context () const;
94 virtual Score_context *get_score_context () const;
95 virtual Output_def *get_output_def () const;
96 virtual Moment now_mom () const;
97 virtual Context *get_default_interpreter ();
99 bool is_alias (SCM) const;
100 void add_alias (SCM);
101 void add_context (Context *trans);
102 bool is_bottom_context () const;
103 bool is_removable () const;
104 bool try_music (Music *);
106 Context *find_create_context (SCM context_name,
108 Context *create_unique_context (SCM context_name, string context_id,
110 vector<Context*> path_to_acceptable_context (SCM alias,
118 void apply_property_operations (Context *tg, SCM pre_init_ops);
119 void execute_pushpop_property (Context *trg, SCM prop, SCM eltprop, SCM val);
120 void execute_general_pushpop_property (Context *context,
121 SCM context_property, SCM grob_property_path, SCM val);
122 SCM updated_grob_properties (Context *tg, SCM sym);
123 Context *find_context_below (Context *where,
124 SCM type_sym, string id);
125 bool melisma_busy (Context *);
127 Context *get_voice_to_lyrics (Context *lyrics);
128 Grob *get_current_note_head (Context *voice);
129 Grob *get_current_rest (Context *voice);
130 DECLARE_UNSMOB (Context, context);
132 Moment measure_position (Context const *context);
133 Rational measure_length (Context const *context);
134 void set_context_property_on_children (Context *trans, SCM sym, SCM val);
136 /* Shorthand for creating and broadcasting stream events. */
137 #define send_stream_event(ctx, type, ...) \
139 SCM props[] = { __VA_ARGS__, 0 }; \
140 ctx->internal_send_stream_event (ly_symbol2scm (type), props); \
143 #endif /* CONTEXT_HH */