25 #ifndef INCLUDED_ClientInterface_h_GUID_A3A55368_DE2F_4980_BAE9_1C398B0D40A1
26 #define INCLUDED_ClientInterface_h_GUID_A3A55368_DE2F_4980_BAE9_1C398B0D40A1
41 #include <boost/noncopyable.hpp>
42 #include <boost/any.hpp>
55 std::string
const &path);
58 ~OSVR_ClientInterfaceObject() {
59 osvr::common::tracing::markReleaseInterface(m_path);
63 OSVR_COMMON_EXPORT std::string
const &
getPath()
const;
70 template <
typename ReportType>
74 osvr::common::tracing::markGetState(m_path);
75 if (!m_state.hasState<ReportType>()) {
78 m_state.
getState<ReportType>(timestamp, state);
82 template <
typename ReportType>
bool hasStateForReportType()
const {
83 return m_state.hasState<ReportType>();
86 bool hasAnyState()
const {
return m_state.hasAnyState(); }
89 template <
typename ReportType>
93 "Should only call setState if we're keeping state for this report "
95 m_state.setStateFromReport(timestamp, report);
103 template <
typename CallbackType>
104 void registerCallback(CallbackType cb,
void *userdata) {
105 m_callbacks.addCallback(cb, userdata);
110 template <
typename ReportType>
112 ReportType
const &report) {
113 m_callbacks.triggerCallbacks(timestamp, report);
117 template <
typename ReportType>
119 return m_callbacks.getNumCallbacksFor(r);
129 boost::any &
data() {
return m_data; }
133 std::string
const m_path;
139 #endif // INCLUDED_ClientInterface_h_GUID_A3A55368_DE2F_4980_BAE9_1C398B0D40A1
typepack::t_< StateType< T >> StateFromReport_t
Alias for the StateType associated with a given ReportType.
void update()
Update any state.
Class to maintain state for an interface for each report (and thus state) type explicitly enumerated...
Header declaring opaque types used by Client and ClientKit.
void getState(util::time::TimeValue ×tamp, traits::StateFromReport_t< ReportType > &state) const
boost::any & data()
Access the type-erased data for this interface.
std::size_t getNumCallbacksFor(ReportType const &r) const
Get the number of registered callbacks for the given report type.
OSVR_ClientInterfaceObject(osvr::common::ClientContext &ctx, std::string const &path)
Constructor - only to be called by a factory function.
Type predicate: Whether callbacks of a report type should store state for that type.
void triggerCallbacks(const OSVR_TimeValue ×tamp, ReportType const &report)
Trigger all callbacks for the given known report type.
Automatically-generated export header - do not edit!
std::string const & getPath() const
Get the path as a string.
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
Class to maintain callbacks for an interface for each report type explicitly enumerated.
void setState(const OSVR_TimeValue ×tamp, ReportType const &report)
Set saved state for a report type.