25 #ifndef INCLUDED_ClientInterface_h_GUID_A3A55368_DE2F_4980_BAE9_1C398B0D40A1 26 #define INCLUDED_ClientInterface_h_GUID_A3A55368_DE2F_4980_BAE9_1C398B0D40A1 29 #include <osvr/Common/Export.h> 38 #include <osvr/Util/ClientCallbackTypesC.h> 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.
Definition: ReportTraits.h:83
void update()
Update any state.
Definition: ClientInterface.cpp:45
Class to maintain state for an interface for each report (and thus state) type explicitly enumerated...
Definition: InterfaceState.h:66
Header declaring opaque types used by Client and ClientKit.
boost::any & data()
Access the type-erased data for this interface.
Definition: ClientInterface.h:129
OSVR_COMMON_EXPORT OSVR_ClientInterfaceObject(osvr::common::ClientContext &ctx, std::string const &path)
Constructor - only to be called by a factory function.
Definition: ClientInterface.cpp:35
OSVR_COMMON_EXPORT std::string const & getPath() const
Get the path as a string.
Definition: ClientInterface.cpp:41
Type predicate: Whether callbacks of a report type should store state for that type.
Definition: ReportStateTraits.h:42
void triggerCallbacks(const OSVR_TimeValue ×tamp, ReportType const &report)
Trigger all callbacks for the given known report type.
Definition: ClientInterface.h:111
void getState(util::time::TimeValue ×tamp, traits::StateFromReport_t< ReportType > &state) const
Definition: InterfaceState.h:86
Definition: ClientContext.h:50
std::size_t getNumCallbacksFor(ReportType const &r) const
Get the number of registered callbacks for the given report type.
Definition: ClientInterface.h:118
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
Definition: TimeValueC.h:81
Definition: ClientInterface.h:49
Class to maintain callbacks for an interface for each report type explicitly enumerated.
Definition: InterfaceCallbacks.h:57
void setState(const OSVR_TimeValue ×tamp, ReportType const &report)
Set saved state for a report type.
Definition: ClientInterface.h:90