]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/moment.hh
* lily/global-context.cc (run_iterator_on_me): fix grace note
[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--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #ifndef MOMENT_HH
11 #define MOMENT_HH
12
13 #include "smobs.hh"
14 #include "rational.hh"
15
16 /**
17    Musical timing (Main-timing, grace-timing) with glue for
18    Guilification;
19 */
20 class Moment
21 {
22   DECLARE_SIMPLE_SMOBS (Moment,);
23 public:
24   Moment ();
25   Moment (int m);
26
27   Moment (Rational, Rational);
28   Moment (Rational m);
29
30   Moment operator - () const;
31   
32   void operator += (Moment const &m);
33   void operator -= (Moment const &m);  
34
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   int den () const;
45   int 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   
52 };
53 IMPLEMENT_ARITHMETIC_OPERATOR (Moment, + );
54 IMPLEMENT_ARITHMETIC_OPERATOR (Moment, - );
55 IMPLEMENT_ARITHMETIC_OPERATOR (Moment, / );
56 IMPLEMENT_ARITHMETIC_OPERATOR (Moment, * );
57
58
59 DECLARE_UNSMOB(Moment,moment);
60 int compare (Moment const&,Moment const&);
61 INSTANTIATE_COMPARE (Moment const&, Moment::compare);
62
63
64 #ifdef STREAM_SUPPORT
65 std::ostream & operator << (std::ostream &, Moment const &);
66 #endif
67
68 #endif /* MOMENT_HH */
69