00001 /*---------------------------------------------------------------------------*\ 00002 * OpenSG * 00003 * * 00004 * * 00005 * Copyright (C) 2000-2002 by the OpenSG Forum * 00006 * * 00007 * www.opensg.org * 00008 * * 00009 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de * 00010 * * 00011 \*---------------------------------------------------------------------------*/ 00012 /*---------------------------------------------------------------------------*\ 00013 * License * 00014 * * 00015 * This library is free software; you can redistribute it and/or modify it * 00016 * under the terms of the GNU Library General Public License as published * 00017 * by the Free Software Foundation, version 2. * 00018 * * 00019 * This library is distributed in the hope that it will be useful, but * 00020 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00022 * Library General Public License for more details. * 00023 * * 00024 * You should have received a copy of the GNU Library General Public * 00025 * License along with this library; if not, write to the Free Software * 00026 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00027 * * 00028 \*---------------------------------------------------------------------------*/ 00029 /*---------------------------------------------------------------------------*\ 00030 * Changes * 00031 * * 00032 * * 00033 * * 00034 * * 00035 * * 00036 * * 00037 \*---------------------------------------------------------------------------*/ 00038 00039 //--------------------------------------------------------------------------- 00040 // Includes 00041 //--------------------------------------------------------------------------- 00042 00043 #include <stdlib.h> 00044 #include <stdio.h> 00045 00046 #include "OSGConfig.h" 00047 #include "OSGLog.h" 00048 #include "OSGConnection.h" 00049 #include "OSGConnectionType.h" 00050 #include "OSGConnectionFactory.h" 00051 00052 OSG_USING_NAMESPACE 00053 00054 ConnectionFactory *ConnectionFactory::_the=NULL; 00055 00079 /*-------------------------------------------------------------------------*/ 00080 /* Constructors */ 00081 00084 ConnectionFactory::ConnectionFactory(void) : 00085 _groupMap(), 00086 _pointMap() 00087 { 00088 } 00089 00090 /*-------------------------------------------------------------------------*/ 00091 /* Destructor */ 00092 00095 ConnectionFactory::~ConnectionFactory(void) 00096 { 00097 } 00098 00099 /*-------------------------------------------------------------------------*/ 00100 /* public interface */ 00101 00104 GroupConnection *ConnectionFactory::createGroup(const std::string &name) 00105 { 00106 TypeMap::iterator i=_groupMap.find(name); 00107 if(i == _groupMap.end()) 00108 return NULL; 00109 else 00110 return i->second->createGroup(); 00111 } 00112 00115 PointConnection *ConnectionFactory::createPoint(const std::string &name) 00116 { 00117 TypeMap::iterator i=_pointMap.find(name); 00118 if(i == _pointMap.end()) 00119 return NULL; 00120 else 00121 return i->second->createPoint(); 00122 } 00123 00126 ConnectionFactory &ConnectionFactory::the(void) 00127 { 00128 if(_the == NULL) 00129 _the=new ConnectionFactory(); 00130 return *_the; 00131 } 00132 00133 /*-------------------------------------------------------------------------*/ 00134 /* protected interface */ 00135 00138 void ConnectionFactory::addGroupType(ConnectionType *type) 00139 { 00140 _groupMap[type->getName()]=type; 00141 SINFO << "Group Connection type " << type->getName() << " added" << std::endl; 00142 } 00143 00146 void ConnectionFactory::addPointType(ConnectionType *type) 00147 { 00148 _pointMap[type->getName()]=type; 00149 SINFO << "Point Connection type " << type->getName() << " added" << std::endl; 00150 } 00151 00154 void ConnectionFactory::subPointType(ConnectionType *type) 00155 { 00156 TypeMap::iterator i=_pointMap.find(type->getName()); 00157 if(i != _pointMap.end() && i->second == type) 00158 _pointMap.erase(i); 00159 SINFO << "Point connection type " << type->getName() 00160 << " removed" << std::endl; 00161 } 00162 00165 void ConnectionFactory::subGroupType(ConnectionType *type) 00166 { 00167 TypeMap::iterator i=_groupMap.find(type->getName()); 00168 if(i != _groupMap.end() && i->second == type) 00169 _groupMap.erase(i); 00170 SINFO << "Group connection type " << type->getName() 00171 << " removed" << std::endl; 00172 } 00173 00174 /*-------------------------------------------------------------------------*/ 00175 /* cvs id's */ 00176 00177 #ifdef __sgi 00178 #pragma set woff 1174 00179 #endif 00180 00181 #ifdef OSG_LINUX_ICC 00182 #pragma warning( disable : 177 ) 00183 #endif 00184 00185 namespace 00186 { 00187 static Char8 cvsid_cpp[] = "@(#)$Id:$"; 00188 static Char8 cvsid_hpp[] = OSG_CONNECTIONFACTORYHEADER_CVSID; 00189 } 00190 00191 00192 00193 00194 00195 00196 00197
1.4.3