Files
pilotclient/src/blackmisc/datastoreobjectlist.h
Klaus Basan 25fd0f4f2d refs #445, value objects and containers
* common base class for DB based classes
* common base class for DB based containers
* Livery, distributor value class
* adjusted value classes to livery
* utility functions for DB values (blackmisc free functions)
* register new objects with metadata system
2015-11-19 20:57:17 +00:00

84 lines
2.7 KiB
C++

/* 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 <QList>
#include <QMap>
namespace BlackMisc
{
//! List of objects read from database.
//! Such objects should implement \sa ITimestampBased and \sa IDatastoreObjectWithIntegerKey
template<class OBJ, class CONTAINER> class IDatastoreObjectListWithIntegerKey : public ITimestampObjectList<OBJ, CONTAINER>
{
public:
//! Object with key, notFound otherwise
OBJ findByKey(int key, const OBJ &notFound = OBJ()) const;
//! Sort by timestamp
void sortByKey();
//! From DB JSON
static CONTAINER fromDatabaseJson(const QJsonArray &array);
protected:
//! Constructor
IDatastoreObjectListWithIntegerKey();
};
//! List of objects read from database.
//! Such objects should implement \sa ITimestampBased and \sa IDatastoreObjectWithString
template<class OBJ, class CONTAINER> class IDatastoreObjectListWithStringKey : public ITimestampObjectList<OBJ, CONTAINER>
{
public:
//! Object with key, not found otherwise
OBJ findByKey(const QString &key, const OBJ &notFound = OBJ()) const;
//! Sort by timestamp
void sortByKey();
//! From DB JSON
static CONTAINER fromDatabaseJson(const QJsonArray &array);
protected:
//! Constructor
IDatastoreObjectListWithStringKey();
};
//! \cond PRIVATE
namespace Aviation
{
class CLivery;
class CLiveryList;
}
namespace Simulation
{
class CDistributor;
class CDistributorList;
class CAircraftModel;
class CAircraftModelList;
}
extern template class BLACKMISC_EXPORT_TEMPLATE IDatastoreObjectListWithIntegerKey<BlackMisc::Aviation::CLivery, BlackMisc::Aviation::CLiveryList>;
extern template class BLACKMISC_EXPORT_TEMPLATE IDatastoreObjectListWithIntegerKey<BlackMisc::Simulation::CAircraftModel, BlackMisc::Simulation::CAircraftModelList>;
extern template class BLACKMISC_EXPORT_TEMPLATE IDatastoreObjectListWithStringKey<BlackMisc::Simulation::CDistributor, BlackMisc::Simulation::CDistributorList>;
//! \endcond
} //namespace
#endif //guard