25 #ifndef INCLUDED_ContextImpl_h_GUID_9000C62E_3693_4888_83A2_0D26F4591B6A 26 #define INCLUDED_ContextImpl_h_GUID_9000C62E_3693_4888_83A2_0D26F4591B6A 29 #include <osvr/Common/Export.h> 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;
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>
221 ClientContextSharedPtr ret(context, &deleteContext);
227 #endif // INCLUDED_ContextImpl_h_GUID_9000C62E_3693_4888_83A2_0D26F4591B6A Handles spatial transformations.
Definition: SerializationTraitExample_Complicated.h:40
unique_ptr< T, ClientContextDeleter > ClientContextUniquePtr
Template alias for a ClientContext unique_ptr with the correct deleter class.
Definition: ClientContext.h:206
shared_ptr< ClientInterface > ClientInterfacePtr
Pointer for holding ClientInterface objects safely.
Definition: ClientInterfacePtr.h:43
void * acquire(T ptr)
Adds an object held by a smart pointer to our ownership, returning its void * usable to release it be...
Definition: KeyedOwnershipContainer.h:88
A tree representation, with path/url syntax, of the known OSVR system.
Definition: PathTree.h:43
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
OSVR_COMMON_EXPORT void sendRoute(std::string const &route)
Sends a JSON route/transform object to the server.
Definition: ClientContext.cpp:139
std::string const & getAppId() const
Accessor for app ID.
Definition: ClientContext.cpp:83
Header to bring unique_ptr into the osvr namespace.
OSVR_COMMON_EXPORT OSVR_ClientContextObject(const char appId[], osvr::common::ClientContextDeleter del)
Constructor for derived class use only.
Header to bring shared_ptr into the osvr namespace.
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
LogLevel
Log message severity levels.
Definition: LogLevel.h:45
Definition: newuoa.h:1888
OSVR_COMMON_EXPORT osvr::common::ClientContextDeleter getDeleter() const
Returns the specialized deleter for this object.
Definition: ClientContext.cpp:157
Holds on to smart pointers by value, and lets you free them by providing the corresponding void *...
Definition: KeyedOwnershipContainer.h:83
OSVR_COMMON_EXPORT void setRoomToWorldTransform(osvr::common::Transform const &xform)
Sets the transform from room space to world space.
Definition: ClientContext.cpp:152
void * acquireObject(T obj)
Pass (smart-pointer) ownership of some object to the client context.
Definition: ClientContext.h:94
Deleter for use with std::unique_ptr.
Definition: ClientContext.h:186
OSVR_COMMON_EXPORT osvr::util::log::LoggerPtr const & logger() const
Provides logger access for related internal classes.
Definition: ClientContext.cpp:69
ClientContextSharedPtr wrapSharedContext(T *context)
Wrap a client context pointer in a shared pointer with the correct custom deleter.
Definition: ClientContext.h:220
OSVR_COMMON_EXPORT bool releaseObject(void *obj)
Frees some object whose lifetime is controlled by the client context.
Definition: ClientContext.cpp:143
virtual OSVR_COMMON_EXPORT ~OSVR_ClientContextObject()
Destructor.
Definition: ClientContext.cpp:78
OSVR_COMMON_EXPORT void log(osvr::util::log::LogLevel severity, const char *message)
Logs a message from the client.
Definition: ClientContext.cpp:163
std::function< ClientInterfacePtr(ClientContext &, const char[])> ClientInterfaceFactory
A factory function type taking the client context and path, and returning a ClientInterfacePtr.
Definition: ClientInterfaceFactory.h:46
Definition: ClientContext.h:50
OSVR_COMMON_EXPORT bool getStatus() const
Returns true if we are started up and fully connected (path tree received, etc.)
Definition: ClientContext.cpp:161
Header to include for OSVR-internal usage of the logging mechanism: provides the needed definition of...
OSVR_COMMON_EXPORT void deleteContext(ClientContext *ctx)
Use the stored deleter to appropriately delete the client context.
Definition: ClientContext.cpp:44
OSVR_COMMON_EXPORT std::string getStringParameter(std::string const &path) const
Gets a string parameter value.
Definition: ClientContext.cpp:131
T * makeContext(Args... args)
Create a subclass object of ClientContext, setting the deleter appropriately by passing it as the las...
Definition: ClientContext.h:213
Definition: ClientInterface.h:49
OSVR_COMMON_EXPORT osvr::common::Transform const & getRoomToWorldTransform() const
Gets the transform from room space to world space.
Definition: ClientContext.cpp:148
OSVR_COMMON_EXPORT void update()
System-wide update method.
Definition: ClientContext.cpp:87
OSVR_COMMON_EXPORT osvr::common::PathTree const & getPathTree() const
Accessor for the path tree.
Definition: ClientContext.cpp:135