25 #ifndef INCLUDED_InternalInterfaceOwner_h_GUID_CE168C67_29A8_44A4_44E4_BCE428AF71EB 26 #define INCLUDED_InternalInterfaceOwner_h_GUID_CE168C67_29A8_44A4_44E4_BCE428AF71EB 34 #include <boost/assert.hpp> 53 : m_ctx(ctx), m_iface(iface) {
61 : m_ctx(ctx), m_iface(iface.get()), m_owningIface(iface) {
69 m_iface = m_owningIface.get();
82 : m_ctx(
std::move(other.m_ctx)),
83 m_owningIface(
std::move(other.m_owningIface)) {
84 std::swap(m_iface, other.m_iface);
94 std::swap(m_ctx, other.m_ctx);
95 std::swap(m_iface, other.m_iface);
96 m_owningIface = std::move(other.m_owningIface);
103 typedef contained_type *
pointer;
106 explicit operator bool()
const {
return nullptr != m_iface; }
110 reference operator*()
const {
return *m_iface; }
111 pointer operator->()
const {
return m_iface; }
119 if (m_ctx && m_iface) {
121 BOOST_ASSERT_MSG(oldIface,
"We should never be the last one " 122 "holding a reference to this " 126 m_owningIface.reset();
131 void m_checkInvariants()
const {
133 (!m_iface || (m_iface && m_ctx)),
134 "If we have an interface, we must have a context.");
135 BOOST_ASSERT_MSG(!m_owningIface || (m_owningIface.get() == m_iface),
136 "Either owningIface should be empty or the same " 137 "as our raw pointer.");
147 #endif // INCLUDED_InternalInterfaceOwner_h_GUID_CE168C67_29A8_44A4_44E4_BCE428AF71EB shared_ptr< ClientInterface > ClientInterfacePtr
Pointer for holding ClientInterface objects safely.
Definition: ClientInterfacePtr.h:43
Header declaring opaque types used by Client and ClientKit.
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
InternalInterfaceOwner & operator=(InternalInterfaceOwner const &)=delete
non-assignable
Definition: TypeSafeIdHash.h:44
InternalInterfaceOwner & operator=(InternalInterfaceOwner &&other)
move-assignable
Definition: InternalInterfaceOwner.h:89
Class that should be used for all internally-used client interface objects as it handles ownership wi...
Definition: InternalInterfaceOwner.h:45
InternalInterfaceOwner(InternalInterfaceOwner &&other)
move constructible
Definition: InternalInterfaceOwner.h:81
OSVR_COMMON_EXPORT osvr::common::ClientInterfacePtr getInterface(const char path[])
Creates an interface object for the given path.
Definition: ClientContext.cpp:94
OSVR_COMMON_EXPORT osvr::common::ClientInterfacePtr releaseInterface(osvr::common::ClientInterface *iface)
Searches through this context to determine if the passed interface object has been retained...
Definition: ClientContext.cpp:105
InternalInterfaceOwner(common::ClientContext *ctx, OSVR_ClientInterface iface)
Constructor.
Definition: InternalInterfaceOwner.h:51
InternalInterfaceOwner()
Empty constructor.
Definition: InternalInterfaceOwner.h:48
~InternalInterfaceOwner()
Destructor - frees interface.
Definition: InternalInterfaceOwner.h:115
Definition: ClientContext.h:50
InternalInterfaceOwner(common::ClientContext *ctx, common::ClientInterfacePtr const &iface)
Constructor that keeps an additional reference to the interface.
Definition: InternalInterfaceOwner.h:59
InternalInterfaceOwner(common::ClientContext *ctx, const char path[])
Constructor from a context and path.
Definition: InternalInterfaceOwner.h:66
Definition: ClientInterface.h:49