OSVR-Core
GenericConnectionDevice.h
Go to the documentation of this file.
1 
11 // Copyright 2014 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_GenericConnectionDevice_h_GUID_411E730D_4ACA_4385_77C9_05A84863E786
26 #define INCLUDED_GenericConnectionDevice_h_GUID_411E730D_4ACA_4385_77C9_05A84863E786
27 
28 // Internal Includes
30 
31 #include <osvr/Util/ReturnCodesC.h>
32 
33 // Library/third-party includes
34 #include <boost/assert.hpp>
35 
36 // Standard includes
37 #include <functional>
38 
39 namespace osvr {
40 namespace connection {
43  public:
44  GenericConnectionDevice(std::string const &name,
45  std::function<OSVR_ReturnCode()> update)
46  : ConnectionDevice(name), m_update(update) {}
47 
48  GenericConnectionDevice(ConnectionDevice::NameList const &names,
49  std::function<OSVR_ReturnCode()> update)
50  : ConnectionDevice(names), m_update(update) {}
51 
52  virtual ~GenericConnectionDevice() {}
53  virtual void m_process() { m_update(); }
54  virtual void m_sendData(util::time::TimeValue const &, MessageType *,
55  const char *, size_t) {
56  BOOST_ASSERT_MSG(false, "Never called!");
57  }
58 
59  private:
60  std::function<OSVR_ReturnCode()> m_update;
61  };
62 } // namespace connection
63 } // namespace osvr
64 
65 #endif // INCLUDED_GenericConnectionDevice_h_GUID_411E730D_4ACA_4385_77C9_05A84863E786
Header declaring a type and values for simple C return codes.
virtual void m_process()
(Subclass implementation) Process messages.
Definition: GenericConnectionDevice.h:53
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
OSVR_CONNECTION_EXPORT ConnectionDevice(std::string const &name)
Constructor for use by derived classes only.
Definition: ConnectionDevice.cpp:48
virtual void m_sendData(util::time::TimeValue const &, MessageType *, const char *, size_t)
(Subclass implementation) Send message.
Definition: GenericConnectionDevice.h:54
Base class for connection-specific message type registration.
Definition: MessageType.h:38
Base class for connection-specific device data, owned by a DeviceToken.
Definition: ConnectionDevice.h:46
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
Definition: TimeValueC.h:81
ConnectionDevice implementation for advanced devices.
Definition: GenericConnectionDevice.h:42