]> git.donarmstrong.com Git - lilypond.git/blob - lily/context-handle.cc
Run `make grand-replace'.
[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--2008 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 void
51 Context_handle::operator = (Context_handle const &s)
52 {
53   set_context (s.outlet_);
54 }
55
56 void
57 Context_handle::set_context (Context *trans)
58 {
59   if (outlet_ == trans)
60     return;
61   if (outlet_)
62     down ();
63   if (trans)
64     up (trans);
65 }
66
67 Context *
68 Context_handle::get_outlet () const
69 {
70
71   return outlet_;
72 }
73
74 int
75 Context_handle::get_count () const
76 {
77   return outlet_->iterator_count_;
78 }