fix the template mess! it now builds on windows but not sure if it works or if it will build on other platforms.

This commit is contained in:
Thai Pangsakulyanont
2011-06-01 14:21:57 +07:00
parent d0ff9413e7
commit 6f83556da7
2 changed files with 66 additions and 24 deletions
-7
View File
@@ -26,13 +26,6 @@ float BaseTimingSegment::GetBeat() const
return NoteRowToBeat(GetRow()); return NoteRowToBeat(GetRow());
} }
template <class DerivedSegment>
bool TimingSegment<DerivedSegment>::operator<( const DerivedSegment &other ) const
{
LTCOMPARE(GetRow());
return false;
}
/* ====================================================== /* ======================================================
Here comes the actual timing segments implementation!! */ Here comes the actual timing segments implementation!! */
+65 -16
View File
@@ -15,18 +15,15 @@ struct BaseTimingSegment
BaseTimingSegment(): BaseTimingSegment():
startingRow(-1) {}; startingRow(-1) {};
BaseTimingSegment(const BaseTimingSegment &b)
{
*this = b;
}
/** /**
* @brief Set up a BaseTimingSegment with specified values. * @brief Set up a BaseTimingSegment with specified values.
* @param s the starting row / beat. * @param s the starting row / beat. */
* BaseTimingSegment(int s): startingRow(ToNoteRow(s)) {}
* NOTE: On Windows, it's passing in the Segments, not ints or floats. */ BaseTimingSegment(float s): startingRow(ToNoteRow(s)) {}
template <typename StartType>
BaseTimingSegment(StartType s): startingRow(s) {} template <class DerivedSegment>
BaseTimingSegment(const DerivedSegment &other):
startingRow(other.GetRow()) {};
virtual ~BaseTimingSegment(); virtual ~BaseTimingSegment();
@@ -68,11 +65,11 @@ template <class DerivedSegment>
struct TimingSegment: public BaseTimingSegment struct TimingSegment: public BaseTimingSegment
{ {
TimingSegment(): BaseTimingSegment(-1) {}; TimingSegment(): BaseTimingSegment() {};
TimingSegment(const DerivedSegment &other): BaseTimingSegment(other) {};
TimingSegment(int s): BaseTimingSegment(s) {}; template <typename StartType>
TimingSegment(StartType s): BaseTimingSegment(s) {};
TimingSegment(float s): BaseTimingSegment(ToNoteRow(s)) {};
/** /**
* @brief Compares two DrivedSegments to see if one is less than the other. * @brief Compares two DrivedSegments to see if one is less than the other.
@@ -82,7 +79,10 @@ struct TimingSegment: public BaseTimingSegment
* This is virtual to allow other segments to implement comparison * This is virtual to allow other segments to implement comparison
* as required by them. * as required by them.
*/ */
virtual bool operator<( const DerivedSegment &other ) const; virtual bool operator<( const DerivedSegment &other ) const
{
return this->GetRow() < other.GetRow();
};
/** /**
* @brief Compares two DrivedSegments to see if they are equal to each other. * @brief Compares two DrivedSegments to see if they are equal to each other.
@@ -149,6 +149,14 @@ struct FakeSegment : public TimingSegment<FakeSegment>
FakeSegment(): FakeSegment():
TimingSegment<FakeSegment>(-1), lengthBeats(-1) {}; TimingSegment<FakeSegment>(-1), lengthBeats(-1) {};
/**
* @brief Create a copy of another Fake Segment.
* @param other the other fake segment
*/
FakeSegment(const FakeSegment &other):
TimingSegment<FakeSegment>(other),
lengthBeats(other.GetLength()) {};
/** /**
* @brief Create a Fake Segment with the specified values. * @brief Create a Fake Segment with the specified values.
* @param s the starting row of this segment. * @param s the starting row of this segment.
@@ -200,6 +208,14 @@ struct WarpSegment : public TimingSegment<WarpSegment>
WarpSegment(): WarpSegment():
TimingSegment<WarpSegment>(), lengthBeats(-1) {}; TimingSegment<WarpSegment>(), lengthBeats(-1) {};
/**
* @brief Create a copy of another Warp Segment.
* @param other the other warp segment
*/
WarpSegment(const WarpSegment &other):
TimingSegment<WarpSegment>(other.GetRow()),
lengthBeats(other.GetLength()) {};
/** /**
* @brief Create a Warp Segment with the specified values. * @brief Create a Warp Segment with the specified values.
* @param s the starting row of this segment. * @param s the starting row of this segment.
@@ -207,7 +223,7 @@ struct WarpSegment : public TimingSegment<WarpSegment>
*/ */
template <typename StartType, typename LengthType> template <typename StartType, typename LengthType>
WarpSegment( StartType s, LengthType r ): WarpSegment( StartType s, LengthType r ):
TimingSegment<WarpSegment>(max((StartType)0, s)), TimingSegment<WarpSegment>(s),
lengthBeats(ToBeat(max((LengthType)0, r))) {}; lengthBeats(ToBeat(max((LengthType)0, r))) {};
/** /**
@@ -251,6 +267,14 @@ struct TickcountSegment : public TimingSegment<TickcountSegment>
TickcountSegment(): TickcountSegment():
TimingSegment<TickcountSegment>(), ticks(4) {}; TimingSegment<TickcountSegment>(), ticks(4) {};
/**
* @brief Create a copy of another Tickcount Segment.
* @param other the other tickcount segment
*/
TickcountSegment(const TickcountSegment &other):
TimingSegment<TickcountSegment>(other),
ticks(other.GetTicks()) {};
/** /**
* @brief Creates a TickcountSegment with specified values. * @brief Creates a TickcountSegment with specified values.
* @param s the starting row / beat. */ * @param s the starting row / beat. */
@@ -305,6 +329,11 @@ struct ComboSegment : public TimingSegment<ComboSegment>
*/ */
ComboSegment() : ComboSegment() :
TimingSegment<ComboSegment>(), combo(1) { } TimingSegment<ComboSegment>(), combo(1) { }
ComboSegment(const ComboSegment &other) :
TimingSegment<ComboSegment>(other),
combo(other.GetCombo()) {};
/** /**
* @brief Creates a Combo Segment with the specified values. * @brief Creates a Combo Segment with the specified values.
* @param s the starting row / beat of this segment. * @param s the starting row / beat of this segment.
@@ -354,6 +383,11 @@ struct LabelSegment : public TimingSegment<LabelSegment>
*/ */
LabelSegment() : LabelSegment() :
TimingSegment<LabelSegment>(), label("") { } TimingSegment<LabelSegment>(), label("") { }
LabelSegment(const LabelSegment &other) :
TimingSegment<LabelSegment>(other),
label(other.GetLabel()) {};
/** /**
* @brief Creates a Label Segment with the specified values. * @brief Creates a Label Segment with the specified values.
* @param s the starting row / beat of this segment. * @param s the starting row / beat of this segment.
@@ -403,6 +437,10 @@ struct BPMSegment : public TimingSegment<BPMSegment>
BPMSegment() : BPMSegment() :
TimingSegment<BPMSegment>(-1), bps(-1.0f) { } TimingSegment<BPMSegment>(-1), bps(-1.0f) { }
BPMSegment(const BPMSegment &other) :
TimingSegment<BPMSegment>(other),
bps(other.GetBPS()) {};
operator int() const { return 1; } operator int() const { return 1; }
operator float() const { return 2.0f; } operator float() const { return 2.0f; }
@@ -464,6 +502,11 @@ struct TimeSignatureSegment : public TimingSegment<TimeSignatureSegment>
TimeSignatureSegment(): TimeSignatureSegment():
TimingSegment<TimeSignatureSegment>(), TimingSegment<TimeSignatureSegment>(),
numerator(4), denominator(4) { } numerator(4), denominator(4) { }
TimeSignatureSegment(const TimeSignatureSegment &other) :
TimingSegment<TimeSignatureSegment>(other),
numerator(other.GetNum()),
denominator(other.GetDen()) {};
/** /**
* @brief Creates a Time Signature Segment with supplied values. * @brief Creates a Time Signature Segment with supplied values.
* *
@@ -552,6 +595,12 @@ struct SpeedSegment : public TimingSegment<SpeedSegment>
TimingSegment<SpeedSegment>(0), TimingSegment<SpeedSegment>(0),
ratio(1), length(0), unit(0) {} ratio(1), length(0), unit(0) {}
SpeedSegment(const SpeedSegment &other) :
TimingSegment<SpeedSegment>(other),
ratio(other.GetRatio()),
length(other.GetLength()),
unit(other.GetUnit()) {};
/** /**
* @brief Sets up the SpeedSegment with specified values. * @brief Sets up the SpeedSegment with specified values.
* @param s The row / beat this activates. * @param s The row / beat this activates.