OSVR-Core
DeviceComponent.h
Go to the documentation of this file.
1 
11 // Copyright 2015 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_DeviceComponent_h_GUID_FC172255_F4F1_41A2_ABA5_E5E33F8BD005
26 #define INCLUDED_DeviceComponent_h_GUID_FC172255_F4F1_41A2_ABA5_E5E33F8BD005
27 
28 // Internal Includes
33 
34 // Library/third-party includes
35 // - none
36 
37 // Standard includes
38 // - none
39 
40 namespace osvr {
41 namespace common {
43  public:
44  typedef BaseDevice Parent;
45 
48  void recordParent(Parent &dev);
49 
51  void update();
52 
53  protected:
56 
58  bool m_hasParent() const;
59 
61  Parent &m_getParent();
62 
69  void m_registerHandler(vrpn_MESSAGEHANDLER handler, void *userdata,
70  RawMessageType const &msgType);
71 
73  virtual void m_parentSet() = 0;
74 
77  virtual void m_update();
78 
79  private:
80  Parent *m_parent;
81  MessageHandlerList<BaseDeviceMessageHandleTraits> m_messageHandlers;
82  };
83 } // namespace common
84 } // namespace osvr
85 #endif // INCLUDED_DeviceComponent_h_GUID_FC172255_F4F1_41A2_ABA5_E5E33F8BD005
Handles spatial transformations.
Definition: SerializationTraitExample_Complicated.h:40
Class used as an interface for underlying devices that can have device components (corresponding to i...
Definition: BaseDevice.h:51
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
void m_registerHandler(vrpn_MESSAGEHANDLER handler, void *userdata, RawMessageType const &msgType)
Registers a handler whose lifetime is tied to the lifetime of the component.
Definition: DeviceComponent.cpp:54
virtual void m_update()
Implementation-specific (optional) stuff to do during mainloop.
Definition: DeviceComponent.cpp:62
Definition: DeviceComponent.h:42
bool m_hasParent() const
Returns true if we have a parent registered.
Definition: DeviceComponent.cpp:48
virtual void m_parentSet()=0
Called once when we have a parent.
Parent & m_getParent()
Gets the parent - only call if m_hasParent() is true.
Definition: DeviceComponent.cpp:50
void recordParent(Parent &dev)
Called (only) by BaseDevice when being added: effectively records a "parent pointer" that does not co...
Definition: DeviceComponent.cpp:39
Type-safe wrapper with built-in default for a VRPN "message type" integer.
Definition: RawMessageType.h:45
void update()
Called during mainloop.
Definition: DeviceComponent.cpp:46
DeviceComponent()
Protected constructor, to require subclassing.
Definition: DeviceComponent.cpp:37