]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/moment.hh
Run grand-replace (issue 3765)
[lilypond.git] / lily / include / moment.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1999--2014 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 #ifndef MOMENT_HH
21 #define MOMENT_HH
22
23 #include "smobs.hh"
24 #include "rational.hh"
25
26 /**
27    Musical timing (Main-timing, grace-timing) with glue for
28    Guilification;
29 */
30 class Moment
31 {
32   DECLARE_SIMPLE_SMOBS (Moment);
33 public:
34   Moment ();
35   Moment (int m);
36
37   Moment (Rational, Rational);
38   Moment (Rational m);
39
40   Moment operator - () const;
41
42   void operator += (Moment const &m);
43   void operator -= (Moment const &m);
44
45   void operator *= (Moment const &m);
46   void operator /= (Moment const &m);
47   void operator %= (Moment const &m);
48
49   Rational main_part_;
50   Rational grace_part_;
51
52   void set_infinite (int k);
53
54   bool to_bool () const;
55   I64 den () const;
56   I64 num () const;
57   /*
58     Deliver a copy of THIS as a smobified SCM
59   */
60   string to_string () const;
61   static int compare (Moment const &, Moment const &);
62   SCM as_scheme () const;
63 };
64
65 IMPLEMENT_ARITHMETIC_OPERATOR (Moment, +);
66 IMPLEMENT_ARITHMETIC_OPERATOR (Moment, -);
67 IMPLEMENT_ARITHMETIC_OPERATOR (Moment, / );
68 IMPLEMENT_ARITHMETIC_OPERATOR (Moment, *);
69 IMPLEMENT_ARITHMETIC_OPERATOR (Moment, % );
70
71 DECLARE_UNSMOB (Moment, moment);
72 int compare (Moment const &, Moment const &);
73 INSTANTIATE_COMPARE (Moment const &, Moment::compare);
74
75 Moment robust_scm2moment (SCM, Moment);
76
77 #ifdef STREAM_SUPPORT
78 ostream &operator << (ostream &, Moment const &);
79 #endif
80
81 bool moment_less (SCM a, SCM b);
82
83 #endif /* MOMENT_HH */
84