25 #ifndef INCLUDED_BaseDevice_h_GUID_52C0B784_DB20_4FA6_0C87_47FB116DA61B
26 #define INCLUDED_BaseDevice_h_GUID_52C0B784_DB20_4FA6_0C87_47FB116DA61B
40 #include <vrpn_ConnectionPtr.h>
41 #include <vrpn_Connection.h>
59 T *ret = component.get();
60 m_addComponent(component);
64 void registerHandler(vrpn_MESSAGEHANDLER handler,
void *userdata,
66 void unregisterHandler(vrpn_MESSAGEHANDLER handler,
void *userdata,
73 messageReg.setMessageType(m_registerMessageType(T::identifier()));
80 OSVR_COMMON_EXPORT
void update();
86 template <
typename T,
typename ClassOfService>
96 template <
typename T,
typename ClassOfService>
101 template <
typename T>
104 std::string
const &getDeviceName()
const;
110 OSVR_COMMON_EXPORT
void m_setup(vrpn_ConnectionPtr conn,
112 std::string
const &name);
124 OSVR_COMMON_EXPORT
void m_addComponent(DeviceComponentPtr component);
126 void m_packMessage(
size_t len,
const char *buf,
129 uint32_t classOfService);
130 DeviceComponentList m_components;
131 vrpn_ConnectionPtr m_conn;
136 template <
typename T,
typename ClassOfService>
137 inline void BaseDevice::packMessage(
138 Buffer<T>
const &buf, RawMessageType
const &msgType,
140 class_of_service::ClassOfServiceBase<ClassOfService>
const &) {
142 buf.size(), buf.data(), msgType, timestamp,
143 class_of_service::VRPNConnectionValue<ClassOfService>::value);
145 template <
typename T>
147 BaseDevice::packMessage(Buffer<T>
const &buf, RawMessageType
const &msgType,
149 packMessage(buf, msgType, timestamp, class_of_service::Reliable());
152 template <
typename T,
typename ClassOfService>
153 inline void BaseDevice::packMessage(
154 Buffer<T>
const &buf, RawMessageType
const &msgType,
155 class_of_service::ClassOfServiceBase<ClassOfService>
const &
159 packMessage(buf, msgType, t, classOfService);
162 template <
typename T>
163 inline void BaseDevice::packMessage(Buffer<T>
const &buf,
164 RawMessageType
const &msgType) {
165 packMessage(buf, msgType, class_of_service::Reliable());
170 #endif // INCLUDED_BaseDevice_h_GUID_52C0B784_DB20_4FA6_0C87_47FB116DA61B
Class used as an interface for underlying devices that can have device components (corresponding to i...
void getNow(TimeValue &tv)
Set the given TimeValue to the current time.
vrpn_ConnectionPtr m_getConnection() const
Accessor for underlying connection.
T * addComponent(shared_ptr< T > component)
Adds a component to a base device.
CRTP base for classes of service, useful for accepting classes of service for an argument without let...
::OSVR_TimeValue TimeValue
C++-friendly typedef for the OSVR_TimeValue structure.
CRTP class template wrapping message-specific data and/or logic.
virtual void m_update()=0
Implementation-specific update (call client_mainloop() or server_mainloop() in it!) ...
A buffer of bytes, built on a byte-vector-like container. Provides methods for easily appending to th...
void sendPending()
Called from a component to send pending messages instead of waiting for next time.
void m_setup(vrpn_ConnectionPtr conn, RawSenderType sender, std::string const &name)
Should be called by derived class to set the connection, etc.
void update()
Called from the outside to run the mainloop on the device and its components.
Header providing a C++ wrapper around TimeValueC.h.
Automatically-generated export header - do not edit!
Type-safe wrapper with built-in default for a VRPN "message type" integer.
virtual ~BaseDevice()
Virtual destructor.
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
Header defining buffer types, with optional alignment dependent on Boost version. ...
void registerMessageType(MessageRegistration< T > &messageReg)
Call with a MessageRegistration object, and the message type will be registered and stored in the typ...
Type-safe wrapper with built-in default for a VRPN "sender type" integer.