fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / Base / Threading / OSGMPBase.h
blobaed56e6de8a57ee87b6573a81392231cf3856366
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2003 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGMPBASE_H_
40 #define _OSGMPBASE_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGTypeBase.h"
46 #include "OSGMemoryObject.h"
47 #include "OSGBaseRefCountPolicies.h"
48 #include "OSGRefCountPtr.h"
49 #include "OSGTransitPtr.h"
50 #include "OSGStringUtils.h"
52 OSG_BEGIN_NAMESPACE
54 class MPBase;
55 class BaseThread;
56 class Barrier;
57 class CondVar;
58 class Lock;
59 class LockPool;
60 class Semaphore;
62 typedef BaseThread *(*CreateThreadF )(const Char8 *szName,
63 UInt32 uiId,
64 bool bGlobal);
65 typedef Barrier *(*CreateBarrierF )(const Char8 *szName,
66 UInt32 uiId,
67 bool bGlobal);
68 typedef CondVar *(*CreateCondVarF )(const Char8 *szName,
69 UInt32 uiId,
70 bool bGlobal);
71 typedef Lock *(*CreateLockF )(const Char8 *szName,
72 UInt32 uiId,
73 bool bGlobal);
74 typedef LockPool *(*CreateLockPoolF )(const Char8 *szName,
75 UInt32 uiId,
76 bool bGlobal);
77 typedef Semaphore *(*CreateSemaphoreF)(const Char8 *szName,
78 UInt32 uiId,
79 bool bGlobal);
80 typedef void (*InitThreadingF ) (void);
82 //---------------------------------------------------------------------------
83 // Class
84 //---------------------------------------------------------------------------
86 /*! \ingroup GrpBaseMultiThreading
87 \ingroup GrpLibOSGBase
90 class OSG_BASE_DLLMAPPING MPType : public TypeBase
92 /*========================== PRIVATE ================================*/
94 private:
96 /*========================== PUBLIC =================================*/
98 public :
100 /*---------------------------------------------------------------------*/
101 /*! \name Constructor */
102 /*! \{ */
104 MPType(const Char8 *szName,
105 const Char8 *szParentName,
106 const UInt32 uiNamespace = GlobalNamespace);
108 /*! \} */
109 /*---------------------------------------------------------------------*/
110 /*! \name Destructor */
111 /*! \{ */
113 virtual ~MPType(void);
115 /*! \} */
116 /*========================= PROTECTED ===============================*/
118 protected:
120 /*========================== PRIVATE ================================*/
122 typedef TypeBase Inherited;
124 private:
126 /*!\brief prohibit default function (move to 'public' if needed) */
127 MPType(const MPType &source);
128 /*!\brief prohibit default function (move to 'public' if needed) */
129 void operator =(const MPType &source);
135 //---------------------------------------------------------------------------
136 // Class
137 //---------------------------------------------------------------------------
139 /*! \ingroup GrpBaseMultiThreading
140 \ingroup GrpLibOSGBase
143 class OSG_BASE_DLLMAPPING MPThreadType : public MPType
145 /*========================== PRIVATE ================================*/
147 private:
149 /*========================== PUBLIC =================================*/
151 public :
153 /*---------------------------------------------------------------------*/
154 /*! \name Constructor */
155 /*! \{ */
157 MPThreadType(const Char8 *szName,
158 const Char8 *szParentName,
159 CreateThreadF fCreateThread,
160 InitThreadingF fInitThreading,
161 const UInt32 uiNamespace = GlobalNamespace);
163 /*! \} */
164 /*---------------------------------------------------------------------*/
165 /*! \name Destructor */
166 /*! \{ */
168 virtual ~MPThreadType(void);
170 /*! \} */
171 /*---------------------------------------------------------------------*/
172 /*! \name Construction */
173 /*! \{ */
175 BaseThread *create(const Char8 *szName, bool bGlobal);
177 /*! \} */
178 /*========================= PROTECTED ===============================*/
180 protected:
182 typedef MPType Inherited;
184 /*---------------------------------------------------------------------*/
185 /*! \name Class Specific */
186 /*! \{ */
188 static UInt32 _uiThreadCount;
189 CreateThreadF _fCreateThread;
191 /*! \} */
192 /*========================== PRIVATE ================================*/
194 private:
196 /*!\brief prohibit default function (move to 'public' if needed) */
197 MPThreadType(const MPThreadType &source);
198 /*!\brief prohibit default function (move to 'public' if needed) */
199 void operator =(const MPThreadType &source);
205 //---------------------------------------------------------------------------
206 // Class
207 //---------------------------------------------------------------------------
209 /*! \ingroup GrpBaseMultiThreading
210 \ingroup GrpLibOSGBase
213 class OSG_BASE_DLLMAPPING MPBarrierType : public MPType
215 /*========================== PRIVATE ================================*/
217 private:
219 /*========================== PUBLIC =================================*/
221 public :
223 /*---------------------------------------------------------------------*/
224 /*! \name Constructor */
225 /*! \{ */
227 MPBarrierType(const Char8 *szName,
228 const Char8 *szParentName,
229 CreateBarrierF fCreateBarrier,
230 const UInt32 uiNamespace = GlobalNamespace);
232 /*! \} */
233 /*---------------------------------------------------------------------*/
234 /*! \name Destructor */
235 /*! \{ */
237 virtual ~MPBarrierType(void);
239 /*! \} */
240 /*---------------------------------------------------------------------*/
241 /*! \name Construction */
242 /*! \{ */
244 Barrier *create(const Char8 *szName, bool bGlobal);
246 /*! \} */
247 /*========================= PROTECTED ===============================*/
249 protected:
251 typedef MPType Inherited;
253 /*---------------------------------------------------------------------*/
254 /*! \name Class Specific */
255 /*! \{ */
257 static UInt32 _uiBarrierCount;
258 CreateBarrierF _fCreateBarrier;
260 /*! \} */
261 /*========================== PRIVATE ================================*/
263 private:
265 /*!\brief prohibit default function (move to 'public' if needed) */
266 MPBarrierType(const MPBarrierType &source);
267 /*!\brief prohibit default function (move to 'public' if needed) */
268 void operator =(const MPBarrierType &source);
271 //---------------------------------------------------------------------------
272 // Class
273 //---------------------------------------------------------------------------
275 /*! \ingroup GrpBaseMultiThreading
276 \ingroup GrpLibOSGBase
279 class OSG_BASE_DLLMAPPING MPCondVarType : public MPType
281 /*========================== PRIVATE ================================*/
283 private:
285 /*========================== PUBLIC =================================*/
287 public :
289 /*---------------------------------------------------------------------*/
290 /*! \name Constructor */
291 /*! \{ */
293 MPCondVarType(const Char8 *szName,
294 const Char8 *szParentName,
295 CreateCondVarF fCreateCondVar,
296 const UInt32 uiNamespace = GlobalNamespace);
298 /*! \} */
299 /*---------------------------------------------------------------------*/
300 /*! \name Destructor */
301 /*! \{ */
303 virtual ~MPCondVarType(void);
305 /*! \} */
306 /*---------------------------------------------------------------------*/
307 /*! \name Construction */
308 /*! \{ */
310 CondVar *create(const Char8 *szName, bool bGlobal);
312 /*! \} */
313 /*========================= PROTECTED ===============================*/
314 protected:
316 typedef MPType Inherited;
318 /*---------------------------------------------------------------------*/
319 /*! \name Class Specific */
320 /*! \{ */
322 static UInt32 _uiCondVarCount;
323 CreateCondVarF _fCreateCondVar;
325 /*! \} */
326 /*========================== PRIVATE ================================*/
328 private:
330 /*!\brief prohibit default function (move to 'public' if needed) */
331 MPCondVarType(const MPCondVarType &source);
332 /*!\brief prohibit default function (move to 'public' if needed) */
333 void operator =(const MPCondVarType &source);
338 //---------------------------------------------------------------------------
339 // Class
340 //---------------------------------------------------------------------------
342 /*! \ingroup GrpBaseMultiThreading
343 \ingroup GrpLibOSGBase
346 class OSG_BASE_DLLMAPPING MPLockType : public MPType
348 /*========================== PRIVATE ================================*/
350 private:
352 /*========================== PUBLIC =================================*/
354 public :
356 /*---------------------------------------------------------------------*/
357 /*! \name Constructor */
358 /*! \{ */
360 MPLockType(const Char8 *szName,
361 const Char8 *szParentName,
362 CreateLockF fCreateLock,
363 const UInt32 uiNamespace = GlobalNamespace);
365 /*! \} */
366 /*---------------------------------------------------------------------*/
367 /*! \name Destructor */
368 /*! \{ */
370 virtual ~MPLockType(void);
372 /*! \} */
373 /*---------------------------------------------------------------------*/
374 /*! \name Construction */
375 /*! \{ */
377 Lock *create(const Char8 *szName, bool bGlobal);
379 /*! \} */
380 /*========================= PROTECTED ===============================*/
381 protected:
383 typedef MPType Inherited;
385 /*---------------------------------------------------------------------*/
386 /*! \name Class Specific */
387 /*! \{ */
389 static UInt32 _uiLockCount;
390 CreateLockF _fCreateLock;
392 /*! \} */
393 /*========================== PRIVATE ================================*/
395 private:
397 /*!\brief prohibit default function (move to 'public' if needed) */
398 MPLockType(const MPLockType &source);
399 /*!\brief prohibit default function (move to 'public' if needed) */
400 void operator =(const MPLockType &source);
406 //---------------------------------------------------------------------------
407 // Class
408 //---------------------------------------------------------------------------
410 /*! \ingroup GrpBaseMultiThreading
411 \ingroup GrpLibOSGBase
413 class OSG_BASE_DLLMAPPING MPLockPoolType : public MPType
415 /*========================== PRIVATE ================================*/
417 private:
419 /*========================== PUBLIC =================================*/
421 public :
423 /*---------------------------------------------------------------------*/
424 /*! \name Constructor */
425 /*! \{ */
427 MPLockPoolType(const Char8 *szName,
428 const Char8 *szParentName,
429 CreateLockPoolF fCreateLockPool,
430 const UInt32 uiNamespace = GlobalNamespace);
432 /*! \} */
433 /*---------------------------------------------------------------------*/
434 /*! \name Destructor */
435 /*! \{ */
437 virtual ~MPLockPoolType(void);
439 /*! \} */
440 /*---------------------------------------------------------------------*/
441 /*! \name Construction */
442 /*! \{ */
444 LockPool *create(const Char8 *szName, bool bGlobal);
446 /*! \} */
447 /*========================= PROTECTED ===============================*/
449 protected:
451 typedef MPType Inherited;
453 /*---------------------------------------------------------------------*/
454 /*! \name Class Specific */
455 /*! \{ */
457 static UInt32 _uiLockPoolCount;
458 CreateLockPoolF _fCreateLockPool;
460 /*! \} */
461 /*========================== PRIVATE ================================*/
463 private:
465 /*!\brief prohibit default function (move to 'public' if needed) */
466 MPLockPoolType(const MPLockPoolType &source);
467 /*!\brief prohibit default function (move to 'public' if needed) */
468 void operator =(const MPLockPoolType &source);
473 //---------------------------------------------------------------------------
474 // Class
475 //---------------------------------------------------------------------------
477 /*! \ingroup GrpBaseMultiThreading
478 \ingroup GrpLibOSGBase
481 class OSG_BASE_DLLMAPPING MPSemaphoreType : public MPType
483 /*========================== PRIVATE ================================*/
485 private:
487 /*========================== PUBLIC =================================*/
489 public :
491 /*---------------------------------------------------------------------*/
492 /*! \name Constructor */
493 /*! \{ */
495 MPSemaphoreType(const Char8 *szName,
496 const Char8 *szParentName,
497 CreateSemaphoreF fCreateSemaphore,
498 const UInt32 uiNamespace = GlobalNamespace);
500 /*! \} */
501 /*---------------------------------------------------------------------*/
502 /*! \name Destructor */
503 /*! \{ */
505 virtual ~MPSemaphoreType(void);
507 /*! \} */
508 /*---------------------------------------------------------------------*/
509 /*! \name Construction */
510 /*! \{ */
512 Semaphore *create(const Char8 *szName, bool bGlobal);
514 /*! \} */
515 /*========================= PROTECTED ===============================*/
516 protected:
518 typedef MPType Inherited;
520 /*---------------------------------------------------------------------*/
521 /*! \name Class Specific */
522 /*! \{ */
524 static UInt32 _uiSemaphoreCount;
525 CreateSemaphoreF _fCreateSemaphore;
527 /*! \} */
528 /*========================== PRIVATE ================================*/
530 private:
532 /*!\brief prohibit default function (move to 'public' if needed) */
533 MPSemaphoreType(const MPSemaphoreType &source);
534 /*!\brief prohibit default function (move to 'public' if needed) */
535 void operator =(const MPSemaphoreType &source);
540 //---------------------------------------------------------------------------
541 // Class
542 //---------------------------------------------------------------------------
544 /*! \ingroup GrpBaseMultiThreading
545 \ingroup GrpLibOSGBase
547 class OSG_BASE_DLLMAPPING MPBase : public MemoryObject
549 /*========================== PUBLIC =================================*/
550 public :
552 /*---------------------------------------------------------------------*/
553 /*! \name Class Get */
554 /*! \{ */
556 static const MPType &getStaticType (void);
557 static UInt32 getStaticTypeId(void);
559 /*! \} */
560 /*---------------------------------------------------------------------*/
561 /*! \name Get */
562 /*! \{ */
564 virtual MPType &getType (void);
565 virtual const MPType &getType (void) const;
566 UInt32 getTypeId(void);
567 const Char8 *getCName (void) const;
569 bool isGlobal (void) const;
571 /*! \} */
572 /*========================= PROTECTED ===============================*/
574 protected:
576 typedef MemoryObject Inherited;
578 /*---------------------------------------------------------------------*/
579 /*! \name Class Specific */
580 /*! \{ */
582 static MPType _type;
583 Char8 *_szName;
584 bool _bGlobal;
586 /*! \} */
587 /*---------------------------------------------------------------------*/
588 /*! \name Constructor */
589 /*! \{ */
591 MPBase(const Char8 *szName, bool bGlobal);
593 /*! \} */
594 /*---------------------------------------------------------------------*/
595 /*! \name Destructor */
596 /*! \{ */
598 virtual ~MPBase(void);
600 /*! \} */
601 /*========================== PRIVATE ================================*/
603 private:
605 /*!\brief prohibit default function (move to 'public' if needed) */
606 MPBase(const MPBase &source);
607 /*!\brief prohibit default function (move to 'public' if needed) */
608 void operator =(const MPBase &source);
611 typedef MPBase *MPBaseP;
613 OSG_END_NAMESPACE
615 #include "OSGMPBase.inl"
617 #endif /* _OSGMPBASE_H_ */