Main Page · Modules · All Classes · Class Hierarchy
MPTypes.hpp
1 /*
2  * This file is part of the AiBO+ project
3  *
4  * Copyright (C) 2005-2016 Csaba Kertész (csaba.kertesz@gmail.com)
5  *
6  * AiBO+ is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * AiBO+ is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
19  *
20  */
21 
22 #pragma once
23 
24 #include <MSData.hpp>
25 
26 #include <core/MACoreTypes.hpp>
27 #include <types/MARobotState.hpp>
28 
29 #include <MCBinaryData.hpp>
30 
31 #include <qmap.h>
32 #include <qvector.h>
33 
34 #include <boost/shared_ptr.hpp>
35 
36 class QJsonObject;
37 class QStringList;
38 class MACollectedData;
39 class MARobotState;
40 class MEImage;
41 class MPRecord;
42 
48 namespace MP
49 {
50 static const QString NumberGameResultsID = "NumberGameResults";
51 
53 typedef std::pair<float, float> FloatPair;
54 
56 typedef QVector<MCBinaryData> BinaryDataList;
57 
59 typedef QVector<int> IntList;
60 
62 typedef boost::shared_ptr<MARobotState> RobotStatePtr;
64 typedef MC::BinaryDataSPtr ImagePtr;
66 typedef boost::shared_ptr<QStringList> LogMessagesPtr;
67 
69 typedef boost::shared_ptr<MPRecord> RecordPtr;
71 typedef QVector<RecordPtr> RecordPtrList;
72 
74 typedef MC::BinaryDataSPtr PacketPtr;
76 typedef QVector<PacketPtr> PacketPtrList;
77 
79 typedef QMap<int, RecordPtr> RecordPtrMap;
80 
82 typedef QVector<float> FloatList;
83 
85 typedef QVector<double> DoubleList;
86 
88 typedef QVector<DoubleList> DoubleTable;
89 
91 typedef QVector<bool> BooleanList;
92 
94 typedef QVector<int> IntList;
95 
97 typedef QMap<qint64, QString> LogEntryMap;
98 
100 typedef QVector<RobotStatePtr> RobotStatePtrList;
101 
103 typedef QVector<RobotStatePtrList> RobotStatePtrTable;
104 }
105 
115 extern MCBinaryData* MPDecodeImage(const MCBinaryData& binary_data);
116 
126 extern QJsonObject* MPConvertCollectedDataToJson(MACollectedData& collected_data);
127 
137 extern QJsonObject* MPConvertCollectedDataToJsonQuery(MACollectedData& collected_data);
138 
148 extern MACollectedData* MPConvertJsonToCollectedData(QJsonObject& json_object);
149 
150 template <typename U, typename T>
151 std::vector<std::vector<T> > MPConvertQtTableToStdTable(const U& qt_table)
152 {
153  std::vector<std::vector<T> > ResultTable;
154 
155  for (typename U::const_iterator Iter = qt_table.begin();
156  Iter != qt_table.end(); ++Iter)
157  {
158  ResultTable.push_back((*Iter).toStdVector());
159  }
160  return ResultTable;
161 }
162 
164 struct MPLogEntryMap : public MSData, public MP::LogEntryMap
165 {
167 
168 
169  MPLogEntryMap();
170  virtual ~MPLogEntryMap() { };
171 };
172 
174 struct MPCursorPosition : public MSData
175 {
177 
178 
180  virtual ~MPCursorPosition() { };
181 
182  int Position;
183 };
184 
185 
187 struct MPRecord
188 {
190  MPRecord();
191 
192  MCBinaryData* DecodeJpegImage() const;
193 
195  int ID;
197  MP::RobotStatePtr RobotState;
199  MC::BinaryDataSPtr RobotStateBinaryData;
201  MP::ImagePtr Image;
203  MP::LogMessagesPtr LogMessages;
205  MC::BinaryDataSPtr SoundData;
207  MP::PacketPtr Packet;
208 };
209 
211 struct MPRecordsContainer : public MSData
212 {
214 
215 
217  virtual ~MPRecordsContainer() { };
218 
226  const MP::RecordPtrList& GetRecords() const;
227 
235  const MP::PacketPtrList& GetPackets() const;
236 
244  bool IsEmpty() const;
245 
251  void Clear();
252 
262  MA::IntIntSortedMap AddDataFromPacket(MCBinaryData& packet);
263 
264  // STATIC VARIABLES
266  static std::string RobotStateVariableMap;
267 private:
268  // NON-STATIC VARIABLES
270  MC::IntList IDs;
272  MP::RecordPtrList Records;
274  MP::PacketPtrList Packets;
275 };
276 
278 struct MPMissingPackets : public MSData
279 {
281 
282 
284  virtual ~MPMissingPackets() { };
285 
287  MA::IntIntSortedMap IDTimestampMap;
288 };
289 
291 struct MPRecoveredPackets : public MSData
292 {
294 
295 
297  virtual ~MPRecoveredPackets() { };
298 
300  MC::IntList RecordIDs;
301 };
302 
304 struct MPStreamMarkers : public MSData
305 {
307 
308 
309  MPStreamMarkers();
310  virtual ~MPStreamMarkers() { };
311 
313  MA::IntIntSortedMap TimestampColorMap;
314 };
315 
317 struct MPTimestampList : public MSData, public MC::IntList
318 {
320 
321 
322  MPTimestampList();
323  virtual ~MPTimestampList() { };
324 };
325 
MP::PacketPtr Packet
Packet pointer.
Definition: MPTypes.hpp:207
Missing records struct.
Definition: MPTypes.hpp:278
MC::IntList RecordIDs
IDs of the recovered records.
Definition: MPTypes.hpp:297
Collected data with portable storage functions.
Timestamp list struct.
Definition: MPTypes.hpp:317
MP::RobotStatePtr RobotState
Stored robot state.
Definition: MPTypes.hpp:197
MP::ImagePtr Image
Stored image.
Definition: MPTypes.hpp:201
Binary data class.
Log entry map struct.
Definition: MPTypes.hpp:164
Recovered records struct.
Definition: MPTypes.hpp:291
int ID
Record ID.
Definition: MPTypes.hpp:195
MC::BinaryDataSPtr RobotStateBinaryData
Stored robot state binary data.
Definition: MPTypes.hpp:199
MCBinaryData * MPDecodeImage(const MCBinaryData &binary_data)
Decode a jpeg image from AIBO.
Definition: MPTypes.cpp:49
MP::PacketPtrList Packets
Packet list.
Definition: MPTypes.hpp:274
MC::IntList IDs
ID list.
Definition: MPTypes.hpp:270
MP::RecordPtrList Records
Record list.
Definition: MPTypes.hpp:272
MC::BinaryDataSPtr SoundData
Stored sound data.
Definition: MPTypes.hpp:205
QJsonObject * MPConvertCollectedDataToJsonQuery(MACollectedData &collected_data)
Convert the collected data in JSON object for query.
Definition: MPTypes.cpp:73
Image.
Definition: MEImage.hpp:112
QJsonObject * MPConvertCollectedDataToJson(MACollectedData &collected_data)
Convert the collected data in JSON object.
Definition: MPTypes.cpp:60
Records container struct.
Definition: MPTypes.hpp:211
Stream markers struct.
Definition: MPTypes.hpp:304
MA::IntIntSortedMap TimestampColorMap
Timestamp-color map.
Definition: MPTypes.hpp:310
Definition: MPContext.hpp:37
static std::string RobotStateVariableMap
Cached variable map for robot state decoding.
Definition: MPTypes.hpp:266
Base class for the data exchange of the elements.
Definition: MSData.hpp:54
MA::IntIntSortedMap IDTimestampMap
ID-timestamp map.
Definition: MPTypes.hpp:284
MP::LogMessagesPtr LogMessages
Stored log messages.
Definition: MPTypes.hpp:203
Robot state record struct.
Definition: MPTypes.hpp:187
#define MSDATA_FUNCTIONS(data_class_name)
MSData macro to declare the copy assignment operator in the descendants.
Definition: MSData.hpp:35
Robot state.
Cursor position struct.
Definition: MPTypes.hpp:174
MACollectedData * MPConvertJsonToCollectedData(QJsonObject &json_object)
Convert a JSON object back to collected data.
Definition: MPTypes.cpp:87