File: pos.h

package info (click to toggle)
muse 0.6.3-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 8,936 kB
  • ctags: 7,446
  • sloc: cpp: 66,262; sh: 8,355; makefile: 755; ansic: 172
file content (107 lines) | stat: -rw-r--r-- 2,780 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//=========================================================
//  MusE
//  Linux Music Editor
//  $Id: pos.h,v 1.1.1.1 2003/10/29 10:05:00 wschweer Exp $
//
//  (C) Copyright 2000 Werner Schweer (ws@seh.de)
//=========================================================

#ifndef __POS_H__
#define __POS_H__

class Xml;
class QString;

//---------------------------------------------------------
//   Pos
//---------------------------------------------------------

class Pos {
   public:
      enum TType { TICKS, SAMPLES, TIME };

   private:
      mutable int sn;

   protected:
      TType _type;
      mutable int    _posTick;
      mutable int    _posSample;
      mutable double _posTime;

   public:
      Pos();
      Pos(const Pos&);
      Pos(int,int,int);
      Pos(int,int,int,int);
      Pos(int, bool ticks=true);
      Pos(const QString&);
      void dump() const;
      void mbt(int*, int*, int*) const;
      void msf(int*, int*, int*, int*) const;

      void invalidSn()  { sn = -1; }

      TType  type() const     { return _type; }
      void   setType(TType t);

      Pos& operator+=(Pos a);
      Pos& operator+=(int a);

      bool operator>(const Pos& s) const {
            return posTick() > s.posTick();
            }
      bool operator<(const Pos& s) const {
            return posTick() < s.posTick();
            }
      bool operator==(const Pos& s) const {
            return posTick() == s.posTick();
            }

      friend Pos operator+(Pos a, Pos b);
      friend Pos operator+(Pos a, int b);

      int    posTick() const;
      int    posSample() const;
      double posTime() const;
      void   setPosTick(int);
      void   setPosSample(int);
      void   setPosTime(double);

      void write(int level, Xml&, const char*) const;
      void read(Xml& xml, const char*);
      bool isValid() const { return true; }
      static bool isValid(int m, int b, int t);
      static bool isValid(int, int, int, int);
      };

//---------------------------------------------------------
//   PosLen
//---------------------------------------------------------

class PosLen : public Pos {
      mutable int    _lenTick;
      mutable int    _lenSample;
      mutable double _lenTime;
      mutable int sn;

   public:
      PosLen();
      PosLen(const PosLen&);
      void dump() const;

      void write(int level, Xml&, const char*) const;
      void read(Xml& xml, const char*);
      void setLenTick(int);
      void setLenSample(int);
      void setLenTime(double);
      int lenTick() const;
      int lenSample() const;
      double lenTime() const;
      Pos end() const;
      int endTick() const    { return end().posTick(); }
      int endSample() const  { return end().posSample(); }
      void setPos(const Pos&);
      };

#endif