]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/moment.hh
a73b9961d1746ccc26dbe531fc7c43fa24f777ce
[lilypond.git] / lily / include / moment.hh
1 /*
2   moment.hh -- declare Moment
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1999--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #ifndef MOMENT_HH
10 #define MOMENT_HH
11
12 #include "smobs.hh"
13 #include "rational.hh"
14
15 /**
16    Musical timing (Main-timing, grace-timing) with glue for
17    Guilification;
18 */
19 class Moment
20 {
21   DECLARE_SIMPLE_SMOBS (Moment);
22 public:
23   Moment ();
24   Moment (int m);
25
26   Moment (Rational, Rational);
27   Moment (Rational m);
28
29   Moment operator - () const;
30
31   void operator += (Moment const &m);
32   void operator -= (Moment const &m);
33
34   void operator *= (Moment const &m);
35   void operator /= (Moment const &m);
36   void operator %= (Moment const &m);
37
38   Rational main_part_;
39   Rational grace_part_;
40
41   void set_infinite (int k);
42
43   bool to_bool () const;
44   I64 den () const;
45   I64 num () const;
46   /*
47     Deliver a copy of THIS as a smobified SCM
48   */
49   string to_string () const;
50   static int compare (Moment const &, Moment const &);
51   SCM as_scheme () const;
52 };
53
54 IMPLEMENT_ARITHMETIC_OPERATOR (Moment, +);
55 IMPLEMENT_ARITHMETIC_OPERATOR (Moment, -);
56 IMPLEMENT_ARITHMETIC_OPERATOR (Moment, /);
57 IMPLEMENT_ARITHMETIC_OPERATOR (Moment, *);
58 IMPLEMENT_ARITHMETIC_OPERATOR (Moment, %);
59
60 DECLARE_UNSMOB (Moment, moment);
61 int compare (Moment const &, Moment const &);
62 INSTANTIATE_COMPARE (Moment const &, Moment::compare);
63
64 Moment robust_scm2moment (SCM, Moment);
65
66 #ifdef STREAM_SUPPORT
67 ostream &operator << (ostream &, Moment const &);
68 #endif
69
70 bool moment_less (SCM a, SCM b);
71
72 #endif /* MOMENT_HH */
73