]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/moment.hh
release: 1.5.0
[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--2001 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    Rationals with glue for Guilification;
18 */
19 class Moment
20 {
21   DECLARE_SIMPLE_SMOBS (Moment,);
22 public:
23   Moment ();
24   Moment (int m);
25   Moment (int m, int n);
26
27   Moment (Rational m);
28
29
30   void operator += (Moment const &m);
31   void operator -= (Moment const &m);  
32
33   void operator *= (Moment const &m);
34   void operator /= (Moment const &m);  
35
36   Rational main_part_;
37   Rational grace_mom_;
38
39   void set_infinite (int k);
40   
41   operator bool ();
42   int den () const;
43   int num () const;
44   /*
45     Deliver a copy of THIS as a smobified SCM
46    */
47   SCM smobbed_copy () const;
48   String str () const;
49   static int compare (Moment const&, Moment const&);
50 };
51 IMPLEMENT_ARITHMETIC_OPERATOR (Moment, + );
52 IMPLEMENT_ARITHMETIC_OPERATOR (Moment, - );
53 IMPLEMENT_ARITHMETIC_OPERATOR (Moment, / );
54 IMPLEMENT_ARITHMETIC_OPERATOR (Moment, * );
55
56
57 Moment * unsmob_moment (SCM);
58 int compare (Moment const&,Moment const&);
59 INSTANTIATE_COMPARE (Moment const&, Moment::compare);
60
61 #if 0
62 IMPLEMENT_ARITHMETIC_OPERATOR (Moment, % );
63 #endif
64
65 #endif /* MOMENT_HH */
66