FakeSegments refactored.

Few things of note:

1) Slowly going away from hungarian notation.
2) Trying to respect public/private members.
2a) Yes, structs can work like this.
3) Trying to not require horizontal scrolling.

If anyone else wants a crack, go ahead:
we have 9 segments left. :)
This commit is contained in:
Jason Felds
2011-05-31 00:51:25 -04:00
parent 62365ee9e9
commit 1d3000e520
6 changed files with 189 additions and 133 deletions
+65 -3
View File
@@ -1,10 +1,13 @@
#include "TimingSegments.h"
TimingSegment::TimingSegment() : startingRow(-1) {}
TimingSegment::TimingSegment() :
startingRow(-1) {}
TimingSegment::TimingSegment(int s) : startingRow(s) {}
TimingSegment::TimingSegment(int s) :
startingRow(s) {}
TimingSegment::TimingSegment(float s) : startingRow(BeatToNoteRow(s)) {}
TimingSegment::TimingSegment(float s) :
startingRow(BeatToNoteRow(s)) {}
TimingSegment::~TimingSegment() {}
@@ -27,6 +30,65 @@ float TimingSegment::GetBeat() const
return NoteRowToBeat(this->startingRow);
}
FakeSegment::FakeSegment():
TimingSegment(-1), lengthBeats(-1) {}
FakeSegment::FakeSegment( int s, int r ):
TimingSegment(max(0, s)), lengthBeats(NoteRowToBeat(max(0, r))) {}
FakeSegment::FakeSegment( int s, float b ):
TimingSegment(max(0, s)), lengthBeats(max(0, b)) {}
FakeSegment::FakeSegment( float s, int r ):
TimingSegment(max(0, s)), lengthBeats(max(0, NoteRowToBeat(r))) {}
FakeSegment::FakeSegment( float s, float b ):
TimingSegment(max(0, s)), lengthBeats(max(0, b)) {}
float FakeSegment::GetLength() const
{
return this->lengthBeats;
}
void FakeSegment::SetLength(const float b)
{
this->lengthBeats = b;
}
bool FakeSegment::operator==( const FakeSegment &other ) const
{
if (this->GetRow() != other.GetRow()) return false;
if (this->GetLength() != other.GetLength()) return false;
return true;
}
bool FakeSegment::operator!=( const FakeSegment &other ) const
{
return !this->operator==(other);
}
bool FakeSegment::operator<( const FakeSegment &other ) const
{
if (this->GetRow() < other.GetRow()) return true;
if (this->GetRow() > other.GetRow()) return false;
return this->GetLength() < other.GetLength();
}
bool FakeSegment::operator<=( const FakeSegment &other ) const
{
return ( this->operator<(other) || this->operator==(other) );
}
bool FakeSegment::operator>( const FakeSegment &other ) const
{
return !this->operator<=(other);
}
bool FakeSegment::operator>=( const FakeSegment &other ) const
{
return !this->operator<(other);
}
/**
* @file
* @author Jason Felds (c) 2011