Overte C++ Documentation
StateController.h
1 //
2 // StateController.h
3 // controllers/src/controllers
4 //
5 // Created by Sam Gateau on 2015-10-27.
6 // Copyright 2015 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_StateController_h
13 #define hifi_StateController_h
14 
15 #include <QtCore/QObject>
16 #include <QtCore/QVector>
17 
18 #include "InputDevice.h"
19 
20 namespace controller {
21 
22 class StateController : public QObject, public InputDevice {
23  Q_OBJECT
24  Q_PROPERTY(QString name READ getName)
25 
26 public:
27  using Pointer = std::shared_ptr<StateController>;
28  using ReadLambda = std::function<float()>;
29  using NamedReadLambda = QPair<QString, ReadLambda>;
30 
31  static void setStateVariables(const QStringList& stateVariables);
32 
33  StateController();
34 
35  const QString& getName() const { return _name; }
36 
37  // Device functions
38  Input::NamedVector getAvailableInputs() const override;
39 
40  void setInputVariant(const QString& name, ReadLambda lambda);
41 
42  EndpointPointer createEndpoint(const Input& input) const override;
43 
44 protected:
45  QHash<QString, ReadLambda> _namedReadLambdas;
46 };
47 
48 }
49 
50 #endif // hifi_StateController_h