]> git.donarmstrong.com Git - lilypond.git/blob - lily/interpretation-context-handle.cc
2003 -> 2004
[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--2004 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   outlet_ =0;
15 }
16
17 Interpretation_context_handle::Interpretation_context_handle (Interpretation_context_handle const&s)
18 {
19   outlet_ =0;
20   if (s.outlet_)
21     up (s.outlet_);
22 }
23
24 Interpretation_context_handle*
25 Interpretation_context_handle::clone () const
26 {
27   Interpretation_context_handle* handle = new Interpretation_context_handle;
28   handle->outlet_ = this->outlet_;
29   return handle;
30 }
31
32 Interpretation_context_handle::~Interpretation_context_handle ()
33 {
34   /*
35     Don't do
36
37     if (outlet_)
38       down ();
39
40     with GC, this is asynchronous.
41    */
42 }
43
44 void
45 Interpretation_context_handle::up (Translator_group*t)
46 {
47   outlet_ = t;
48   t->iterator_count_ ++;
49 }
50
51 void
52 Interpretation_context_handle::down ()
53 {
54   outlet_->iterator_count_ --;
55   outlet_ = 0;
56 }
57
58 void
59 Interpretation_context_handle::quit ()
60 {
61   if (outlet_)
62     {
63       outlet_->iterator_count_ --;
64       outlet_ = 0;
65     }
66 }
67
68 bool
69 Interpretation_context_handle::try_music (Music *m)
70 {
71   return outlet_->try_music (m);
72 }
73
74 void
75 Interpretation_context_handle::operator = (Interpretation_context_handle const &s)
76 {
77   set_translator (s.outlet_);
78 }
79
80 void
81 Interpretation_context_handle::set_translator (Translator_group*trans)
82 {
83   if (outlet_ ==trans)
84     return;
85   if (outlet_)
86     down ();
87   if (trans)
88     up (trans);
89 }
90
91 Translator_group*
92 Interpretation_context_handle::get_outlet () const
93 {
94   
95   return outlet_;
96 }
97
98 int
99 Interpretation_context_handle::get_count () const
100 {
101   return outlet_->iterator_count_ ;
102 }