OSVR-Core
ConnectionDevice.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_ConnectionDevice_h_GUID_C04223D7_51D1_49BE_91AB_73FCA9C88515
26 #define INCLUDED_ConnectionDevice_h_GUID_C04223D7_51D1_49BE_91AB_73FCA9C88515
27 
28 // Internal Includes
29 #include <osvr/Connection/Export.h>
33 #include <osvr/Util/TimeValue.h>
34 
35 // Library/third-party includes
36 #include <boost/noncopyable.hpp>
37 
38 // Standard includes
39 #include <string>
40 #include <vector>
41 
42 namespace osvr {
43 namespace connection {
46  class ConnectionDevice : boost::noncopyable {
47  public:
49  OSVR_CONNECTION_EXPORT virtual ~ConnectionDevice();
50 
51  typedef std::vector<std::string> NameList;
52 
54  OSVR_CONNECTION_EXPORT std::string const &getName() const;
55 
57  NameList const &getNames() const;
58 
62  void process();
63 
65  void sendData(util::time::TimeValue const &timestamp, MessageType *type,
66  const char *bytestream, size_t len);
67 
69  void setDeviceToken(DeviceToken &token);
70 
75  OSVR_CONNECTION_EXPORT void
76  setDeviceDescriptor(std::string const &jsonString);
77 
79  OSVR_CONNECTION_EXPORT std::string const &getDeviceDescriptor() const;
80 
81  protected:
84  bool m_hasDeviceToken() const;
89  virtual void m_process() = 0;
90 
92  virtual void m_sendData(util::time::TimeValue const &timestamp,
93  MessageType *type, const char *bytestream,
94  size_t len) = 0;
95 
97  OSVR_CONNECTION_EXPORT ConnectionDevice(std::string const &name);
98 
100  OSVR_CONNECTION_EXPORT ConnectionDevice(NameList const &names);
101 
102  private:
103  NameList m_names;
104  DeviceToken *m_token;
105  std::string m_descriptor;
106  };
107 } // namespace connection
108 } // namespace osvr
109 #endif // INCLUDED_ConnectionDevice_h_GUID_C04223D7_51D1_49BE_91AB_73FCA9C88515
Header forward declaring MessageType and specifying a smart pointer.
OSVR_CONNECTION_EXPORT void setDeviceDescriptor(std::string const &jsonString)
Send new/updated JSON device descriptor.
Definition: ConnectionDevice.cpp:68
A DeviceToken connects the generic device interaction code in PluginKit&#39;s C API with the workings of ...
Definition: DeviceToken.h:56
virtual void m_sendData(util::time::TimeValue const &timestamp, MessageType *type, const char *bytestream, size_t len)=0
(Subclass implementation) Send message.
Header forward-declaring ConnectionDevice and specifying the desired pointer to hold a ConnectionDevi...
bool m_hasDeviceToken() const
Does this connection device have a device token? Should be true in nearly every case.
Definition: ConnectionDevice.cpp:77
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
NameList const & getNames() const
accessor for device names
Definition: ConnectionDevice.cpp:44
DeviceToken & m_getDeviceToken()
accessor for device token
Definition: ConnectionDevice.cpp:81
Base class for connection-specific message type registration.
Definition: MessageType.h:38
virtual OSVR_CONNECTION_EXPORT ~ConnectionDevice()
destructor
Definition: ConnectionDevice.cpp:38
void setDeviceToken(DeviceToken &token)
For use only by DeviceToken.
Definition: ConnectionDevice.cpp:63
void process()
Process messages.
Definition: ConnectionDevice.cpp:54
OSVR_CONNECTION_EXPORT std::string const & getDeviceDescriptor() const
Get the most current JSON device descriptor.
Definition: ConnectionDevice.cpp:73
Base class for connection-specific device data, owned by a DeviceToken.
Definition: ConnectionDevice.h:46
Header providing a C++ wrapper around TimeValueC.h.
void sendData(util::time::TimeValue const &timestamp, MessageType *type, const char *bytestream, size_t len)
Send message (as primary device name)
Definition: ConnectionDevice.cpp:56
OSVR_CONNECTION_EXPORT std::string const & getName() const
accessor for (primary) device name
Definition: ConnectionDevice.cpp:40
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
Definition: TimeValueC.h:81
virtual void m_process()=0
(Subclass implementation) Process messages.