Main Page · Modules · All Classes · Class Hierarchy
MPSessionMemory.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 "MPTypes.hpp"
25 
26 #include <MSElement.hpp>
27 
28 #include <boost/scoped_ptr.hpp>
29 #include <boost/serialization/access.hpp>
30 
31 class MCBinaryData;
32 class MCDataStorage;
33 
41 {
43  int Min;
45  int Max;
47  float Magnitude;
49  QString DisplayName;
51  MP::FloatList Values;
52 };
53 
54 namespace MP
55 {
57 typedef QMap<QString, MPVariableDescriptor> VariableMap;
58 }
59 
63 class MPSessionMemory : public MSElement
64 {
65  Q_OBJECT
66 
67  friend class boost::serialization::access;
68 
69 public:
71  explicit MPSessionMemory(const QString& session_directory = "");
73  virtual ~MPSessionMemory();
74 
75  std::string GetVariableMapStr() const;
76  QString GetSessionDirectory() const;
77  void SetSessionDirectory(const QString& directory);
78  void SyncQueryCache();
79  void OptimizeQueryCache();
80  MCBinaryData* Encode();
81  static MPSessionMemory* Decode(const MCBinaryData& data);
82  static QString GetSessionCacheFileName(const QString& directory);
83  static MPSessionMemory* Load(const QString& directory, bool only_cache = false);
84  void SaveToFile(const QString& file_name);
85  void EnableAnsiToQtMarkup();
86  bool IsAnsiConvertedToQtMarkup();
87  int GetMinCursorPosition();
88  int GetMaxCursorPosition();
89  int GetFirstSecond();
90  int GetLastSecond();
91  int GetCursorPosition();
92  const MP::LogEntryMap& GetFullAiboLog();
93  const MA::IntIntSortedMap& GetStreamMarkers();
94  QStringList GetVariableMap();
95  const MPVariableDescriptor* GetVariableDescriptor(const QString& variable_name);
96  MC::IntList GetMissingTimestamps();
97  MCBinaryData* GetAiboImage(int milliseconds);
98  MARobotState* GetRobotState(int milliseconds);
99  MP::RobotStatePtrList GetRobotStates();
100  MP::RobotStatePtrList GetRobotStates(int start_time, int end_time);
101  MC::BinaryDataSPtr GetAudioData(int start_time, int end_time);
102  MA::BinaryDataSPtrList GetRobotStatesData(int start_time, int end_time);
103  void GetStateTimeSerie(const QString& variable, int start, int end,
104  MP::DoubleList& times, MP::DoubleList& serie, int upscale_value = 0);
105  bool IsMissingDataInRange(int StartTime, int EndTime);
106  MP::DoubleTable GetSamples(const QString& variable, const QString& log_start, const QString& log_end,
107  MP::BooleanList& validity);
108  MP::DoubleTable GetValidSamples(const QString& variable, const QString& log_start,
109  const QString& log_end);
110  MP::RobotStatePtrTable GetRobotStates(const QString& log_start, const QString& log_end,
111  MP::BooleanList& validity);
112  MP::RobotStatePtrTable GetValidRobotStates(const QString& log_start, const QString& log_end);
113 
114 public Q_SLOTS:
115  void SetCursorPosition(int milliseconds);
116  void IncrementCursor();
117  void DecrementCursor();
118 
119 Q_SIGNALS:
120  void FirstRobotStatesArrived();
121 
122 private:
123  virtual bool ProgressTasks(bool be_hurry) override;
124 
125  template<class Archive>
126  void serialize(Archive& archive, const unsigned int version);
127 
133  boost::scoped_ptr<MCDataStorage> CacheStorage;
149  MA::IntIntSortedMap StreamMarkers;
151  QStringList VariableMap;
153  std::string VariableMapStr;
155  MP::IntList RobotStateTimestamps;
157  MP::BinaryDataList ImageCache;
159  MP::BinaryDataList RobotStateCache;
161  MP::VariableMap VariableCache;
163  MP::LogEntryMap LogCache;
165  MP::BinaryDataList SoundDataCache;
178 };
179 
Missing records struct.
Definition: MPTypes.hpp:278
Timestamp list struct.
Definition: MPTypes.hpp:317
MPRecoveredPackets InputRecoveredPackets
Input variable of the recovered packets.
MPTimestampList NewMissingTimestamps
New missing timestamps.
MP::LogEntryMap LogCache
Log cache.
MPStreamMarkers NewStreamMarkers
New stream markers.
MPCursorPosition NewCursorPosition
New cursor position.
MP::BinaryDataList RobotStateCache
Robot state cache.
bool ConvertAnsiToQtMarkup
Whenever the log messages should be converted from Ansi to Qt markup.
Binary data class.
MA::IntIntSortedMap StreamMarkers
Stream markers.
Log entry map struct.
Definition: MPTypes.hpp:164
Recovered records struct.
Definition: MPTypes.hpp:291
MP::VariableMap VariableCache
Robot state variable cache.
Basic ancestor class of the elements.
Definition: MSElement.hpp:65
QString DisplayName
Display name.
std::string VariableMapStr
Variable map string for robot state decoding.
MP::IntList RobotStateTimestamps
Robot state timestamp list.
float Magnitude
Magnitude.
boost::scoped_ptr< MCDataStorage > CacheStorage
Query cache data storage.
int CursorPosition
Cursor position (in milliseconds)
MPMissingPackets MissingPackets
Missing packets.
Data storage with file support.
Records container struct.
Definition: MPTypes.hpp:211
MPMissingPackets InputMissingPackets
Input variable of the missing packets.
MPRecordsContainer InputStates
Input variable.
QStringList VariableMap
Variable map.
Stream markers struct.
Definition: MPTypes.hpp:304
MPTimestampList NewRecoveredTimestamps
New recovered timestamps.
QString SessionDirectory
Session directory.
Session memory element.
Definition: MPContext.hpp:37
MP::BinaryDataList ImageCache
Image cache.
int LastCursorPosition
Last cursor position (in milliseconds)
MP::BinaryDataList SoundDataCache
Sound data cache.
QString QueryCacheFileName
Query cache file name.
Support struct to store MANum<int> data in smaller place.
MP::FloatList Values
Values.
MPLogEntryMap NewLogEntries
New log entries.
bool CursorPositionChanged
Whenever the cursor position has been changed.
Robot state.
Cursor position struct.
Definition: MPTypes.hpp:174