OSVR-Core
RemoteHandlerInternals.h
Go to the documentation of this file.
1 
11 // Copyright 2015 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_RemoteHandlerInternals_h_GUID_20139712_D173_4D91_A995_2552DF68354A
26 #define INCLUDED_RemoteHandlerInternals_h_GUID_20139712_D173_4D91_A995_2552DF68354A
27 
28 // Internal Includes
31 
32 // Library/third-party includes
33 // - none
34 
35 // Standard includes
36 // - none
37 
38 namespace osvr {
39 namespace client {
45  public:
47  explicit RemoteHandlerInternals(common::InterfaceList &ifaces)
48  : m_interfaces(ifaces) {}
49 
50  // non-assignable
51  RemoteHandlerInternals &operator=(RemoteHandlerInternals &) = delete;
52 
54  template <typename ReportType>
56  ReportType const &report) {
57  static_assert(
59  "Should only call a state setter if we're keeping state for "
60  "this report type!");
61 
63  [&timestamp, &report](common::ClientInterface &iface) {
64  iface.setState(timestamp, report);
65  iface.triggerCallbacks(timestamp, report);
66  });
67  }
68 
71  template <typename F> void forEachInterface(F &&f) {
73  for (auto &iface : m_interfaces) {
76  pin = iface;
77  f(*pin);
78  }
79  }
80 
81  private:
82  common::InterfaceList &m_interfaces;
83  };
84 } // namespace client
85 } // namespace osvr
86 #endif // INCLUDED_RemoteHandlerInternals_h_GUID_20139712_D173_4D91_A995_2552DF68354A
shared_ptr< ClientInterface > ClientInterfacePtr
Pointer for holding ClientInterface objects safely.
Definition: ClientInterfacePtr.h:43
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
void forEachInterface(F &&f)
Do something with every client interface object, if the above options don&#39;t suit your needs...
Definition: RemoteHandlerInternals.h:71
Type predicate: Whether callbacks of a report type should store state for that type.
Definition: ReportStateTraits.h:42
void triggerCallbacks(const OSVR_TimeValue &timestamp, ReportType const &report)
Trigger all callbacks for the given known report type.
Definition: ClientInterface.h:111
void setStateAndTriggerCallbacks(const OSVR_TimeValue &timestamp, ReportType const &report)
Set state and call callbacks for a report type.
Definition: RemoteHandlerInternals.h:55
RemoteHandlerInternals(common::InterfaceList &ifaces)
Construct with a reference to an interface list.
Definition: RemoteHandlerInternals.h:47
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
Definition: TimeValueC.h:81
Definition: ClientInterface.h:49
Class holding shared implementation between the various handlers.
Definition: RemoteHandlerInternals.h:44
void setState(const OSVR_TimeValue &timestamp, ReportType const &report)
Set saved state for a report type.
Definition: ClientInterface.h:90