#ifndef ICONTEXTACCESSOR_H #define ICONTEXTACCESSOR_H #include #include #include "amkglapp.h" class IGraphicsDocument; class DummyContext { public: DummyContext(const IGraphicsDocument* doc, const QOpenGLContext* newContext) : m_doc(const_cast(doc)), m_newContext(const_cast(newContext)) { } IGraphicsDocument* getDocument() const { return m_doc; } QOpenGLContext* getOpenglContext() const { return m_newContext; } private: IGraphicsDocument* m_doc; QOpenGLContext* m_newContext; }; template class IContextAccessor { public: typedef QHash ContextCollection; typedef QHashIterator ContextCollectionIterator; virtual ~IContextAccessor(); /** * @brief Call this method when you add this renderer to * your graphics view and pass it your opengl context */ virtual void addedTo(const IGraphicsDocument *doc, const QOpenGLContext* newContext); /** * @brief Call this method when you remove this renderer from * your graphics view and pass it your opengl context */ virtual void removedFrom(const IGraphicsDocument* doc, const QOpenGLContext* newContext); /** * @brief Returns all contexts */ const typename IContextAccessor::ContextCollection& getContexts() const; /** * @brief Returns the current context */ RendererContextT* getCurrentContext() const; /** * @brief Returns the current document */ IGraphicsDocument* getCurrentDocument() const; private: QHash m_contexts; }; #include "icontextaccessor.hpp" #endif // ICONTEXTACCESSOR_H