25 #define OSVR_DEV_VERBOSE_DISABLE
33 #include <boost/assert.hpp>
48 void BaseDevice::m_addComponent(DeviceComponentPtr component) {
50 throw std::logic_error(
51 "Tried to add a null component pointer to a base device!");
53 m_components.push_back(component);
54 component->recordParent(*
this);
57 void BaseDevice::registerHandler(vrpn_MESSAGEHANDLER handler,
59 RawMessageType
const &msgType) {
64 void BaseDevice::unregisterHandler(vrpn_MESSAGEHANDLER handler,
66 RawMessageType
const &msgType) {
71 RawMessageType BaseDevice::m_registerMessageType(
const char *msgString) {
72 OSVR_DEV_VERBOSE(
"BaseDevice registering message type " << msgString);
73 return RawMessageType(
77 RawSenderType BaseDevice::getSender() {
return m_sender; }
80 for (
auto const &component : m_components) {
90 std::string
const &BaseDevice::getDeviceName()
const {
return m_name; }
92 void BaseDevice::m_packMessage(
size_t len,
const char *buf,
93 RawMessageType
const &msgType,
95 uint32_t classOfService) {
99 static_cast<uint32_t>(len), t, msgType.get(), getSender().
get(),
100 buf, classOfService);
102 throw std::runtime_error(
"Could not pack message!");
107 std::string
const &name) {
void toStructTimeval(struct timeval &dest, TimeValue const &src)
Convert a TimeValue to a struct timeval.
vrpn_ConnectionPtr m_getConnection() const
Accessor for underlying connection.
virtual void m_update()=0
Implementation-specific update (call client_mainloop() or server_mainloop() in it!) ...
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.
UnderlyingSenderType get() const
Gets the registered sender value or default.
Internal, configured header file for verbosity macros.
virtual ~BaseDevice()
Virtual destructor.
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
Type-safe wrapper with built-in default for a VRPN "sender type" integer.