Overte C++ Documentation
JSEndpoint.h
1 //
2 // Created by Bradley Austin Davis 2015/10/23
3 // Copyright 2015 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 #pragma once
10 #ifndef hifi_Controllers_JSEndpoint_h
11 #define hifi_Controllers_JSEndpoint_h
12 
13 #include "../Endpoint.h"
14 
15 #include <QtQml/QJSValue>
16 #include <QtQml/QJSValueList>
17 
18 namespace controller {
19 
20 class JSEndpoint : public Endpoint {
21 public:
22  static std::shared_ptr<Endpoint> newEndpoint(const QJSValue& callable) {
23  return std::shared_ptr<Endpoint>(new JSEndpoint(callable));
24  };
25 
26  using Endpoint::apply;
27  virtual AxisValue peek() const override;
28  virtual void apply(AxisValue newValue, const Pointer& source) override;
29 
30 private:
31  JSEndpoint(const QJSValue& callable)
32  : Endpoint(Input::INVALID_INPUT), _callable(callable) {
33  }
34 
35  mutable QJSValue _callable;
36 };
37 
38 }
39 
40 #endif