]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/context.hh
* scm/layout-page-layout.scm (write-page-breaks): record tweaks
[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 #include <map>
13 using namespace std;
14
15 #include "moment.hh"
16 #include "lily-proto.hh"
17 #include "virtual-methods.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   map<String, int> grob_counts_;
34   map<String, int> context_counts_;
35
36 protected:
37   Object_key const *key_;
38   Context *daddy_context_;
39   SCM definition_;
40
41   SCM properties_scm_;
42   SCM context_list_;
43   SCM accepts_list_;
44   SCM aliases_;
45   Translator_group *implementation_;
46   String id_string_;
47
48   friend class Context_def;
49   void clear_key_disambiguations ();
50
51 public:
52   Object_key const *key () const { return key_; }
53
54   Object_key const *create_grob_key (String);
55   Object_key const *get_grob_key (String);
56   Object_key const *get_context_key (String, String);
57
58   Context *create_context (Context_def *, String, SCM);
59   String id_string () const { return id_string_; }
60   SCM children_contexts () const { return context_list_; }
61   SCM default_child_context_name () const;
62
63   Translator_group *implementation () const { return implementation_; }
64   Context *get_parent_context () const;
65   Context (Object_key const *);
66
67   /* properties:  */
68   SCM internal_get_property (SCM name_sym) const;
69   SCM properties_as_alist () const;
70   void internal_set_property (SCM var_sym, SCM value);
71   Context *where_defined (SCM name_sym, SCM *value) const;
72   void unset_property (SCM var_sym);
73
74   Context *remove_context (Context *trans);
75   void check_removal ();
76   String context_name () const;
77   SCM context_name_symbol () const;
78   Global_context *get_global_context () const;
79
80   virtual Score_context *get_score_context () const;
81   virtual Output_def *get_output_def () const;
82   virtual Moment now_mom () const;
83   virtual Context *get_default_interpreter ();
84
85   bool is_alias (SCM) const;
86   void add_alias (SCM);
87   void add_context (Context *trans);
88   bool is_bottom_context () const;
89   bool is_removable () const;
90   bool try_music (Music *);
91
92   Context *find_create_context (SCM context_name,
93                                 String id, SCM ops);
94   Context *create_unique_context (SCM context_name,
95                                   SCM ops);
96   Link_array<Context> path_to_acceptable_context (SCM alias,
97                                                   Output_def *) const;
98 };
99
100 /*
101   Context arg?
102 */
103
104 void apply_property_operations (Context *tg, SCM pre_init_ops);
105 void execute_pushpop_property (Context *trg, SCM prop, SCM eltprop, SCM val);
106 void execute_general_pushpop_property (Context *context,
107                                        SCM context_property, SCM grob_property_path, SCM val);
108 SCM updated_grob_properties (Context *tg, SCM sym);
109 Context *find_context_below (Context *where,
110                              SCM type_sym, String id);
111 bool melisma_busy (Context *);
112
113 Context *get_voice_to_lyrics (Context *lyrics);
114 Grob *get_current_note_head (Context *voice);
115 Grob *get_current_rest (Context *voice);
116 DECLARE_UNSMOB (Context, context);
117
118 Moment measure_position (Context const *context);
119 Rational measure_length (Context const *context);
120 void set_context_property_on_children (Context *trans, SCM sym, SCM val);
121
122 #endif /* CONTEXT_HH */
123