Studierstube 4 Documentation Project

   Main Page       Modules       Class Hierarchy       Alphabetical List       Compound List       File List       Compound Members       Related Pages   

ComponentRetriever.cxx

Go to the documentation of this file.
00001 /* ========================================================================
00002 * Copyright (C) 2005  Graz University of Technology
00003 *
00004 * This framework is free software; you can redistribute it and/or modify
00005 * it under the terms of the GNU General Public License as published by
00006 * the Free Software Foundation; either version 2 of the License, or
00007 * (at your option) any later version.
00008 *
00009 * This framework is distributed in the hope that it will be useful,
00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 * GNU General Public License for more details.
00013 *
00014 * You should have received a copy of the GNU General Public License
00015 * along with this framework; if not, write to the Free Software
00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 *
00018 * For further information please contact Dieter Schmalstieg under
00019 * <schmalstieg@icg.tu-graz.ac.at> or write to Dieter Schmalstieg,
00020 * Graz University of Technology, Inffeldgasse 16a, A8010 Graz,
00021 * Austria.
00022 * ========================================================================
00023 * PROJECT: Studierstube
00024 * ======================================================================== */
00025 /* @author Denis Kalkofen
00026 *
00027 * $Id: ComponentRetriever.cxx 25 2005-11-28 16:11:59Z denis $
00028 * @file                                                                   */
00029 /* ======================================================================= */
00030 
00031 #include <cstring>
00032 #include <stb/kernel/ComponentRetriever.h>
00033 #include <stb/kernel/ComponentInfo.h>
00034 #include <stb/kernel/Kernel.h>
00035 #include <stb/base/OS.h>
00036 
00037 BEGIN_NAMESPACE_STB
00038 
00042 ComponentRetriever::ComponentRetriever()
00043 {
00044 
00045 }
00046 
00050 ComponentRetriever::~ComponentRetriever()
00051 {
00052 }
00053 
00054 Component* 
00055 ComponentRetriever::getComponent(ComponentInfo *compInfo)
00056 {
00058     stb::string libName=compInfo->getLibName();
00059 
00060 //FIX ME: we should remove the gui-binding from the kernel -denis
00061 //#ifdef STB_IS_WINDOWS
00062 //    if(libName=="stbviewer")
00063 //    {
00064 //        switch(stb::Kernel::getInstance()->scheduler->getCurrentGuiBinding())
00065 //        {
00066 //            case SOWIN::
00067 //                break;
00068 //
00069 //        }
00070 //       
00071 //    }
00072 //#endif
00074 
00075     char padding[4];
00076     Component* newComponent=NULL;
00077         if(libName=="")
00078                 return NULL;
00079         hModule libHandle;
00080         os_correctModuleName(libName, true,true);
00081 
00082     if (libName.size()<16) strcpy(padding,"\t\t\t");
00083     else strcpy(padding,"\t\t");
00084 
00085     logPrintS("Loading component %s %s \n", libName.c_str(), padding);
00086 
00087         libHandle = os_LoadLibrary(libName);
00088         if(!libHandle){
00089         logPrint("[ X ]\n");
00090                 logPrintE("  Couldn't load " + libName + "\n");
00091         return NULL;
00092         }
00093         compInfo->setHModule(libHandle);
00094         Component* (*createComponent)()=(Component*(*)())os_GetProcAddress(libHandle,"createComponent");
00095     if(!createComponent)
00096     {
00097         logPrint("[ X ]\n");
00098         logPrintE("  Can't find createComponent() in " + libName + "\n");
00099         return NULL;
00100     }
00101         newComponent=(*createComponent)();
00102     newComponent->setComponentInfo(compInfo);
00103     logPrint("[ OK ]\n");
00104     //logPrintI("  Component %s loaded\n", libName.c_str());
00105         return newComponent;
00106 }
00107 
00108 
00109 
00110 
00111 END_NAMESPACE_STB
 This page was generated at Wed Oct 27 13:00:08 2010 for Studierstube 4 by Doxygen.
 If you have any comments, please send a message to schmalstieg#icg.tu-graz.ac.at.
www.studierstube.org