]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/context.hh
* flower
[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--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #ifndef CONTEXT_HH
10 #define CONTEXT_HH
11
12 #include <map>
13
14 #include "moment.hh"
15 #include "lily-proto.hh"
16
17 class Context
18 {
19   Scheme_hash_table *properties_dict () const;
20   Context (Context const &src);
21
22   DECLARE_SMOBS (Context, dummy);
23
24   void terminate ();
25
26 private:
27   friend class Interpretation_context_handle;
28   int iterator_count_;
29   bool init_;
30
31   std::map < String, int> grob_counts_;
32   std::map < String, int> context_counts_;
33
34 protected:
35   Object_key const *key_;
36   Context *daddy_context_;
37   SCM definition_;
38   SCM properties_scm_;
39   SCM context_list_;
40   SCM accepts_list_;
41   SCM aliases_;
42   SCM implementation_;
43   String id_string_;
44
45   friend class Context_def;
46   void clear_key_disambiguations ();
47
48 public:
49   Object_key const *get_key () const;
50   Object_key const *get_grob_key (String);
51   Object_key const *get_context_key (String, String);
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;
59   Context *get_parent_context () const;
60   Context (Object_key const *);
61
62   /* properties:  */
63   void execute_pushpop_property (SCM prop, SCM sym, SCM val);
64   SCM internal_get_property (SCM name_sym) const;
65   SCM properties_as_alist () const;
66   void internal_set_property (SCM var_sym, SCM value);
67   Context *where_defined (SCM name_sym) const;
68   void unset_property (SCM var_sym);
69
70   Context *remove_context (Context *trans);
71   void check_removal ();
72   String context_name () const;
73   SCM context_name_symbol () const;
74   Global_context *get_global_context () const;
75
76   virtual Score_context *get_score_context () const;
77   virtual Output_def *get_output_def () const;
78   virtual Moment now_mom () const;
79   virtual Context *get_default_interpreter ();
80
81   bool is_alias (SCM) const;
82   void add_alias (SCM);
83   void add_context (Context *trans);
84   bool is_bottom_context () const;
85   bool is_removable () const;
86   bool try_music (Music *);
87
88   Context *find_create_context (SCM context_name,
89                                 String id, SCM ops);
90   Context *create_unique_context (SCM context_name,
91                                   SCM ops);
92   Link_array<Context> path_to_acceptable_context (SCM alias,
93                                                   Output_def *) const;
94
95 };
96
97 /*
98   Context arg?
99 */
100
101 void apply_property_operations (Context *tg, SCM pre_init_ops);
102 void execute_pushpop_property (Context *trg, SCM prop, SCM eltprop, 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 #endif /* CONTEXT_HH */
114