#ifndef CONTEXT_HH
#define CONTEXT_HH
-#include <map>
-using namespace std;
+#include "std-vector.hh"
#include "moment.hh"
#include "lily-proto.hh"
#include "virtual-methods.hh"
+#include "context-key-manager.hh"
class Context
{
int iterator_count_;
bool init_;
- map<string, int> grob_counts_;
- map<string, int> context_counts_;
-
protected:
- Object_key const *key_;
+ int unique_;
Context *daddy_context_;
+ /* The used Context_def */
SCM definition_;
-
+ /* Additions to the Context_def, given by \with */
+ SCM definition_mods_;
+ Context_key_manager key_manager_;
+
SCM properties_scm_;
SCM context_list_;
SCM accepts_list_;
SCM aliases_;
Translator_group *implementation_;
string id_string_;
+
+ /* Events reported in the context is sent to this dispatcher. */
+ Dispatcher *event_source_;
+
+ /* Events reported to this context or recursively in any of its
+ children, are sent to this dispatcher. */
+ Dispatcher *events_below_;
friend class Context_def;
void clear_key_disambiguations ();
+
public:
- Object_key const *key () const { return key_; }
- Object_key const *create_grob_key (string);
- Object_key const *get_grob_key (string);
- Object_key const *get_context_key (string, string);
+ Object_key const *get_grob_key (string name);
+ Object_key const *get_context_key (string name, string id);
Context *create_context (Context_def *, string, SCM);
string id_string () const { return id_string_; }
SCM children_contexts () const { return context_list_; }
SCM default_child_context_name () const;
+ int get_unique() { return unique_; }
+
+ Dispatcher *event_source () const { return event_source_; }
+ Dispatcher *events_below () const { return events_below_; }
+ void internal_send_stream_event (SCM type, SCM props[]);
+
+ SCM get_definition () const { return definition_; }
+ SCM get_definition_mods () const { return definition_mods_; }
Translator_group *implementation () const { return implementation_; }
Context *get_parent_context () const;
Context *find_create_context (SCM context_name,
string id, SCM ops);
- Context *create_unique_context (SCM context_name,
+ Context *create_unique_context (SCM context_name, string context_id,
SCM ops);
vector<Context*> path_to_acceptable_context (SCM alias,
Output_def *) const;
Rational measure_length (Context const *context);
void set_context_property_on_children (Context *trans, SCM sym, SCM val);
+/* Shorthand for creating and broadcasting stream events. */
+#define send_stream_event(ctx, type, ...) \
+{ \
+ SCM props[] = { __VA_ARGS__, 0 }; \
+ ctx->internal_send_stream_event (ly_symbol2scm (type), props); \
+}
+
#endif /* CONTEXT_HH */