]> git.donarmstrong.com Git - lilypond.git/blob - lily/context-handle.cc
*** empty log message ***
[lilypond.git] / lily / 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--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7  */
8
9 #include "interpretation-context-handle.hh"
10 #include "context.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
25 Interpretation_context_handle::~Interpretation_context_handle ()
26 {
27   /*
28     Don't do
29
30     if (outlet_)
31       down ();
32
33     with GC, this is asynchronous.
34    */
35 }
36
37 void
38 Interpretation_context_handle::up (Context *t)
39 {
40   outlet_ = t;
41   t->iterator_count_ ++;
42 }
43
44 void
45 Interpretation_context_handle::down ()
46 {
47   outlet_->iterator_count_ --;
48   outlet_ = 0;
49 }
50
51 void
52 Interpretation_context_handle::quit ()
53 {
54   if (outlet_)
55     {
56       outlet_->iterator_count_ --;
57       outlet_ = 0;
58     }
59 }
60
61 bool
62 Interpretation_context_handle::try_music (Music *m)
63 {
64   return outlet_->try_music (m);
65 }
66
67 void
68 Interpretation_context_handle::operator = (Interpretation_context_handle const &s)
69 {
70   set_context (s.outlet_);
71 }
72
73 void
74 Interpretation_context_handle::set_context (Context *trans)
75 {
76   if (outlet_ == trans)
77     return;
78   if (outlet_)
79     down ();
80   if (trans)
81     up (trans);
82 }
83
84 Context *
85 Interpretation_context_handle::get_outlet () const
86 {
87   
88   return outlet_;
89 }
90
91 int
92 Interpretation_context_handle::get_count () const
93 {
94   return outlet_->iterator_count_ ;
95 }