00001 /*************************************************************************** 00002 * Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> * 00003 * * 00004 * This file is part of the FreeCAD CAx development system. * 00005 * * 00006 * This library is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Library General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2 of the License, or (at your option) any later version. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00014 * GNU Library General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Library General Public * 00017 * License along with this library; see the file COPYING.LIB. If not, * 00018 * write to the Free Software Foundation, Inc., 59 Temple Place, * 00019 * Suite 330, Boston, MA 02111-1307, USA * 00020 * * 00021 ***************************************************************************/ 00022 00023 00024 #include "PreCompiled.h" 00025 00026 #include "WorkbenchFactory.h" 00027 #include "Workbench.h" 00028 00029 using namespace Gui; 00030 00031 Gui::WorkbenchFactoryInst* Gui::WorkbenchFactoryInst::_pcSingleton = 0; 00032 00033 WorkbenchFactoryInst& WorkbenchFactoryInst::instance() 00034 { 00035 if (_pcSingleton == 0L) 00036 _pcSingleton = new WorkbenchFactoryInst; 00037 return *_pcSingleton; 00038 } 00039 00040 void WorkbenchFactoryInst::destruct () 00041 { 00042 if ( _pcSingleton != 0 ) 00043 delete _pcSingleton; 00044 _pcSingleton = 0; 00045 } 00046 00047 Workbench* WorkbenchFactoryInst::createWorkbench ( const char* sName ) const 00048 { 00049 Workbench* obj = (Workbench*)Produce( sName ); 00050 Workbench* w = dynamic_cast<Workbench*>(obj); 00051 if ( !w ) 00052 { 00053 delete obj; // delete the unknown object as no workbench object 00054 return 0; 00055 } 00056 00057 w->setName( sName ); 00058 return w; 00059 } 00060 00061 std::list<std::string> WorkbenchFactoryInst::workbenches() const 00062 { 00063 std::list<std::string> wb; 00064 for (std::map<const std::string, Base::AbstractProducer*>::const_iterator 00065 it = _mpcProducers.begin(); it != _mpcProducers.end(); ++it) 00066 wb.push_back(it->first); 00067 return wb; 00068 }