Overte C++ Documentation
InputRecorder.h
1 //
2 // Created by Dante Ruiz on 2017/04/16
3 // Copyright 2017 High Fidelity, Inc.
4 //
5 // Distributed under the Apache License, Version 2.0.
6 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 //
8 
9 #ifndef hifi_InputRecorder_h
10 #define hifi_InputRecorder_h
11 
12 #include <mutex>
13 #include <atomic>
14 #include <vector>
15 #include <map>
16 
17 #include <QString>
18 #include <QJsonObject>
19 
20 #include "Pose.h"
21 #include "Actions.h"
22 
23 namespace controller {
24  class InputRecorder {
25  public:
26  using PoseStates = std::map<QString, Pose>;
27  using ActionStates = std::map<QString, float>;
28 
29  InputRecorder();
30  ~InputRecorder();
31 
32  static InputRecorder* getInstance();
33 
34  void saveRecording();
35  void loadRecording(const QString& path);
36  void startRecording();
37  void startPlayback();
38  void stopPlayback();
39  void stopRecording();
40  void toggleRecording() { _recording = !_recording; }
41  void togglePlayback() { _playback = !_playback; }
42  void resetFrame();
43  bool isRecording() { return _recording; }
44  bool isPlayingback() { return (_playback && !_loading); }
45  void setActionState(const QString& action, float value);
46  void setActionState(const QString& action, const controller::Pose& pose);
47  float getActionState(const QString& action);
48  ActionStates getActionstates();
49  controller::Pose getPoseState(const QString& action);
50  QString getSaveDirectory();
51  void frameTick();
52  private:
53  QJsonObject recordDataToJson();
54  bool _recording { false };
55  bool _playback { false };
56  bool _loading { false };
57  std::vector<PoseStates> _poseStateList = std::vector<PoseStates>();
58  std::vector<ActionStates> _actionStateList = std::vector<ActionStates>();
59  PoseStates _currentFramePoses;
60  ActionStates _currentFrameActions;
61 
62  int _framesRecorded { 0 };
63  int _playCount { 0 };
64  };
65 }
66 #endif