]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/context.hh
Added data structures for music streams.
[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   int unique_;
35   Context *daddy_context_;
36   SCM definition_;
37   Context_key_manager key_manager_;
38   
39   SCM properties_scm_;
40   SCM context_list_;
41   SCM accepts_list_;
42   SCM aliases_;
43   Translator_group *implementation_;
44   string id_string_;
45
46   friend class Context_def;
47   void clear_key_disambiguations ();
48
49   
50 public:
51   Object_key const *get_grob_key (string name);
52   Object_key const *get_context_key (string name, string id);
53
54   Context *create_context (Context_def *, string, SCM);
55   string id_string () const { return id_string_; }
56   SCM children_contexts () const { return context_list_; }
57   SCM default_child_context_name () const;
58   int get_unique() { return unique_; }
59
60   Translator_group *implementation () const { return implementation_; }
61   Context *get_parent_context () const;
62   Context (Object_key const *);
63
64   /* properties:  */
65   SCM internal_get_property (SCM name_sym) const;
66   SCM properties_as_alist () const;
67   void internal_set_property (SCM var_sym, SCM value);
68   Context *where_defined (SCM name_sym, SCM *value) const;
69   void unset_property (SCM var_sym);
70
71   Context *remove_context (Context *trans);
72   void check_removal ();
73   string context_name () const;
74   SCM context_name_symbol () const;
75   Global_context *get_global_context () const;
76
77   virtual Score_context *get_score_context () const;
78   virtual Output_def *get_output_def () const;
79   virtual Moment now_mom () const;
80   virtual Context *get_default_interpreter ();
81
82   bool is_alias (SCM) const;
83   void add_alias (SCM);
84   void add_context (Context *trans);
85   bool is_bottom_context () const;
86   bool is_removable () const;
87   bool try_music (Music *);
88
89   Context *find_create_context (SCM context_name,
90                                 string id, SCM ops);
91   Context *create_unique_context (SCM context_name, string context_id,
92                                   SCM ops);
93   vector<Context*> path_to_acceptable_context (SCM alias,
94                                                   Output_def *) const;
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 void execute_general_pushpop_property (Context *context,
104                                        SCM context_property, SCM grob_property_path, 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 void set_context_property_on_children (Context *trans, SCM sym, SCM val);
118
119 #endif /* CONTEXT_HH */
120