OSVR-Core
Interface.h
Go to the documentation of this file.
1 
12 // Copyright 2014 Sensics, Inc.
13 //
14 // Licensed under the Apache License, Version 2.0 (the "License");
15 // you may not use this file except in compliance with the License.
16 // You may obtain a copy of the License at
17 //
18 // http://www.apache.org/licenses/LICENSE-2.0
19 //
20 // Unless required by applicable law or agreed to in writing, software
21 // distributed under the License is distributed on an "AS IS" BASIS,
22 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 // See the License for the specific language governing permissions and
24 // limitations under the License.
25 
26 #ifndef INCLUDED_Interface_h_GUID_5D5B1FAD_AD72_4216_9FB6_6483D6EE7DF1
27 #define INCLUDED_Interface_h_GUID_5D5B1FAD_AD72_4216_9FB6_6483D6EE7DF1
28 
29 // Internal Includes
34 #include <osvr/Util/ReportTypesX.h>
35 
36 // Library/third-party includes
37 #include <boost/function.hpp>
38 
39 // Standard includes
40 // - none
41 
42 namespace osvr {
43 
44 namespace clientkit {
45 
47  : m_ctx(&ctx), m_interface(iface) {}
48 
49  inline Interface::Interface() : m_ctx(NULL), m_interface(NULL) {}
50 
51  inline bool Interface::notEmpty() const {
52  return m_ctx != NULL && m_interface != NULL;
53  }
54 
55  inline OSVR_ClientInterface Interface::get() { return m_interface; }
56 
57  inline ClientContext &Interface::getContext() { return *m_ctx; }
58 
59  inline void Interface::free() {
60  m_deletables.clear();
61  m_ctx->free(*this);
62  m_ctx = NULL;
63  m_interface = NULL;
64  }
65 
66  inline void
68  m_deletables.push_back(obj);
69  }
70 
71 #define OSVR_X(TYPE) \
72  inline void Interface::registerCallback(OSVR_##TYPE##Callback cb, \
73  void *userdata) { \
74  osvrRegister##TYPE##Callback(m_interface, cb, userdata); \
75  }
76  OSVR_INVOKE_REPORT_TYPES_XMACRO()
77 #undef OSVR_X
78 
79 } // end namespace clientkit
80 
81 } // end namespace osvr
82 
83 #endif // INCLUDED_Interface_h_GUID_5D5B1FAD_AD72_4216_9FB6_6483D6EE7DF1
Client context object: Create and keep one in your application.
Definition: Context_decl.h:57
void free()
Manually free the interface before the context is closed.
Definition: Interface.h:59
::boost::shared_ptr< Deletable > DeletablePtr
Shared-ownership smart pointer to a Deletable, using Boost&#39;s shared pointers.
Definition: BoostDeletable.h:42
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
Interface()
Empty constructor.
Definition: Interface.h:49
void free(Interface &iface)
Frees an interface before it would normally be freed (at context close).
Definition: Context.h:104
bool notEmpty() const
Determine if this interface object is empty (that is, was it once initialized).
Definition: Interface.h:51
Header containing the class declaration for Interface, but not its inline implementation.
OSVR_ClientInterface get()
Get the raw OSVR_ClientInterface from this wrapper.
Definition: Interface.h:55
Header.
Definition: ClientInterface.h:49
ClientContext & getContext()
Get the associated ClientContext.
Definition: Interface.h:57
void takeOwnership(util::boost_util::DeletablePtr const &obj)
Take (shared) ownership of some Deletable object.
Definition: Interface.h:67