]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/context.hh
* lily/context.cc (Context): take key argument in ctor.
[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 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
18 class Context
19 {
20   Scheme_hash_table *properties_dict () const;
21   Context (Context const &src);
22   
23   DECLARE_SMOBS (Context, dummy);
24
25   void terminate ();
26
27 private:
28   friend class Interpretation_context_handle;
29   int iterator_count_;
30   bool init_;
31
32   std::map<String, int> grob_counts_;
33   std::map<String, int> context_counts_;
34
35 protected:
36   Object_key const * key_;
37   Context * daddy_context_;
38   SCM definition_;
39   SCM properties_scm_;
40   SCM context_list_;
41   SCM accepts_list_;
42   SCM aliases_;
43   SCM implementation_;
44   String id_string_;
45
46   friend class Context_def;
47   void clear_key_disambiguations ();
48
49 public:
50   Object_key const *get_key () const;
51   Object_key const *get_grob_key (String);
52   Object_key const *get_context_key (String, String);
53
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   
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   Link_array<Context> path_to_acceptable_context (SCM alias,
92                                                   Output_def*) const;
93
94 };
95
96 /*
97   Context arg? 
98  */
99
100 void apply_property_operations (Context *tg, SCM pre_init_ops);
101 void execute_pushpop_property (Context *trg, SCM prop, SCM eltprop, SCM val);
102 SCM updated_grob_properties (Context *tg, SCM sym);
103 Context *find_context_below (Context *where,
104                               SCM type_sym, String id);
105 bool melisma_busy (Context *);
106
107 Context *get_voice_to_lyrics (Context *lyrics);
108 Grob *get_current_note_head (Context *voice);
109 Grob *get_current_rest (Context *voice);
110 DECLARE_UNSMOB(Context, context);
111
112 #endif /* CONTEXT_HH */
113