glc_contextmanager.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  This file is part of the GLC-lib library.
00004  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
00005  http://glc-lib.sourceforge.net
00006 
00007  GLC-lib is free software; you can redistribute it and/or modify
00008  it under the terms of the GNU Lesser General Public License as published by
00009  the Free Software Foundation; either version 3 of the License, or
00010  (at your option) any later version.
00011 
00012  GLC-lib is distributed in the hope that it will be useful,
00013  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  GNU Lesser General Public License for more details.
00016 
00017  You should have received a copy of the GNU Lesser General Public License
00018  along with GLC-lib; if not, write to the Free Software
00019  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021  *****************************************************************************/
00023 
00024 #include <QtDebug>
00025 
00026 #include "glc_contextmanager.h"
00027 #include "glc_state.h"
00028 
00029 GLC_ContextManager* GLC_ContextManager::m_pContextManager= NULL;
00030 
00031 GLC_ContextManager::GLC_ContextManager()
00032 : m_pCurrentContext(NULL)
00033 , m_SetOfContext()
00034 {
00035 
00036 
00037 }
00038 
00039 GLC_ContextManager::~GLC_ContextManager()
00040 {
00041 
00042 }
00043 
00045 // Get Functions
00047 GLC_ContextManager* GLC_ContextManager::instance()
00048 {
00049         if (NULL == m_pContextManager)
00050         {
00051                 m_pContextManager= new GLC_ContextManager();
00052         }
00053 
00054         return m_pContextManager;
00055 }
00056 
00057 GLC_Context* GLC_ContextManager::currentContext() const
00058 {
00059         return m_pCurrentContext;
00060 }
00061 
00063 // Set Functions
00065 void GLC_ContextManager::addContext(GLC_Context* pContext)
00066 {
00067         Q_ASSERT(!m_SetOfContext.contains(pContext));
00068         m_SetOfContext.insert(pContext);
00069 }
00070 
00071 void GLC_ContextManager::remove(GLC_Context* pContext)
00072 {
00073         Q_ASSERT(m_SetOfContext.contains(pContext));
00074         m_SetOfContext.remove(pContext);
00075         if (m_pCurrentContext == pContext)
00076         {
00077                 m_pCurrentContext= NULL;
00078         }
00079 }
00080 
00081 void GLC_ContextManager::setCurrent(GLC_Context* pContext)
00082 {
00083 
00084         Q_ASSERT((NULL == pContext) || m_SetOfContext.contains(pContext));
00085         m_pCurrentContext= pContext;
00086 }
00087 
00088 

SourceForge.net Logo

©2005-2011 Laurent Ribon