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