]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/context.hh
* lily/include/midi-item.hh (class Midi_track): idem.
[lilypond.git] / lily / include / context.hh
1 /*
2   context.hh -- declare  Context
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2004--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #ifndef CONTEXT_HH
10 #define CONTEXT_HH
11
12
13 #include "std-vector.hh"
14 #include "moment.hh"
15 #include "lily-proto.hh"
16 #include "virtual-methods.hh"
17 #include "context-key-manager.hh"
18
19 class Context
20 {
21   Scheme_hash_table *properties_dict () const;
22   Context (Context const &src);
23
24   DECLARE_SMOBS (Context, dummy);
25   DECLARE_CLASSNAME(Context);
26   void terminate ();
27
28 private:
29   friend class Context_handle;
30   int iterator_count_;
31   bool init_;
32
33 protected:
34   Context *daddy_context_;
35   SCM definition_;
36   Context_key_manager key_manager_;
37   
38   SCM properties_scm_;
39   SCM context_list_;
40   SCM accepts_list_;
41   SCM aliases_;
42   Translator_group *implementation_;
43   string id_string_;
44
45   friend class Context_def;
46   void clear_key_disambiguations ();
47
48   
49 public:
50   Object_key const *get_grob_key (string name);
51   Object_key const *get_context_key (string name, string id);
52
53   Context *create_context (Context_def *, string, SCM);
54   string id_string () const { return id_string_; }
55   SCM children_contexts () const { return context_list_; }
56   SCM default_child_context_name () const;
57
58   Translator_group *implementation () const { return implementation_; }
59   Context *get_parent_context () const;
60   Context (Object_key const *);
61
62   /* properties:  */
63   SCM internal_get_property (SCM name_sym) const;
64   SCM properties_as_alist () const;
65   void internal_set_property (SCM var_sym, SCM value);
66   Context *where_defined (SCM name_sym, SCM *value) const;
67   void unset_property (SCM var_sym);
68
69   Context *remove_context (Context *trans);
70   void check_removal ();
71   string context_name () const;
72   SCM context_name_symbol () const;
73   Global_context *get_global_context () const;
74
75   virtual Score_context *get_score_context () const;
76   virtual Output_def *get_output_def () const;
77   virtual Moment now_mom () const;
78   virtual Context *get_default_interpreter ();
79
80   bool is_alias (SCM) const;
81   void add_alias (SCM);
82   void add_context (Context *trans);
83   bool is_bottom_context () const;
84   bool is_removable () const;
85   bool try_music (Music *);
86
87   Context *find_create_context (SCM context_name,
88                                 string id, SCM ops);
89   Context *create_unique_context (SCM context_name, string context_id,
90                                   SCM ops);
91   vector<Context*> path_to_acceptable_context (SCM alias,
92                                                   Output_def *) const;
93 };
94
95 /*
96   Context arg?
97 */
98
99 void apply_property_operations (Context *tg, SCM pre_init_ops);
100 void execute_pushpop_property (Context *trg, SCM prop, SCM eltprop, SCM val);
101 void execute_general_pushpop_property (Context *context,
102                                        SCM context_property, SCM grob_property_path, SCM val);
103 SCM updated_grob_properties (Context *tg, SCM sym);
104 Context *find_context_below (Context *where,
105                              SCM type_sym, string id);
106 bool melisma_busy (Context *);
107
108 Context *get_voice_to_lyrics (Context *lyrics);
109 Grob *get_current_note_head (Context *voice);
110 Grob *get_current_rest (Context *voice);
111 DECLARE_UNSMOB (Context, context);
112
113 Moment measure_position (Context const *context);
114 Rational measure_length (Context const *context);
115 void set_context_property_on_children (Context *trans, SCM sym, SCM val);
116
117 #endif /* CONTEXT_HH */
118