dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
uavobjectmanager.h
Go to the documentation of this file.
1 
17 /*
18  * This program is free software; you can redistribute it and/or modify
19  * it under the terms of the GNU General Public License as published by
20  * the Free Software Foundation; either version 3 of the License, or
21  * (at your option) any later version.
22  *
23  * This program is distributed in the hope that it will be useful, but
24  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
25  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26  * for more details.
27  *
28  * You should have received a copy of the GNU General Public License along
29  * with this program; if not, see <http://www.gnu.org/licenses/>
30  *
31  * Additional note on redistribution: The copyright and license notices above
32  * must be maintained in each individual source file that is a derivative work
33  * of this source file; otherwise redistribution is prohibited.
34  */
35 
36 #ifndef UAVOBJECTMANAGER_H
37 #define UAVOBJECTMANAGER_H
38 
40 #include "uavobjects/uavobject.h"
43 #include <QVector>
44 #include <QHash>
45 
46 class UAVOBJECTS_EXPORT UAVObjectManager : public QObject
47 {
48  Q_OBJECT
49 
50 public:
53  typedef QMap<quint32, UAVObject *> ObjectMap;
54  bool registerObject(UAVDataObject *obj);
55  QVector<QVector<UAVObject *>> getObjectsVector();
56  QHash<quint32, QMap<quint32, UAVObject *>> getObjects();
57  QVector<QVector<UAVDataObject *>> getDataObjectsVector();
58  QVector<QVector<UAVMetaObject *>> getMetaObjectsVector();
59  UAVObject *getObject(const QString &name, quint32 instId = 0);
60  UAVObject *getObject(quint32 objId, quint32 instId = 0);
69  UAVObjectField *getField(const QString &objName, const QString &fieldName, quint32 instId = 0);
70  QVector<UAVObject *> getObjectInstancesVector(const QString &name);
71  QVector<UAVObject *> getObjectInstancesVector(quint32 objId);
72  qint32 getNumInstances(const QString &name);
73  qint32 getNumInstances(quint32 objId);
74  bool unRegisterObject(UAVDataObject *obj);
75 signals:
76  void newObject(UAVObject *obj);
77  void newInstance(UAVObject *obj);
78  void instanceRemoved(UAVObject *obj);
79 
80 private:
81  static const quint32 MAX_INSTANCES = 1000;
82  QHash<quint32, QMap<quint32, UAVObject *>> objects;
83  QHash<QString, QMap<quint32, UAVObject *>> objectsByName;
84 
85  void addObject(UAVObject *obj);
86  UAVObject *getObject(const QString &name, quint32 objId, quint32 instId);
87  QVector<UAVObject *> getObjectInstancesVector(const QString *name, quint32 objId);
88  qint32 getNumInstances(const QString *name, quint32 objId);
89 };
90 
91 #endif // UAVOBJECTMANAGER_H
QMap< quint32, UAVObject * > ObjectMap