]> git.donarmstrong.com Git - lilypond.git/blob - lily/grob-info.cc
Issue 4550 (1/2) Avoid "using namespace std;" in included files
[lilypond.git] / lily / grob-info.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1997--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "context.hh"
21 #include "grob-info.hh"
22 #include "item.hh"
23 #include "music.hh"
24 #include "spanner.hh"
25 #include "stream-event.hh"
26 #include "translator-group.hh"
27
28 using std::vector;
29
30 Grob_info::Grob_info (Translator *t, Grob *g)
31 {
32   origin_trans_ = t;
33   grob_ = g;
34   start_end_ = START;
35   rerouting_daddy_context_ = 0;
36
37   /*
38     assert here, because this is easier to debug.
39   */
40   assert (g);
41 }
42
43 Grob_info::Grob_info ()
44 {
45   grob_ = 0;
46   start_end_ = START;
47   origin_trans_ = 0;
48   rerouting_daddy_context_ = 0;
49 }
50
51 Stream_event *
52 Grob_info::event_cause () const
53 {
54   SCM cause = grob_->get_property ("cause");
55   return unsmob<Stream_event> (cause);
56 }
57
58 vector<Context *>
59 Grob_info::origin_contexts (Translator *end) const
60 {
61   Context *t = origin_trans_->context ();
62   vector<Context *> r;
63   do
64     {
65       r.push_back (t);
66       t = t->get_parent_context ();
67     }
68   while (t && t != end->context ());
69
70   return r;
71 }
72
73 Context *
74 Grob_info::context () const
75 {
76   return origin_trans_->context ();
77 }
78
79 Spanner *
80 Grob_info::spanner () const
81 {
82   return dynamic_cast<Spanner *> (grob_);
83 }
84
85 Item *
86 Grob_info::item () const
87 {
88   return dynamic_cast<Item *> (grob_);
89 }
90
91 Stream_event *
92 Grob_info::ultimate_event_cause () const
93 {
94   SCM cause = grob_->self_scm ();
95   while (unsmob<Grob> (cause))
96     {
97       cause = unsmob<Grob> (cause)->get_property ("cause");
98     }
99   return unsmob<Stream_event> (cause);
100 }
101
102 bool
103 Grob_info::less (Grob_info i, Grob_info j)
104 {
105   return Grob::less (i.grob (), j.grob ());
106 }