Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / ground / gcs / src / plugins / uavobjects / uavobjectmanager.h
blobc65e54e71be38d2cc2f007e22be01a601966c65e
1 /**
2 ******************************************************************************
4 * @file uavobjectmanager.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @see The GNU Public License (GPL) Version 3
7 * @addtogroup GCSPlugins GCS Plugins
8 * @{
9 * @addtogroup UAVObjectsPlugin UAVObjects Plugin
10 * @{
11 * @brief The UAVUObjects GCS plugin
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #ifndef UAVOBJECTMANAGER_H
29 #define UAVOBJECTMANAGER_H
31 #include "uavobjects_global.h"
32 #include "uavobject.h"
33 #include "uavdataobject.h"
34 #include "uavmetaobject.h"
35 #include <QList>
36 #include <QMutex>
37 #include <QMutexLocker>
38 #include <QJsonObject>
40 class UAVOBJECTS_EXPORT UAVObjectManager : public QObject {
41 Q_OBJECT
43 public:
44 enum JSON_EXPORT_OPTION { JSON_EXPORT_ALL, JSON_EXPORT_METADATA, JSON_EXPORT_SETTINGS, JSON_EXPORT_DATA };
45 UAVObjectManager();
46 ~UAVObjectManager();
48 bool registerObject(UAVDataObject *obj);
49 QList< QList<UAVObject *> > getObjects();
50 QList< QList<UAVDataObject *> > getDataObjects();
51 QList< QList<UAVMetaObject *> > getMetaObjects();
52 UAVObject *getObject(const QString & name, quint32 instId = 0);
53 UAVObject *getObject(quint32 objId, quint32 instId = 0);
54 QList<UAVObject *> getObjectInstances(const QString & name);
55 QList<UAVObject *> getObjectInstances(quint32 objId);
56 qint32 getNumInstances(const QString & name);
57 qint32 getNumInstances(quint32 objId);
59 void toJson(QJsonObject &jsonObject, JSON_EXPORT_OPTION what = JSON_EXPORT_ALL);
60 void toJson(QJsonObject &jsonObject, const QList<QString> &objectsToExport);
61 void toJson(QJsonObject &jsonObject, const QList<UAVObject *> &objectsToExport);
62 void fromJson(const QJsonObject &jsonObject, QList<UAVObject *> *updatedObjects = NULL);
64 signals:
65 void newObject(UAVObject *obj);
66 void newInstance(UAVObject *obj);
68 private:
69 static const quint32 MAX_INSTANCES = 1000;
71 QList< QList<UAVObject *> > objects;
72 QMutex *mutex;
74 void addObject(UAVObject *obj);
75 UAVObject *getObject(const QString *name, quint32 objId, quint32 instId);
76 QList<UAVObject *> getObjectInstances(const QString *name, quint32 objId);
77 qint32 getNumInstances(const QString *name, quint32 objId);
81 #endif // UAVOBJECTMANAGER_H