Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGMPBase.cpp

Go to the documentation of this file.
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 #include <stdlib.h>
00040 #include <stdio.h>
00041 
00042 #include "OSGConfig.h"
00043 
00044 #include <iostream>
00045 
00046 #include "OSGMPBase.h"
00047 #include <OSGTypeFactory.h>
00048 #include <OSGBaseFunctions.h>
00049 #include <OSGThreadManager.h>
00050 
00051 OSG_USING_NAMESPACE
00052 
00053 //---------------------------------------------------------------------------
00054 //  Class
00055 //---------------------------------------------------------------------------
00056 
00060 MPType::MPType(const Char8 *szName, 
00061                const Char8 *szParentName) :
00062     Inherited(szName, szParentName)
00063 {
00064 }
00065 
00066 
00067 MPType::~MPType(void)
00068 {
00069 }
00070 
00071 
00072 
00073 
00074 //---------------------------------------------------------------------------
00075 //  Class
00076 //---------------------------------------------------------------------------
00077 
00081 UInt32 MPThreadType::_uiThreadCount = 0;
00082 
00083 
00084 MPThreadType::MPThreadType(const Char8          *szName, 
00085                            const Char8          *szParentName,
00086                                  CreateThreadF   fCreateThread,
00087                                  InitThreadingF  fInitThreading) :
00088      Inherited    (szName, szParentName),
00089     _fCreateThread(fCreateThread       )
00090 {
00091     ThreadManager::the()->registerThreadType(this);
00092 
00093     if(fInitThreading != NULL)
00094         fInitThreading();
00095 }
00096 
00097 
00098 MPThreadType::~MPThreadType(void)
00099 {
00100 }
00101 
00102 
00103 BaseThread *MPThreadType::create(const Char8 *szName)
00104 {
00105     Char8  *szTmp;
00106     UInt32  uiNewId = _uiThreadCount++;
00107 
00108     if(szName == NULL)
00109     {
00110         szTmp = new Char8[16];
00111         sprintf(szTmp, "OSGThread_%u", uiNewId);
00112     }
00113     else
00114     {
00115         szTmp = const_cast<Char8 *>(szName);
00116     }
00117 
00118     if(_fCreateThread != NULL)
00119         return _fCreateThread(szTmp, uiNewId);
00120     else
00121         return NULL;
00122 }
00123 
00124 
00125 
00126 
00127 //---------------------------------------------------------------------------
00128 //  Class
00129 //---------------------------------------------------------------------------
00130 
00134 UInt32 MPBarrierType::_uiBarrierCount = 0;
00135 
00136 
00137 MPBarrierType::MPBarrierType(const Char8          *szName, 
00138                              const Char8          *szParentName,
00139                                    CreateBarrierF  fCreateBarrier) :
00140      Inherited     (szName, szParentName),
00141     _fCreateBarrier(fCreateBarrier      )
00142 {
00143     ThreadManager::the()->registerBarrierType(this);
00144 }
00145 
00146 
00147 MPBarrierType::~MPBarrierType(void)
00148 {
00149 }
00150 
00151 
00152 Barrier *MPBarrierType::create(const Char8 *szName)
00153 {
00154     UInt32 uiNewId = _uiBarrierCount++;
00155 
00156     if(_fCreateBarrier != NULL)
00157         return _fCreateBarrier(szName, uiNewId);
00158     else
00159         return NULL;
00160 }
00161 
00162 
00163 
00164 
00165 //---------------------------------------------------------------------------
00166 //  Class
00167 //---------------------------------------------------------------------------
00168 
00172 UInt32 MPLockType::_uiLockCount = 0;
00173 
00174 
00175 MPLockType::MPLockType(const Char8       *szName, 
00176                        const Char8       *szParentName,
00177                              CreateLockF  fCreateLock) :
00178      Inherited(szName, szParentName),
00179     _fCreateLock(fCreateLock       )
00180 {
00181     ThreadManager::the()->registerLockType(this);
00182 }
00183 
00184 
00185 MPLockType::~MPLockType(void)
00186 {
00187 }
00188 
00189 
00190 Lock *MPLockType::create(const Char8 *szName)
00191 {
00192     UInt32 uiNewId = _uiLockCount++;
00193 
00194     if(_fCreateLock != NULL)
00195         return _fCreateLock(szName, uiNewId);
00196     else
00197         return NULL;
00198 }
00199 
00200 
00201 
00202 
00203 //---------------------------------------------------------------------------
00204 //  Class
00205 //---------------------------------------------------------------------------
00206 
00210 UInt32 MPLockPoolType::_uiLockPoolCount = 0;
00211 
00212 
00213 MPLockPoolType::MPLockPoolType(
00214     const Char8           *szName, 
00215     const Char8           *szParentName,
00216           CreateLockPoolF  fCreateLockPool) :
00217 
00218      Inherited      (szName, szParentName),
00219     _fCreateLockPool(fCreateLockPool     )
00220 {
00221     ThreadManager::the()->registerLockPoolType(this);
00222 }
00223 
00224 
00225 MPLockPoolType::~MPLockPoolType(void)
00226 {
00227 }
00228 
00229 
00230 LockPool *MPLockPoolType::create(const Char8 *szName)
00231 {
00232     UInt32 uiNewId = _uiLockPoolCount++;
00233 
00234     if(_fCreateLockPool != NULL)
00235         return _fCreateLockPool(szName, uiNewId);
00236     else
00237         return NULL;
00238 }
00239 
00240 
00241 
00242 
00243 //---------------------------------------------------------------------------
00244 //  Class
00245 //---------------------------------------------------------------------------
00246 
00250 MPType MPBase::_type("OSGMPBase", NULL);
00251 
00252 
00253 const MPType &MPBase::getStaticType(void)
00254 {
00255     return _type;
00256 }
00257 
00258 
00259 UInt32 MPBase::getStaticTypeId(void)
00260 {
00261     return 0;
00262 }
00263 
00264 
00265 MPType &MPBase::getType(void)
00266 {
00267     return _type;
00268 }
00269 
00270 
00271 const MPType &MPBase::getType(void) const
00272 {
00273     return _type;
00274 }
00275 
00276 
00277 UInt32 MPBase::getTypeId(void)
00278 {
00279     return getType().getId();
00280 }
00281 
00282 
00283 const Char8 *MPBase::getCName(void) const
00284 {
00285     return _szName;
00286 }
00287 
00288 
00289 MPBase::MPBase(const Char8 *szName) :
00290      Inherited(    ),
00291     
00292     _szName   (NULL)
00293 {
00294     stringDup(szName, _szName);
00295 }
00296 
00297 
00298 MPBase::~MPBase(void)
00299 {
00300     delete [] _szName;
00301 }
00302 
00303 
00304 /*-------------------------------------------------------------------------*/
00305 /*                              cvs id's                                   */
00306 
00307 #ifdef __sgi
00308 #pragma set woff 1174
00309 #endif
00310 
00311 #ifdef OSG_LINUX_ICC
00312 #pragma warning( disable : 177 )
00313 #endif
00314 
00315 namespace 
00316 {
00317     static Char8 cvsid_cpp[] = "@(#)$Id: $";
00318     static Char8 cvsid_hpp[] = OSGMPBASE_HEADER_CVSID;
00319 }
00320 

Generated on Thu Aug 25 04:07:47 2005 for OpenSG by  doxygen 1.4.3