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 #ifndef _OSGMPBASE_H_ 00040 #define _OSGMPBASE_H_ 00041 #ifdef __sgi 00042 #pragma once 00043 #endif 00044 00045 #include <OSGBase.h> 00046 #include <OSGBaseTypes.h> 00047 #include <OSGTypeBase.h> 00048 #include <OSGMemoryObject.h> 00049 00050 OSG_BEGIN_NAMESPACE 00051 00052 class MPBase; 00053 class BaseThread; 00054 class Barrier; 00055 class Lock; 00056 class LockPool; 00057 00058 typedef BaseThread *(*CreateThreadF )(const Char8 *szName, 00059 UInt32 uiId); 00060 typedef Barrier *(*CreateBarrierF )(const Char8 *szName, 00061 UInt32 uiId); 00062 typedef Lock *(*CreateLockF )(const Char8 *szName, 00063 UInt32 uiId); 00064 typedef LockPool *(*CreateLockPoolF)(const Char8 *szName, 00065 UInt32 uiId); 00066 typedef void (*InitThreadingF) (void); 00067 00068 //--------------------------------------------------------------------------- 00069 // Class 00070 //--------------------------------------------------------------------------- 00071 00075 class OSG_BASE_DLLMAPPING MPType : public TypeBase 00076 { 00077 /*========================== PUBLIC =================================*/ 00078 00079 public : 00080 00081 /*---------------------------------------------------------------------*/ 00085 MPType(const Char8 *szName, 00086 const Char8 *szParentName); 00087 00089 /*---------------------------------------------------------------------*/ 00093 virtual ~MPType(void); 00094 00096 /*========================= PROTECTED ===============================*/ 00097 00098 protected: 00099 00100 typedef TypeBase Inherited; 00101 00102 /*========================== PRIVATE ================================*/ 00103 00104 private: 00105 00107 MPType(const MPType &source); 00109 void operator =(const MPType &source); 00110 }; 00111 00112 00113 00114 00115 //--------------------------------------------------------------------------- 00116 // Class 00117 //--------------------------------------------------------------------------- 00118 00122 class OSG_BASE_DLLMAPPING MPThreadType : public MPType 00123 { 00124 /*========================== PUBLIC =================================*/ 00125 00126 public : 00127 00128 /*---------------------------------------------------------------------*/ 00132 MPThreadType(const Char8 *szName, 00133 const Char8 *szParentName, 00134 CreateThreadF fCreateThread, 00135 InitThreadingF fInitThreading); 00136 00138 /*---------------------------------------------------------------------*/ 00142 virtual ~MPThreadType(void); 00143 00145 /*---------------------------------------------------------------------*/ 00149 BaseThread *create(const Char8 *szName); 00150 00152 /*========================= PROTECTED ===============================*/ 00153 00154 protected: 00155 00156 typedef MPType Inherited; 00157 00158 /*---------------------------------------------------------------------*/ 00162 static UInt32 _uiThreadCount; 00163 CreateThreadF _fCreateThread; 00164 00166 /*========================== PRIVATE ================================*/ 00167 00168 private: 00169 00171 MPThreadType(const MPThreadType &source); 00173 void operator =(const MPThreadType &source); 00174 }; 00175 00176 00177 00178 00179 //--------------------------------------------------------------------------- 00180 // Class 00181 //--------------------------------------------------------------------------- 00182 00186 class OSG_BASE_DLLMAPPING MPBarrierType : public MPType 00187 { 00188 /*========================== PUBLIC =================================*/ 00189 00190 public : 00191 00192 /*---------------------------------------------------------------------*/ 00196 MPBarrierType(const Char8 *szName, 00197 const Char8 *szParentName, 00198 CreateBarrierF fCreateBarrier); 00199 00201 /*---------------------------------------------------------------------*/ 00205 virtual ~MPBarrierType(void); 00206 00208 /*---------------------------------------------------------------------*/ 00212 Barrier *create(const Char8 *szName); 00213 00215 /*========================= PROTECTED ===============================*/ 00216 00217 protected: 00218 00219 typedef MPType Inherited; 00220 00221 /*---------------------------------------------------------------------*/ 00225 static UInt32 _uiBarrierCount; 00226 CreateBarrierF _fCreateBarrier; 00227 00229 /*========================== PRIVATE ================================*/ 00230 00231 private: 00232 00234 MPBarrierType(const MPBarrierType &source); 00236 void operator =(const MPBarrierType &source); 00237 }; 00238 00239 00240 00241 00242 //--------------------------------------------------------------------------- 00243 // Class 00244 //--------------------------------------------------------------------------- 00245 00249 class OSG_BASE_DLLMAPPING MPLockType : public MPType 00250 { 00251 /*========================== PUBLIC =================================*/ 00252 00253 public : 00254 00255 /*---------------------------------------------------------------------*/ 00259 MPLockType(const Char8 *szName, 00260 const Char8 *szParentName, 00261 CreateLockF fCreateLock); 00262 00264 /*---------------------------------------------------------------------*/ 00268 virtual ~MPLockType(void); 00269 00271 /*---------------------------------------------------------------------*/ 00275 Lock *create(const Char8 *szName); 00276 00278 /*========================= PROTECTED ===============================*/ 00279 protected: 00280 00281 typedef MPType Inherited; 00282 00283 /*---------------------------------------------------------------------*/ 00287 static UInt32 _uiLockCount; 00288 CreateLockF _fCreateLock; 00289 00291 /*========================== PRIVATE ================================*/ 00292 00293 private: 00294 00296 MPLockType(const MPLockType &source); 00298 void operator =(const MPLockType &source); 00299 }; 00300 00301 00302 00303 00304 //--------------------------------------------------------------------------- 00305 // Class 00306 //--------------------------------------------------------------------------- 00307 00309 00310 class OSG_BASE_DLLMAPPING MPLockPoolType : public MPType 00311 { 00312 /*========================== PUBLIC =================================*/ 00313 00314 public : 00315 00316 /*---------------------------------------------------------------------*/ 00320 MPLockPoolType(const Char8 *szName, 00321 const Char8 *szParentName, 00322 CreateLockPoolF fCreateLockPool); 00323 00325 /*---------------------------------------------------------------------*/ 00329 virtual ~MPLockPoolType(void); 00330 00332 /*---------------------------------------------------------------------*/ 00336 LockPool *create(const Char8 *szName); 00337 00339 /*========================= PROTECTED ===============================*/ 00340 00341 protected: 00342 00343 typedef MPType Inherited; 00344 00345 /*---------------------------------------------------------------------*/ 00349 static UInt32 _uiLockPoolCount; 00350 CreateLockPoolF _fCreateLockPool; 00351 00353 /*========================== PRIVATE ================================*/ 00354 00355 private: 00356 00358 MPLockPoolType(const MPLockPoolType &source); 00360 void operator =(const MPLockPoolType &source); 00361 }; 00362 00363 00364 00365 00366 //--------------------------------------------------------------------------- 00367 // Class 00368 //--------------------------------------------------------------------------- 00369 00371 00372 class OSG_BASE_DLLMAPPING MPBase : public MemoryObject 00373 { 00374 /*========================== PUBLIC =================================*/ 00375 public : 00376 00377 /*---------------------------------------------------------------------*/ 00381 static const MPType &getStaticType (void); 00382 static UInt32 getStaticTypeId(void); 00383 00385 /*---------------------------------------------------------------------*/ 00389 virtual MPType &getType (void); 00390 virtual const MPType &getType (void) const; 00391 UInt32 getTypeId(void); 00392 const Char8 *getCName (void) const; 00393 00395 /*========================= PROTECTED ===============================*/ 00396 00397 protected: 00398 00399 typedef MemoryObject Inherited; 00400 00401 /*---------------------------------------------------------------------*/ 00405 static MPType _type; 00406 Char8 *_szName; 00407 00409 /*---------------------------------------------------------------------*/ 00413 MPBase(const Char8 *szName); 00414 00416 /*---------------------------------------------------------------------*/ 00420 virtual ~MPBase(void); 00421 00423 /*========================== PRIVATE ================================*/ 00424 00425 private: 00426 00428 MPBase(const MPBase &source); 00430 void operator =(const MPBase &source); 00431 }; 00432 00433 OSG_END_NAMESPACE 00434 00435 #define OSGMPBASE_HEADER_CVSID "@(#)$Id: $" 00436 00437 #endif /* _OSGMPBASE_H_ */
1.4.3