Ref T259, Ref T243 utility functions for timestamp based classes and parts plus renamings

This commit is contained in:
Klaus Basan
2018-03-04 10:48:04 +01:00
parent df38107852
commit 55e2690ceb
6 changed files with 31 additions and 4 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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>()
{

View File

@@ -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);