25 #ifndef INCLUDED_ContextImpl_h_GUID_9000C62E_3693_4888_83A2_0D26F4591B6A
26 #define INCLUDED_ContextImpl_h_GUID_9000C62E_3693_4888_83A2_0D26F4591B6A
42 #include <boost/noncopyable.hpp>
43 #include <boost/any.hpp>
52 typedef std::vector<osvr::common::ClientInterfacePtr> InterfaceList;
57 OSVR_COMMON_EXPORT
void update();
80 InterfaceList
const &getInterfaces()
const {
return m_interfaces; }
83 OSVR_COMMON_EXPORT
void sendRoute(std::string
const &route);
86 OSVR_COMMON_EXPORT std::string
95 return m_ownedObjects.
acquire(obj);
109 OSVR_COMMON_EXPORT
void
113 OSVR_COMMON_EXPORT osvr::common::ClientContextDeleter
getDeleter()
const;
117 OSVR_COMMON_EXPORT
bool getStatus()
const;
120 OSVR_COMMON_EXPORT
void log(osvr::util::log::LogLevel severity,
121 const char *message);
124 OSVR_COMMON_EXPORT osvr::util::log::LoggerPtr
const &
logger()
const;
130 osvr::common::ClientContextDeleter del);
136 osvr::common::ClientContextDeleter del);
139 virtual void m_update() = 0;
140 virtual void m_sendRoute(std::string
const &route) = 0;
141 OSVR_COMMON_EXPORT
virtual bool m_getStatus()
const;
144 OSVR_COMMON_EXPORT
virtual void
148 OSVR_COMMON_EXPORT
virtual void
153 m_getPathTree()
const = 0;
158 m_getRoomToWorldTransform()
const = 0;
165 std::string
const m_appId;
166 InterfaceList m_interfaces;
170 osvr::common::ClientContextDeleter m_deleter;
173 osvr::util::log::LoggerPtr m_logger;
175 osvr::util::log::LoggerPtr m_clientLogger;
195 template <
typename T>
197 T *o =
static_cast<T *
>(obj);
205 template <
typename T = ClientContext>
207 using ClientContextSharedPtr = shared_ptr<ClientContext>;
212 template <
typename T,
typename... Args>
214 return new T(std::forward<Args>(args)..., &detail::context_deleter<T>);
219 template <
typename T>
227 #endif // INCLUDED_ContextImpl_h_GUID_9000C62E_3693_4888_83A2_0D26F4591B6A
bool getStatus() const
Returns true if we are started up and fully connected (path tree received, etc.)
unique_ptr< T, ClientContextDeleter > ClientContextUniquePtr
Template alias for a ClientContext unique_ptr with the correct deleter class.
shared_ptr< ClientInterface > ClientInterfacePtr
Pointer for holding ClientInterface objects safely.
void * acquire(T ptr)
Adds an object held by a smart pointer to our ownership, returning its void * usable to release it be...
std::string getStringParameter(std::string const &path) const
Gets a string parameter value.
A tree representation, with path/url syntax, of the known OSVR system.
osvr::common::Transform const & getRoomToWorldTransform() const
Gets the transform from room space to world space.
void sendRoute(std::string const &route)
Sends a JSON route/transform object to the server.
Header to bring unique_ptr into the osvr namespace.
Header to bring shared_ptr into the osvr namespace.
osvr::common::ClientInterfacePtr getInterface(const char path[])
Creates an interface object for the given path. The context retains shared ownership.
osvr::common::ClientInterfacePtr releaseInterface(osvr::common::ClientInterface *iface)
Searches through this context to determine if the passed interface object has been retained...
std::string const & getAppId() const
Accessor for app ID.
Holds on to smart pointers by value, and lets you free them by providing the corresponding void *...
void setRoomToWorldTransform(osvr::common::Transform const &xform)
Sets the transform from room space to world space.
void * acquireObject(T obj)
Pass (smart-pointer) ownership of some object to the client context.
Deleter for use with std::unique_ptr.
ClientContextSharedPtr wrapSharedContext(T *context)
Wrap a client context pointer in a shared pointer with the correct custom deleter.
OSVR_ClientContextObject(const char appId[], osvr::common::ClientContextDeleter del)
Constructor for derived class use only.
bool releaseObject(void *obj)
Frees some object whose lifetime is controlled by the client context.
osvr::common::PathTree const & getPathTree() const
Accessor for the path tree.
virtual ~OSVR_ClientContextObject()
Destructor.
void log(osvr::util::log::LogLevel severity, const char *message)
Logs a message from the client.
std::function< ClientInterfacePtr(ClientContext &, const char[])> ClientInterfaceFactory
A factory function type taking the client context and path, and returning a ClientInterfacePtr. The ClientContext will handle notifying its internals about the new interface before returning it.
Header to include for OSVR-internal usage of the logging mechanism: provides the needed definition of...
Automatically-generated export header - do not edit!
osvr::util::log::LoggerPtr const & logger() const
Provides logger access for related internal classes.
void deleteContext(ClientContext *ctx)
Use the stored deleter to appropriately delete the client context.
T * makeContext(Args...args)
Create a subclass object of ClientContext, setting the deleter appropriately by passing it as the las...
void update()
System-wide update method.
osvr::common::ClientContextDeleter getDeleter() const
Returns the specialized deleter for this object.