]> git.donarmstrong.com Git - lilypond.git/blob - lily/context-handle.cc
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / lily / context-handle.cc
1 /*
2   context-handle.cc -- implement Context_handle
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1999--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "context-handle.hh"
10 #include "context.hh"
11
12 Context_handle::Context_handle ()
13 {
14   outlet_ = 0;
15 }
16
17 Context_handle::Context_handle (Context_handle const &s)
18 {
19   outlet_ = 0;
20   if (s.outlet_)
21     up (s.outlet_);
22 }
23
24 Context_handle::~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 Context_handle::up (Context *t)
38 {
39   outlet_ = t;
40   t->iterator_count_++;
41 }
42
43 void
44 Context_handle::down ()
45 {
46   outlet_->iterator_count_--;
47   outlet_ = 0;
48 }
49
50 bool
51 Context_handle::try_music (Music *m)
52 {
53   return outlet_->try_music (m);
54 }
55
56 void
57 Context_handle::operator = (Context_handle const &s)
58 {
59   set_context (s.outlet_);
60 }
61
62 void
63 Context_handle::set_context (Context *trans)
64 {
65   if (outlet_ == trans)
66     return;
67   if (outlet_)
68     down ();
69   if (trans)
70     up (trans);
71 }
72
73 Context *
74 Context_handle::get_outlet () const
75 {
76
77   return outlet_;
78 }
79
80 int
81 Context_handle::get_count () const
82 {
83   return outlet_->iterator_count_;
84 }