/* 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_DATABASEOBJECTLIST_H #define BLACKMISC_DATABASEOBJECTLIST_H #include "blackmisc/timestampobjectlist.h" #include "blackmisc/collection.h" #include "blackmisc/sequence.h" #include #include namespace BlackMisc { //! List of objects read from database. //! Such objects should implement \sa ITimestampBased and \sa IDatastoreObjectWithIntegerKey or \sa IDatastoreObjectWithStringKey template class IDatastoreObjectList : public ITimestampObjectList { public: //! Object with key, notFound otherwise OBJ findByKey(KEYTYPE key, const OBJ ¬Found = OBJ()) const; //! Object with max.key OBJ maxKeyObject() const; //! Sort by timestamp void sortByKey(); //! All keys as list QList toDbKeyList() const; //! Max.key value (making sense with integer key) KEYTYPE getMaxKey(bool *ok = nullptr) const; //! Remove objects with key int removeObjectsWithKeys(const QList &keys); //! Update or insert data (based on DB key) int replaceOrAddObjectsByKey(const CONTAINER &container); //! From DB JSON with default prefixes static CONTAINER fromDatabaseJson(const QJsonArray &array); //! From DB JSON static CONTAINER fromDatabaseJson(const QJsonArray &array, const QString &prefix); protected: //! Constructor IDatastoreObjectList(); }; //! \cond PRIVATE namespace Aviation { class CLivery; class CLiveryList; } namespace Simulation { class CDistributor; class CDistributorList; class CAircraftModel; class CAircraftModelList; } extern template class BLACKMISC_EXPORT_TEMPLATE IDatastoreObjectList; extern template class BLACKMISC_EXPORT_TEMPLATE IDatastoreObjectList; extern template class BLACKMISC_EXPORT_TEMPLATE IDatastoreObjectList; extern template class BLACKMISC_EXPORT_TEMPLATE IDatastoreObjectList; extern template class BLACKMISC_EXPORT_TEMPLATE IDatastoreObjectList; extern template class BLACKMISC_EXPORT_TEMPLATE IDatastoreObjectList; //! \endcond } //namespace #endif //guard