/* Copyright (C) 2015 * swift project Community / Contributors * * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, * including this file, may be copied, modified, propagated, or distributed except according to the terms * contained in the LICENSE file. */ //! \file #ifndef BLACKMISC_TIMESTAMPOBJECTLIST_H #define BLACKMISC_TIMESTAMPOBJECTLIST_H #include "blackmisc/blackmiscexport.h" #include #include class QDateTime; namespace BlackMisc { //! List of objects with timestamp. //! Such objects should implement \sa ITimestampBased template class ITimestampObjectList { public: //! List of objects before dateTime CONTAINER findBefore(const QDateTime &dateTime) const; //! List of objects before msSinceEpoch CONTAINER findBefore(qint64 msSinceEpoch) const; //! Get objects before msSinceEpoch and remove those CONTAINER findBeforeAndRemove(qint64 msSinceEpoch); //! List of objects before now - offset CONTAINER findBeforeNowMinusOffset(qint64 msOffset) const; //! List of objects after dateTime CONTAINER findAfter(const QDateTime &dateTime) const; //! List of objects after msSinceEpoch CONTAINER findAfter(qint64 msSinceEpoch) const; //! Objects without valid timestamp CONTAINER findInvalidTimestamps() const; //! Has invalid timestamp bool hasInvalidTimestamps() const; //! Set all timestamps to now void setCurrentUtcTime(); //! Set all timestamps to given time void setUtcTime(qint64 msSinceEpoch); //! Set invalid timestamps to now void setInvalidTimestampsToCurrentUtcTime(); //! Latest timestamp QDateTime latestTimestamp() const; //! Latest timestamp qint64 latestTimestampMsecsSinceEpoch() const; //! Oldest timestamp QDateTime oldestTimestamp() const; //! Oldest timestamp qint64 oldestTimestampMsecsSinceEpoch() const; //! Latest value OBJ latestObject() const; //! Latest value OBJ oldestObject() const; //! Remove objects with timestamp before dateTime int removeBefore(const QDateTime &dateTime); //! Remove objects with timestamp before dateTime int removeBefore(qint64 msSinceEpoch); //! Remove objects older than seconds int removeOlderThanNowMinusOffset(qint64 offsetMs); //! Sort by timestamp void sortLatestFirst(); //! Sort by timestamp void sortOldestFirst(); //! Inserts as first object by keeping max. elements void push_frontMaxElements(const OBJ &object, int maxElements); protected: //! Constructor ITimestampObjectList(); //! Container const CONTAINER &container() const; //! Container CONTAINER &container(); }; //! \cond PRIVATE namespace Aviation { class CAircraftSituation; class CAircraftSituationList; class CAircraftParts; class CAircraftPartsList; class CAirport; class CAirportList; class CLivery; class CLiveryList; class CAircraftIcaoCode; class CAircraftIcaoCodeList; class CAirlineIcaoCode; class CAirlineIcaoCodeList; } namespace Network { class CTextMessage; class CTextMessageList; class CUrlLog; class CUrlLogList; } namespace Db { class CDbInfo; class CDbInfoList; class CDistribution; class CDistributionList; } namespace Simulation { class CDistributor; class CDistributorList; class CAircraftModel; class CAircraftModelList; } class CStatusMessage; class CStatusMessageList; class CIdentifier; class CIdentifierList; class CCountry; class CCountryList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; //! \endcond } //namespace #endif //guard