]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/context.hh
* make/lilypond.fedora.spec.in (Group): add lilypond-internals to
[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 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 *get_key () const;
53   Object_key const *get_grob_key (String);
54   Object_key const *get_context_key (String, String);
55
56   Context *create_context (Context_def *, String, SCM);
57   String id_string () const { return id_string_; }
58   SCM children_contexts () const { return context_list_; }
59   SCM default_child_context_name () const;
60
61   Translator_group *implementation () const { return implementation_; }
62   Context *get_parent_context () const;
63   Context (Object_key const *);
64
65   /* properties:  */
66   void execute_pushpop_property (SCM prop, SCM sym, SCM val);
67   SCM internal_get_property (SCM name_sym) const;
68   SCM properties_as_alist () const;
69   void internal_set_property (SCM var_sym, SCM value);
70   Context *where_defined (SCM name_sym, SCM *value) const;
71   void unset_property (SCM var_sym);
72
73   Context *remove_context (Context *trans);
74   void check_removal ();
75   String context_name () const;
76   SCM context_name_symbol () const;
77   Global_context *get_global_context () const;
78
79   virtual Score_context *get_score_context () const;
80   virtual Output_def *get_output_def () const;
81   virtual Moment now_mom () const;
82   virtual Context *get_default_interpreter ();
83
84   bool is_alias (SCM) const;
85   void add_alias (SCM);
86   void add_context (Context *trans);
87   bool is_bottom_context () const;
88   bool is_removable () const;
89   bool try_music (Music *);
90
91   Context *find_create_context (SCM context_name,
92                                 String id, SCM ops);
93   Context *create_unique_context (SCM context_name,
94                                   SCM ops);
95   Link_array<Context> path_to_acceptable_context (SCM alias,
96                                                   Output_def *) const;
97 };
98
99 /*
100   Context arg?
101 */
102
103 void apply_property_operations (Context *tg, SCM pre_init_ops);
104 void execute_pushpop_property (Context *trg, SCM prop, SCM eltprop, SCM val);
105 SCM updated_grob_properties (Context *tg, SCM sym);
106 Context *find_context_below (Context *where,
107                              SCM type_sym, String id);
108 bool melisma_busy (Context *);
109
110 Context *get_voice_to_lyrics (Context *lyrics);
111 Grob *get_current_note_head (Context *voice);
112 Grob *get_current_rest (Context *voice);
113 DECLARE_UNSMOB (Context, context);
114
115 Moment measure_position (Context const *context);
116 Rational measure_length (Context const *context);
117
118 #endif /* CONTEXT_HH */
119