Skip to content

Commit cd6cabf

Browse files
committed
changed Freq::Time internal storage type to seconds/float
1 parent 8f0d494 commit cd6cabf

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

kit/freq/freq.h

+22-23
Original file line numberDiff line numberDiff line change
@@ -20,42 +20,41 @@ class Freq
2020
class Time
2121
{
2222
public:
23-
unsigned int value;
23+
//unsigned int value;
24+
float sec;
2425
Time():
25-
value(0) {}
26-
explicit Time(unsigned int ms) {
27-
value = ms;
28-
}
26+
sec(0) {}
27+
explicit Time(float ms) { sec = ms/1000.0f; } // deprecated
2928
Time(const Time& t) = default;
3029
Time& operator=(const Time& t) = default;
3130
Time(Time&& t) = default;
3231
Time& operator=(Time&& t) = default;
3332

34-
unsigned int internal() const { return value; }
33+
unsigned ui() const { return (unsigned int)(sec*1000.0f); }
3534
//static Time seconds(unsigned int s) { return Time(s * 1000);}
36-
static Time seconds(float s) { return Time((unsigned int)(s * 1000.0f)); }
35+
static Time seconds(float s) { return Time(s*1000.0f); }
3736
//static Time minutes(unsigned int m) { return Time(m * 60000);}
38-
static Time minutes(float m) { return Time((unsigned int)(m * 60000.0f));}
39-
static Time ms(unsigned int ms) { return Time(ms); }
37+
static Time minutes(float m) { return Time(m * 60000.0f);}
38+
static Time ms(float ms) { return Time(ms); }
4039

41-
//operator bool() const { return value; }
42-
//operator float() const { return value / 1000.0f; }
40+
//operator bool() const { return sec; }
41+
//operator float() const { return sec / 1000.0f; }
4342

4443
Time& operator+=(Time t) {
45-
value += t.internal();
44+
sec += t.sec;
4645
return *this;
4746
}
48-
bool operator>(Time t) const { return value > t.internal(); }
49-
bool operator<(Time t) const { return value < t.internal(); }
50-
bool operator>=(Time t) const { return value >= t.internal(); }
51-
bool operator<=(Time t) const { return value <= t.internal(); }
47+
bool operator>(Time t) const { return sec > t.sec; }
48+
bool operator<(Time t) const { return sec < t.sec; }
49+
bool operator>=(Time t) const { return sec >= t.sec; }
50+
bool operator<=(Time t) const { return sec <= t.sec; }
5251
operator bool() const {
53-
return value;
52+
return std::abs(sec*1000.0f) > K_EPSILON;
5453
}
5554

56-
float s() const { return value / 1000.0f; }
57-
float seconds() const { return value / 1000.0f; }
58-
unsigned int ms() const { return value; }
55+
float s() const { return sec; }
56+
float seconds() const { return sec; }
57+
float ms() const { return sec * 1000.0f; }
5958
};
6059

6160
class Timeline {
@@ -122,7 +121,7 @@ class Freq
122121
}
123122

124123
bool elapsed(Freq::Time value) {
125-
return m_ulPassedTime > value.ms();
124+
return m_ulPassedTime > value.ui();
126125
}
127126
Freq::Time age() const {
128127
return Freq::Time::ms(m_ulPassedTime);
@@ -225,7 +224,7 @@ class Freq
225224
}
226225

227226
Freq::Time pause() {
228-
return Freq::Time(m_ulAlarmTime - m_ulStartTime);
227+
return Freq::Time::ms(m_ulAlarmTime - m_ulStartTime);
229228
}
230229

231230
void minutes(unsigned int m)
@@ -277,7 +276,7 @@ class Freq
277276
Freq::Time excess() const {
278277
if(!elapsed())
279278
return Freq::Time(0);
280-
return Freq::Time(m_pTimer->ms() - m_ulAlarmTime);
279+
return Freq::Time::ms(m_pTimer->ms() - m_ulAlarmTime);
281280
}
282281

283282
boost::signals2::connection connect(std::function<void()> cb) {

lib/local_shared_ptr

Submodule local_shared_ptr deleted from fdaef36

lib/local_shared_ptr

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/home/flipcoder/Projects/local_shared_ptr

0 commit comments

Comments
 (0)