]> git.donarmstrong.com Git - lilypond.git/blob - lily/interpretation-context-handle.cc
* VERSION (MY_PATCH_LEVEL): make 1.7.0
[lilypond.git] / lily / interpretation-context-handle.cc
1 /*   
2   interpretation-context-handle.cc --  implement Interpretation_context_handle
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 1999--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7  */
8
9 #include "interpretation-context-handle.hh"
10 #include "translator-group.hh"
11
12 Interpretation_context_handle::Interpretation_context_handle ()
13 {
14   report_to_ =0;
15 }
16
17 Interpretation_context_handle::Interpretation_context_handle (Interpretation_context_handle const&s)
18 {
19   report_to_ =0;
20   if (s.report_to_)
21     up (s.report_to_);
22 }
23
24 Interpretation_context_handle*
25 Interpretation_context_handle::clone () const
26 {
27   Interpretation_context_handle* handle = new Interpretation_context_handle;
28   handle->report_to_ = this->report_to_;
29   return handle;
30 }
31
32 Interpretation_context_handle::~Interpretation_context_handle ()
33 {
34   /*
35     Don't do
36
37     if (report_to_)
38       down ();
39
40     with GC, this is asynchronous.
41    */
42 }
43
44 void
45 Interpretation_context_handle::up (Translator_group*t)
46 {
47   report_to_ = t;
48   t->iterator_count_ ++;
49 }
50
51 void
52 Interpretation_context_handle::down ()
53 {
54   report_to_->iterator_count_ --;
55   report_to_ = 0;
56 }
57
58 void
59 Interpretation_context_handle::quit ()
60 {
61   if (report_to_)
62     {
63       report_to_->iterator_count_ --;
64       report_to_ = 0;
65     }
66 }
67
68 bool
69 Interpretation_context_handle::try_music (Music *m)
70 {
71   return report_to_->try_music (m);
72 }
73
74 void
75 Interpretation_context_handle::operator = (Interpretation_context_handle const &s)
76 {
77   set_translator (s.report_to_);
78 }
79
80 void
81 Interpretation_context_handle::set_translator (Translator_group*trans)
82 {
83   if (report_to_ ==trans)
84     return;
85   if (report_to_)
86     down ();
87   if (trans)
88     up (trans);
89 }
90
91 Translator_group*
92 Interpretation_context_handle::report_to ()const
93 {
94   
95   return report_to_;
96 }
97
98