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 "duration.hh"
13 #include "lily-proto.hh"
14 #include "listener.hh"
16 #include "scm-hash.hh"
17 #include "std-vector.hh"
18 #include "virtual-methods.hh"
22 Scheme_hash_table
*properties_dict () const;
23 Context (Context
const &src
);
25 DECLARE_SMOBS (Context
);
26 DECLARE_CLASSNAME(Context
);
30 friend class Context_handle
;
33 /* Used internally by create_context */
34 Stream_event
*infant_event_
;
37 Context
*daddy_context_
;
38 /* The used Context_def */
40 /* Additions to the Context_def, given by \with */
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
);
64 DECLARE_LISTENER (set_property_from_event
);
65 DECLARE_LISTENER (unset_property_from_event
);
68 string
id_string () const { return id_string_
; }
69 SCM
children_contexts () const { return context_list_
; }
70 SCM
default_child_context_name () const;
72 Dispatcher
*event_source () const { return event_source_
; }
73 Dispatcher
*events_below () const { return events_below_
; }
74 void internal_send_stream_event (SCM type
, Input
*origin
, SCM props
[]);
76 SCM
get_definition () const { return definition_
; }
77 SCM
get_definition_mods () const { return definition_mods_
; }
79 Translator_group
*implementation () const { return implementation_
; }
80 Context
*get_parent_context () const;
84 SCM
internal_get_property (SCM name_sym
) const;
85 SCM
properties_as_alist () const;
86 Context
*where_defined (SCM name_sym
, SCM
*value
) const;
87 void unset_property (SCM var_sym
);
89 void instrumented_set_property (SCM
, SCM
, const char*, int, const char*);
90 void internal_set_property (SCM var_sym
, SCM value
);
92 Context
*create_context (Context_def
*, string
, SCM
);
93 DECLARE_LISTENER (create_context_from_event
);
94 DECLARE_LISTENER (acknowledge_infant
);
95 DECLARE_LISTENER (remove_context
);
96 DECLARE_LISTENER (change_parent
);
97 void disconnect_from_parent ();
98 void check_removal ();
99 string
context_name () const;
100 SCM
context_name_symbol () const;
101 Global_context
*get_global_context () const;
103 virtual Context
*get_score_context () const;
104 virtual Output_def
*get_output_def () const;
105 virtual Moment
now_mom () const;
106 virtual Context
*get_default_interpreter ();
108 bool is_alias (SCM
) const;
109 void add_alias (SCM
);
110 void add_context (Context
*trans
);
111 bool is_bottom_context () const;
112 bool is_removable () const;
114 Context
*find_create_context (SCM context_name
,
116 Context
*create_unique_context (SCM context_name
, string context_id
,
118 vector
<Context_def
*> path_to_acceptable_context (SCM alias
) const;
125 void apply_property_operations (Context
*tg
, SCM pre_init_ops
);
126 void execute_revert_property (Context
*context
,
127 SCM context_property
,
128 SCM grob_property_path
);
129 void execute_pushpop_property (Context
*trg
, SCM prop
, SCM eltprop
, SCM val
);
130 void sloppy_general_pushpop_property (Context
*context
,
131 SCM context_property
, SCM grob_property_path
, SCM val
);
132 SCM
updated_grob_properties (Context
*tg
, SCM sym
);
133 Context
*find_context_below (Context
*where
,
134 SCM type_sym
, string id
);
135 bool melisma_busy (Context
*);
137 Context
*get_voice_to_lyrics (Context
*lyrics
);
138 Grob
*get_current_note_head (Context
*voice
);
139 Grob
*get_current_rest (Context
*voice
);
140 DECLARE_UNSMOB (Context
, context
);
142 Moment
measure_position (Context
const *context
);
143 Moment
measure_position (Context
const *context
, Duration
const *dur
);
144 Rational
measure_length (Context
const *context
);
145 int measure_number (Context
const *context
);
146 void set_context_property_on_children (Context
*trans
, SCM sym
, SCM val
);
148 /* Shorthand for creating and broadcasting stream events. */
149 #define send_stream_event(ctx, type, origin, ...) \
151 SCM props[] = { __VA_ARGS__, 0 }; \
152 ctx->internal_send_stream_event (ly_symbol2scm (type), origin, props); \
155 SCM
nested_property_alist (SCM alist
, SCM prop_path
, SCM value
);
156 SCM
nested_property_revert_alist (SCM alist
, SCM prop_path
);
157 SCM
evict_from_alist (SCM
, SCM
, SCM
);
159 #endif /* CONTEXT_HH */