25 #ifndef INCLUDED_BaseDevice_h_GUID_52C0B784_DB20_4FA6_0C87_47FB116DA61B 26 #define INCLUDED_BaseDevice_h_GUID_52C0B784_DB20_4FA6_0C87_47FB116DA61B 29 #include <osvr/Common/Export.h> 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(
142 buf.
size(), buf.
data(), msgType, timestamp,
145 template <
typename T>
152 template <
typename T,
typename ClassOfService>
153 inline void BaseDevice::packMessage(
159 packMessage(buf, msgType, t, classOfService);
162 template <
typename T>
163 inline void BaseDevice::packMessage(
Buffer<T> const &buf,
170 #endif // INCLUDED_BaseDevice_h_GUID_52C0B784_DB20_4FA6_0C87_47FB116DA61B Handles spatial transformations.
Definition: SerializationTraitExample_Complicated.h:40
Definition: NetworkClassOfService.h:134
Class used as an interface for underlying devices that can have device components (corresponding to i...
Definition: BaseDevice.h:51
void getNow(TimeValue &tv)
Set the given TimeValue to the current time.
Definition: TimeValue.h:51
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
T * addComponent(shared_ptr< T > component)
Adds a component to a base device.
Definition: BaseDevice.h:58
CRTP base for classes of service, useful for accepting classes of service for an argument without let...
Definition: NetworkClassOfService.h:81
size_t size() const
Gets the current size, in bytes.
Definition: Buffer.h:282
CRTP class template wrapping message-specific data and/or logic.
Definition: MessageRegistration.h:44
virtual void m_update()=0
Implementation-specific update (call client_mainloop() or server_mainloop() in it!) ...
OSVR_COMMON_EXPORT BaseDevice()
Constructor.
Definition: BaseDevice.cpp:41
A buffer of bytes, built on a byte-vector-like container.
Definition: Buffer.h:206
OSVR_COMMON_EXPORT void sendPending()
Called from a component to send pending messages instead of waiting for next time.
Definition: BaseDevice.cpp:86
OSVR_COMMON_EXPORT void m_setup(vrpn_ConnectionPtr conn, RawSenderType sender, std::string const &name)
Should be called by derived class to set the connection, etc.
Definition: BaseDevice.cpp:106
Association of class of service types with integral constants.
Definition: NetworkClassOfService.h:95
OSVR_COMMON_EXPORT void update()
Called from the outside to run the mainloop on the device and its components.
Definition: BaseDevice.cpp:79
vrpn_ConnectionPtr m_getConnection() const
Accessor for underlying connection.
Definition: BaseDevice.cpp:113
Header providing a C++ wrapper around TimeValueC.h.
Type-safe wrapper with built-in default for a VRPN "message type" integer.
Definition: RawMessageType.h:45
virtual OSVR_COMMON_EXPORT ~BaseDevice()
Virtual destructor.
Definition: BaseDevice.cpp:42
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
Definition: TimeValueC.h:81
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...
Definition: BaseDevice.h:72
ElementType const * data() const
Provides access to the underlying data.
Definition: Buffer.h:288
Type-safe wrapper with built-in default for a VRPN "sender type" integer.
Definition: RawSenderType.h:45