]> git.donarmstrong.com Git - lilypond.git/blob - lily/interpretation-context-handle.cc
3c1e38153ae250b76b472a20570f25e5b3d97a50
[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   if (report_to_)
35     down ();
36 }
37
38 void
39 Interpretation_context_handle::up (Translator_group*t)
40 {
41   report_to_ = t;
42   t->iterator_count_ ++;
43 }
44
45 void
46 Interpretation_context_handle::down ()
47 {
48   report_to_->iterator_count_ --;
49   report_to_ = 0;
50 }
51
52 bool
53 Interpretation_context_handle::try_music (Music *m)
54 {
55   return  report_to_->try_music (m);
56 }
57
58 void
59 Interpretation_context_handle::operator = (Interpretation_context_handle const &s)
60 {
61   set_translator (s.report_to_);
62 }
63
64 void
65 Interpretation_context_handle::set_translator (Translator_group*trans)
66 {
67   if (report_to_ ==trans)
68     return;
69   if (report_to_)
70     down ();
71   if (trans)
72     up (trans);
73 }
74
75 Translator_group*
76 Interpretation_context_handle::report_to ()const
77 {
78   return report_to_;
79 }
80
81