mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
Ref T259, Ref T243 utility functions for timestamp based classes and parts plus renamings
This commit is contained in:
@@ -25,5 +25,17 @@ namespace BlackMisc
|
||||
CAircraftPartsList::CAircraftPartsList(std::initializer_list<CAircraftParts> il) :
|
||||
CSequence<CAircraftParts>(il)
|
||||
{ }
|
||||
|
||||
int CAircraftPartsList::setOnGround(bool onGround)
|
||||
{
|
||||
int c = 0;
|
||||
for (CAircraftParts &p : *this)
|
||||
{
|
||||
if (p.isOnGround() == onGround) { continue; }
|
||||
p.setOnGround(onGround);
|
||||
c++;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace BlackMisc
|
||||
class BLACKMISC_EXPORT CAircraftPartsList :
|
||||
public CSequence<CAircraftParts>,
|
||||
public ITimestampWithOffsetObjectList<CAircraftParts, CAircraftPartsList>,
|
||||
public BlackMisc::Mixin::MetaType<CAircraftPartsList>
|
||||
public Mixin::MetaType<CAircraftPartsList>
|
||||
{
|
||||
public:
|
||||
BLACKMISC_DECLARE_USING_MIXIN_METATYPE(CAircraftPartsList)
|
||||
@@ -42,8 +42,10 @@ namespace BlackMisc
|
||||
|
||||
//! Construct from initializer list.
|
||||
CAircraftPartsList(std::initializer_list<CAircraftParts> il);
|
||||
};
|
||||
|
||||
//! Set on ground for all entries
|
||||
int setOnGround(bool onGround);
|
||||
};
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -310,7 +310,7 @@ namespace BlackMisc
|
||||
return (i >= static_cast<int>(IndexOffsetMs)) && (i <= static_cast<int>(IndexOffsetWithUnit));
|
||||
}
|
||||
|
||||
bool ITimestampWithOffsetBased::hasOffsetTime() const
|
||||
bool ITimestampWithOffsetBased::hasNonZeroOffsetTime() const
|
||||
{
|
||||
return m_timeOffsetMs != 0;
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace BlackMisc
|
||||
qint64 getTimeOffsetMs() const { return m_timeOffsetMs; }
|
||||
|
||||
//! Having a valid offset time
|
||||
bool hasOffsetTime() const;
|
||||
bool hasNonZeroOffsetTime() const;
|
||||
|
||||
//! Offset with unit
|
||||
QString getTimeOffsetWithUnit() const;
|
||||
|
||||
@@ -293,6 +293,16 @@ namespace BlackMisc
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class OBJ, class CONTAINER>
|
||||
bool ITimestampWithOffsetObjectList<OBJ, CONTAINER>::containsNegativeOffsetTime() const
|
||||
{
|
||||
for (const ITimestampWithOffsetBased &obj : this->container())
|
||||
{
|
||||
if (obj.getTimeOffsetMs() < 0) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class OBJ, class CONTAINER>
|
||||
ITimestampWithOffsetObjectList<OBJ, CONTAINER>::ITimestampWithOffsetObjectList() : ITimestampObjectList<OBJ, CONTAINER>()
|
||||
{
|
||||
|
||||
@@ -128,6 +128,9 @@ namespace BlackMisc
|
||||
//! Any negative or zero offset time?
|
||||
bool containsZeroOrNegativeOffsetTime() const;
|
||||
|
||||
//! Any negative offset time?
|
||||
bool containsNegativeOffsetTime() const;
|
||||
|
||||
//! Insert as first element by keeping maxElements and the latest first
|
||||
void push_frontKeepLatestAdjustedFirst(const OBJ &value, int maxElements = -1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user