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