1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003 VideoLAN
5 * $Id: var_manager.cpp,v 1.3 2004/01/24 13:08:12 asmax Exp $
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
8 * Olivier Teulière <ipkiss@via.ecp.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 #include "var_manager.hpp"
28 VarManager::VarManager( intf_thread_t *pIntf ): SkinObject( pIntf ),
29 m_tooltipText( pIntf ), m_helpText( pIntf )
34 VarManager::~VarManager()
36 // Delete the variables in the reverse order they were added
37 list<string>::const_iterator it;
38 for( it = m_varList.begin(); it != m_varList.end(); it++ )
45 VarManager *VarManager::instance( intf_thread_t *pIntf )
47 if( ! pIntf->p_sys->p_varManager )
49 VarManager *pVarManager;
50 pVarManager = new VarManager( pIntf );
53 pIntf->p_sys->p_varManager = pVarManager;
56 return pIntf->p_sys->p_varManager;
60 void VarManager::destroy( intf_thread_t *pIntf )
62 if( pIntf->p_sys->p_varManager )
64 delete pIntf->p_sys->p_varManager;
65 pIntf->p_sys->p_varManager = NULL;
70 void VarManager::registerVar( const VariablePtr &rcVar, const string &rName )
72 m_varMap[rName] = rcVar;
73 m_varList.push_front(rName);
77 Variable *VarManager::getVar( const string &rName )
79 if( m_varMap.find( rName ) != m_varMap.end() )
81 return m_varMap[rName].get();
90 Variable *VarManager::getVar( const string &rName, const string &rType )
92 if( m_varMap.find( rName ) != m_varMap.end() )
94 Variable *pVar = m_varMap[rName].get();
95 // Check the variable type
96 if( pVar->getType() != rType )
98 msg_Warn( getIntf(), "Variable %s has incorrect type (%s instead"
99 " of (%s)", rName.c_str(), pVar->getType().c_str(),